Interface RestConverter

All Known Implementing Classes:
Introspectable, Queryable, Traversable

public interface RestConverter
REST method response converter.

Implements a filter mechanism for REST method calls that allows response objects to be converted to some other POJO after invocation of the REST method.

Converters are associated with REST methods through the following:

Example:

public class RequestEchoResource extends BasicRestServlet { // GET request handler @RestGet(path="/*", converters={Queryable.class,Traversable.class}) public HttpServletRequest doGet(RestRequest req, RestResponse res) { res.setTitle("Contents of HttpServletRequest object"); return req; } }

Converters can also be associated at the servlet level using the @Rest(converters) annotation.
Applying converters at the resource level is equivalent to applying converters to each resource method individually.

How to implement
Implementers should simply implement the convert(RestRequest, Object) and return back a 'converted' object.
It's up to the implementer to decide what this means.

Subclasses must implement one of the following constructors:

  • public T(); // No-arg constructor
  • public T(ContextProperties); // Property store of the RestContext

Subclasses can also be defined as inner classes of the resource class.

Predefined converters
  • Traversable - Allows URL additional path info to address individual elements in a POJO tree.
  • Queryable - Allows query/view/sort functions to be performed on POJOs.
  • Introspectable - Allows Java public methods to be invoked on the returned POJOs.
See Also:
  • Method Summary

    Modifier and Type
    Method
    Description
    Performs post-call conversion on the specified response object.