1

Our Java EE project has a RESTful interface available at something like http://example.com/rest/. When the development is progressing we create new versions of this interface. In order to enable backward compatibility we'd like to provide them all online, at different URLs, for example:

http://example.com/rest/1.0/
http://example.com/rest/1.1/

The question is how to deploy them? Shall we assemble a number of WARs (we use Maven)? But the project has the latest version in /trunk.. Maybe we should package them all into one WAR by means of some Maven plugin, retrieving them from Subversion /tags? What is your experience?

Arjan Tijms
  • 37,782
  • 12
  • 108
  • 140
yegor256
  • 102,010
  • 123
  • 446
  • 597

4 Answers4

4

When I hit my finger with a hammer it hurts, what should I do? Stop hitting it maybe?

One of the primary goals of the REST architectural style is to allow client and server to evolve independently.

By creating a new version of your service you are in effect creating an entirely new service to replace the old one. By doing this you throwing away what REST is trying to achieve.

Maybe it is your intent to simply build an HTTP Api, in which case, carry on. (But don't complain when versioning hurts :-))

If you do want to do REST, then recognize that if you find yourself needing to version pieces of a REST api then you did something wrong. That can happen and if it does, I recommend the first place to start is to consider versioning media types. Versioning URIs is a last resort.

Darrel Miller
  • 139,164
  • 32
  • 194
  • 243
2

They're all "first-class" parts of your application.

Don't separate them. You'll only make yourself confused trying to update one without touching another.

When you make a change, you'll probably have to release everything anyway.

S.Lott
  • 384,516
  • 81
  • 508
  • 779
1

Deploy different wars with different paths to your Interface classes. that way you can remove "old" versions without disturbing the newer ones. Personally i would allways deploy the new version under a new filename. that way you don't have to care about any old files.

Laures
  • 5,389
  • 11
  • 50
  • 76
1

If by versioning, you are talking about the structure of your resources/content type, you'd have to keep your old implementation and use content negotiation so as older clients can still use your service.

If the only change is on URL structures, then you don't need any versioning, just use 301-Moved Permanently redirects.

redben
  • 5,578
  • 5
  • 47
  • 63