Using the JAX-RS API, I am assuming there is a way to automatically
transform custom objects to any of a number of supported output formats.
But it is not clear to me how it is done or what the life cycle would be.
For example, I would like to be able to create a method that returns a Java
object (of a specified type @GET public MyClass someGetMethod() - no
@ProduceMime specified), and depending on the Content-Type in the HTTP
request, have a custom converter automatically invoked that would serialize
that Java object to any of the Content-Types supported by my application
(xml, plain text, etc), and automatically return the converted result in the
response.
This would allow me to create a single method that returns a Java type, and
have that type automatically converted to the output format specified by the
client, without having to create a method implementation for each
Content-Type in the request.
Of course I would expect the developer to create the transformation code for
each return type and output format, I am just not clear on what the
interfaces are, how to hook it in, and in general how (or if) it works.
If this is possible, can anyone please point me to some code samples and/or
explanation?
Much thanks, Victor