LibraryToggle FramesPrintFeedback

The information returned to the consumer determines the exact type of object a resource method returns. This may seem obvious, but the mapping between Java return objects and what is returned to a RESTful consumer is not one-to-one. At a minimum, RESTful consumers need to be returned a valid HTTP return code in addition to any response entity body. The mapping of the data contained within a Java object to a response entity is effected by the MIME types a consumer is willing to accept.

To address the issues involved in mapping Java object to RESTful response messages, resource methods are allowed to return four types of Java constructs:

  • common Java types return basic information with HTTP return codes determined by the JAX-RS runtime.

  • JAXB objects return complex information with HTTP return codes determined by the JAX-RS runtime.

  • JAX-RS Response objects return complex information with a programmatically determined HTTP return status. The Response object also allows HTTP headers to be specified.

  • JAX-RS GenericEntity objects return complex information with HTTP return codes determined by the JAX-RS runtime. The GenericEnitity object provides more information to the runtime components serializing the data.

Comments powered by Disqus