users@jersey.java.net

[Jersey] Re: Adding versioning support in jersey rest

From: Mathews, Benjamin L <benjamin.mathews_at_optum.com>
Date: Thu, 7 Jul 2011 09:20:37 -0500

Versioning is not a Jersey specific question. There is plenty of good
(and some not so good) information out there. The best way to do it that
I'm aware of is using vendor specific mime types.
http://barelyenough.org/blog/2008/05/versioning-rest-web-services/


Ben Mathews

-----Original Message-----
From: Jakub Podlesak [mailto:jakub.podlesak_at_oracle.com]
Sent: Thursday, July 07, 2011 7:50 AM
To: users_at_jersey.java.net
Subject: [Jersey] Re: Adding versioning support in jersey rest

On 07/02/2011 07:17 PM, Christopher Currie wrote:
> AFAIK jersey doesn't do request routing on query parameters. A couple
> of options:
>
> 1. If you're flexible with your API, you can make the version number a

> prefix of the path. Then its a simple matter of having a different
> root resource registered for each version of your API.

That would be one option, another one [1] was suggested by Gili and
Conal.

> 2. If your API is not flexible, then you'll have to do the heavy
> lifting. Your root resource(s) methods will have to accept the
> QueryParam argument, check its value, and return the version-specific
> Resource class as a "subresource". Even though this is a bit of an
> abuse of that mechanic, it should achieve the result. But its a lot
> more work than option 1.
Even if your API is not flexible, i would recommend implementing one of
the above mentioned versioning methods and implement a special request
filter [2] in addition in order to allow the special version query
parameter.
The filter needs to lookup the query parameter in the original request
and return the request updated according to the selected versioning
method.

~Jakub


[1]http://stackoverflow.com/questions/972226/how-to-version-rest-uris/97
5394#975394
[2]http://jersey.java.net/nonav/apidocs/latest/jersey/com/sun/jersey/spi
/container/ContainerRequestFilter.html
> HTH,
> Christopher
>
>
> On 7/2/11, Umesh Bhatt<umesh_bhatt_at_mindtree.com> wrote:
>> Hi,
>>
>> I want to add version support in my rest web service and want to
>> achieve as mentioned below. Please let me know how to achieve it.
>>
>> In URL I want to add QueryParam version and based on this value want
>> to call correct resource. For this I want to create Http request
>> interceptor to check version info and call appropriate resource.
>> Please let me know how to do this.
>>
>> Thanks,
>> Umesh
>>
>> ________________________________
>>
>> http://www.mindtree.com/email/disclaimer.html
>>


This e-mail, including attachments, may include confidential and/or
proprietary information, and may be used only by the person or entity
to which it is addressed. If the reader of this e-mail is not the intended
recipient or his or her authorized agent, the reader is hereby notified
that any dissemination, distribution or copying of this e-mail is
prohibited. If you have received this e-mail in error, please notify the
sender by replying to this message and delete this e-mail immediately.