Java Reference
In-Depth Information
public URI getPrevious ()
iif ( links == null
null ) return
return null
null ;
for ( Link link : links )
iif ( "previous" . equals ( link . getRel ())) return
return link . getUri ();
return null
null ;
There is no nice way to define a map in JAXB, so all the Atom links are stuffed within a col-
lection property in Customers . The convenience methods getPrevious() and getNext()
iterate through this collection to find the next and previous Atom links embedded within
the document if they exist.
The final difference from the ex06_1 example is the implementation of GET /customers
@Path ( "/customers" )
public class
class CustomerResource
@Produces ( "application/xml" )
public Customers getCustomers ( @QueryParam ( "start" ) int
int start ,
@QueryParam ( "size" ) @DefaultValue ( "2" ) int
int size ,
@Context UriInfo uriInfo )
The @org.jboss.resteasy.annotations.providers.jaxb.Formatted annotation is a
RESTEasy-specific plug-in that formats the XML output returned to the client to include in-
dentations and new lines so that the text is easier to read.
The query parameters for the getCustomers() method, start and size , are optional. They
represent an index into the customer database and how many customers you want returned
by the invocation. The @DefaultValue annotation is used to define a default page size of 2.
The UriInfo instance injected with @Context is used to build the URLs that define next
and previous link relationships.
Search WWH ::

Custom Search