Hi

On Wed, Sep 8, 2010 at 12:03 AM, Jason Chaffee <[email protected]> wrote:

> I am looking for an easy way to jaxb formatting on a per request basis
> in jaxrs.  I see the code in JaxbElementProvider is looking up values
> from the MessageContext to set them in the marshaller.  However, I am
> not quite sure how those values are set into MessageContext in the first
> place and if it can be done on a per request basis?
>
>
> You'd need to set a Marshaller property from a custom ResponseFilter
(registered as a jaxrs provider) or CXF out interceptor. Doing it from
ResponseFilter is probably simpler, as you can have UriInfo or HttpHeaders
injected (provided they can give the hint on whether to format the given
response or not).
Setting a property on a Message instance or the exchange
(message.getExchange()) should be enough for JAXBElementProvider to pick it
up later on from MessageContext.

You may also have MessageContext injected in your response filter and get
to UriInfo/HttpHeaders from it but also set a property on it (call
setContextualProperty(...))

cheers, Sergey


>
> Thanks,
>
>
>
> Jason
>
>

Reply via email to