users@jersey.java.net

Re: [Jersey] Re: Re[Jersey] ading entity body

From: Paul Sandoz <Paul.Sandoz_at_Sun.COM>
Date: Thu, 23 Oct 2008 17:13:19 +0200

On Oct 23, 2008, at 4:41 PM, Gili wrote:

>
>
> Paul Sandoz wrote:
>>
>> What XML API do you want to use?
>>
>
> XOM or dom4j.
>
>
> Paul Sandoz wrote:
>>
>> You want to use POST for partial update?
>>
>
> Actually I was going to use PUT for both partial and full updates.
>

That would be against the semantics of PUT.


>
> Paul Sandoz wrote:
>>
>> You can just use InputStream directly.
>>
>> @POST void post(InputStream in) { ... }
>>
>> Or you can use JAXB, or DOM:
>>
>> @POST void post(javax.xml.transform.dom.DOMSource ds) { ...
>>
>
> That's very cool :) Where can I find a list of the kinds of
> parameters I can
> expect JAX-RS or Jersey to provide auto-magically? :)
>

See here:

https://jsr311.dev.java.net/nonav/releases/1.0/spec/
spec3.html#x3-460004.2.4
https://jersey.dev.java.net/source/browse/*checkout*/jersey/tags/jersey-1.0/jersey/dependencies.html

>
> Paul Sandoz wrote:
>>
>>> Does JAX-RS write something
>>> proprietary onto the HTTP headers or body to this end or is the
>>> Provider in
>>> full control of what's getting written?
>>
>> No. The application developer is in control of the Java type and
>> media
>> type, which results in the selection of the most appropriate
>> MessageBodyReader.
>>
>
> How does a MessageBodyReader indicate it can parse a certain
> InputStream
> without consuming it in the process of checking?


Declare @Produces on the reader class.


> :) The only way I can think
> of is using the headers or media type. Is there another way?
>
>
> Paul Sandoz wrote:
>>
>>> Doesn't this mechanism assume that
>>> servers and clients will share the same MessageBodyReader/Writer
>>> implementation?
>>
>> No.
>>
>
> So I'm not sure I understand how this is supposed to work. If the
> server is
> using MessageBodyWriter to encode a Java object, doesn't the client
> need to
> know how to decode it? Are you saying it doesn't need to know
> anything about
> MessageBodyReader/Writer so long as it understands the format
> produced by
> the server's MessageBodyWriter?
>

Yes, the media type defines the format.

Paul.