users@jersey.java.net

Re: [Jersey] need code samples for hooking in converters

From: Jakub Podlesak <Jakub.Podlesak_at_Sun.COM>
Date: Mon, 16 Jun 2008 09:28:45 +0200

Hi Victor,

You can try to download Jersey bundle [1] and look at the [EntityProvider]
example. You can also see some examples in blog entries [2] and [3].
Some documentation could be found at [4].

HTH,

~Jakub

[1]https://jersey.dev.java.net/servlets/ProjectDocumentList
[2]http://blogs.sun.com/sandoz/entry/jersey_and_abdera_with_a
[3]http://blogs.sun.com/japod/entry/workarounding_cross_domain_restriction_with
[4]http://docs.sun.com/app/docs/doc/820-4867/ggqnr?a=view

On Sun, Jun 15, 2008 at 11:41:31PM -0400, Victor Grazi wrote:
> That's my question too.
> The JSR 311 Spec refers to it but it was not clear to me
>
> On 6/15/08, Mark Volkmann <mark_at_ociweb.com> wrote:
> > On Jun 15, 2008, at 7:31 PM, Victor Grazi wrote:
> >
> >> Hmm, am I missing something - what then is the use of "Entity
> >> Providers"?
> >
> > Documentation on Jersey and JAX-RS seems so scarce now. Maybe I'm just
> > not looking in the right place. Where can I read about entity
> > providers in Jersey?
> >
> >> On Sun, Jun 15, 2008 at 10:02 AM, Mark Volkmann <mark_at_ociweb.com>
> >> wrote:
> >> On Jun 15, 2008, at 1:04 AM, Victor Grazi wrote:
> >>
> >> 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?
> >>
> >>
> >> It is my understanding the JAX-RS doesn't address this. I'm
> >> convinced that the best way to do this for XML is to use XStream.
> >> You can find a quick tutorial I put together on XStream at
> >> http://www.ociweb.com/mark/programming/XStream.html
> >> .
> >>
> >> ---
> >> Mark Volkmann
> >>
> >>
> >>
> >>
> >>
> >> ---------------------------------------------------------------------
> >> To unsubscribe, e-mail: users-unsubscribe_at_jersey.dev.java.net
> >> For additional commands, e-mail: users-help_at_jersey.dev.java.net
> >>
> >>
> >
> >
> > ---
> > Mark Volkmann
> >
> >
> >
> >
> >
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe_at_jersey.dev.java.net
> For additional commands, e-mail: users-help_at_jersey.dev.java.net
>

-- 
http://blogs.sun.com/japod