users@jersey.java.net

Re: [Jersey] Using MessageBodyReader

From: Kem Elbrader <kem.elbrader_at_elementline.com>
Date: Thu, 21 Aug 2008 16:33:30 -0600

The developer guide state that "the MessageBodyReader is used to map
an HTTP request entity body to method parameters"[1] Here is an
example http://weblogs.java.net/blog/mhadley/archive/2008/02/integrating_jer_2.html

I want to have a get method that takes a javax.awt.Shape which is
retrieved from a query parameter.
For example,
http://localhost:8080/?s=r:10,20 might return an image of a rectangle
with dimension 10 wide and 20 high and
http://localhost:8080/?s=o:10,20 would return an oval with those
dimensions.
http://localhost:8080/?s=p:(0,0),(10,0),(5,10) would return a triangle.

I'd prefer the get method to avoid the conversion of strings to
java.awt.Shape if possible and I thought that MessageBodyReader could
be used to do that.

I'm I wrong about the use of MessageBodyReader? If so, is there
another way of accomplishing this?

[1] http://docs.sun.com/app/docs/doc/820-4867/ggqrs?l=en&a=view

On Thu, Aug 21, 2008 at 3:47 PM, Arul Dhesiaseelan <arul_at_fluxcorp.com> wrote:
> If you are using query params in GET, then I would think that you need to
> provide a String type instead of a complex type. Change it to String s, it
> should work and you can invoke using GET http://localhost:8080/?s=shape .
> Not sure if this is what you intended.
>
> -Arul
>
> Kem Elbrader wrote:
>>
>> I'm getting the following exception when I attempt to deploy my jersey
>> app to glassfish v2.
>>
>> com.sun.jersey.api.container.ContainerException: Method, public
>> java.awt.image.BufferedImage
>> com.el.ui.graphicserver.Renderer.draw(java.awt.Shape), annotated with
>> GET of resource, class com.el.ui.graphicserver.Renderer, is not
>> recognized as valid Java method annotated with @HttpMethod.
>>
>> I'm attempting to use the a MessageBodyReader named ShapeProvider to
>> allow java.awt.Shape to be used as a parameter in my @GET method. I'm
>> not sure if I'm using this correctly.
>>
>> I've attached my project.
>>
>> Thanks for any help.
>> Kem Elbrader
>>
>>
>> ________________________________
>> Scanned by MessageLabs for Flux
>> ________________________________
>> ------------------------------------------------------------------------
>>
>> This body part will be downloaded on demand.
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe_at_jersey.dev.java.net
> For additional commands, e-mail: users-help_at_jersey.dev.java.net
>
>