users@jersey.java.net

Re: switch providers based on URL

From: Paul Sandoz <Paul.Sandoz_at_oracle.com>
Date: Wed, 1 Dec 2010 16:33:45 +0100

On Dec 1, 2010, at 12:42 PM, Reto Bachmann-Gmür wrote:

> well, what you can do is delegate to the old-style MessageBodyWriter
> in the new MBW for certain paths (having URiInfo as an injected filed.
>

Yes, and the servlet way is an option to. It all depends on how
granular you want to be.

Another approach using MBWs is to use a resource filter factory to
register filters that wrap a response entity for certain resources
then you can use an MBW for that wrapping entity type.

Paul.


> Reto
>
> On Tue, Nov 30, 2010 at 8:39 PM, Ronak Patel <ronak2121_at_yahoo.com>
> wrote:
> Only other thing I can think of is playing games with Spring and
> dynamically loading the @Provider bean per request instead of as a
> Singleton...
>
> Would that work?
>
> From: Ronak Patel <ronak2121_at_yahoo.com>
>
> To: users_at_jersey.java.net
> Sent: Tue, November 30, 2010 11:37:14 AM
>
> Subject: Re: switch providers based on URL
>
> So that means we can't do that?...
>
> This will force me to create two different copies of my war files
> then....one legacy one that uses the mapped style when I didn't know
> any better....
>
> and
>
> a new war file that uses the better natural style JSON.....
>
> That's what I was afraid of....
>
> From: Reto Bachmann-Gmür <reto_at_gmuer.ch>
> To: users_at_jersey.java.net
> Sent: Tue, November 30, 2010 7:36:43 AM
> Subject: Re: switch providers based on URL
>
> I think it would be a good extension to the jax-rs spec to restrict
> ceratin provider to a URI-space.
>
> Cheers,
> Reto
>
> On Tue, Nov 30, 2010 at 4:26 PM, Ronak Patel <ronak2121_at_yahoo.com>
> wrote:
> Hi All,
>
> Does anyone know if we can switch which @Provider JAX-RS Jersey uses
> based on a URI?
>
> I have certain endpoints I want wrapped style JSON (for backward
> compatibility) and certain endpoints I want natural style JSON (for
> everything going forward).
>
> Thanks,
>
> Ronak Patel
>
>
>
>
>