From a resource standpoint, it is more expensive (especially in memory starved environments).
From a development standpoint, I feel parallel deployments is the only thing that really makes sense with versioning, otherwise you end up with mixed classes, and at some point your code from v1 might was on jersey 2.4 where v2 might want to be on the new and shiny, and you end up with all sorts of classpath problems youll never be able to resolve.
On Apr 25, 2014, at 2:32 PM, Robert DiFalco <email@example.com<mailto:firstname.lastname@example.org>> wrote:
That's a cool approach. If I understand you correctly you are saying to keep my old version jars and just create new ones. Then have a router handle the versioning. My only issues with that are (a) more expensive on heroku (where I currently deploy) and (b) it would make hotfixes a little more tedious. But a cool idea for sure.
On Fri, Apr 25, 2014 at 2:11 PM, Van Klaveren, Brian N. <email@example.com<mailto:firstname.lastname@example.org>> wrote:
In the past, I have tackled this problem in several ways.
My preferred method is this:
Deploy your application to a unique path, and use an additional router or rewrite rules:
use a router:
example.com/api/v1<http://example.com/api/v1> -> example.com/roberts-api-v1.0<http://example.com/roberts-api-v1.0>
example.com/api/v1.1<http://example.com/api/v1.1> -> example.com/roberts-api-v1.1<http://example.com/roberts-api-v1.1>
example.com/api/v2<http://example.com/api/v2> -> example.com/roberts-api-v2<http://example.com/roberts-api-v2>
example.com/api/dev<http://example.com/api/dev> -> example.com/roberts-api-v2.0-SNAPSHOT<http://example.com/roberts-api-v2.0-SNAPSHOT>
Then the rest of the application doesnt ever have to know about its version number.
I did it with the router once, using:
You could also write your own filter to do something similar.
I think I had another version where I had added some HTTP headers which appended the original URL.
Theres probably better ways, but I was fine with this.
Let's say that I choose to do URI versioning. I know many people are against this approach but I don't want to spark a discussion on *which* method I use for versioning. I want to ask HOW I would do it.
What I would like to do (ideally) is have a Container Request Filter that will see if (for example) there is a V2 contained in the incoming the request path. If there *is* the filter will look to see if there is a resource with an exact match for this path. If there is *NOT* an exact match it will modify the request URI to use the V1 version of the resource method.
Is there a way to do this? Is there a better approach to take for URI versions with JAX-RS?