right, you use your own header since there is no standard for
versioning (and actually versioning means a lot of things depending
the company ;))


Romain Manni-Bucau
@rmannibucau
http://www.tomitribe.com
http://rmannibucau.wordpress.com
https://github.com/rmannibucau


2014-10-20 10:38 GMT+02:00 Alex Soto <asot...@gmail.com>:
> yes sorry when I said content I mean the Content field of Header.
>
> 2014-10-20 10:36 GMT+02:00 Romain Manni-Bucau <rmannibu...@gmail.com>:
>
>> sure, only the header does it
>>
>>
>> Romain Manni-Bucau
>> @rmannibucau
>> http://www.tomitribe.com
>> http://rmannibucau.wordpress.com
>> https://github.com/rmannibucau
>>
>>
>> 2014-10-20 10:34 GMT+02:00 Alex Soto <asot...@gmail.com>:
>> > yes but then @Consumes and @Produces not containing the version part:
>> >
>> > @Path("/resource")
>> >
>> > @Consumes({"application/xml", "application/json"})
>> >
>> > @Produces({"application/xml", "application/json"})
>> >
>> > public AppApiSubResource getVersionedSubResource() {
>> >
>> >   String version = getVersionFromHeader();
>> >
>> >   return SubResourceFactory.getResource(version);
>> >
>> >
>> > }
>> >
>> > because if content also contains version then we are still in original
>> > problem.
>> >
>> >
>> >
>> >
>> > 2014-10-20 10:21 GMT+02:00 Romain Manni-Bucau <rmannibu...@gmail.com>:
>> >
>> >> You can read the header in the router, route then delegates the impl
>> >> to the next? Also means you can just use rest endpoint to select the
>> >> right impl using same pattern but with a single JAXRS level surely
>> >> (and routing is done to service level).
>> >>
>> >>
>> >> Romain Manni-Bucau
>> >> @rmannibucau
>> >> http://www.tomitribe.com
>> >> http://rmannibucau.wordpress.com
>> >> https://github.com/rmannibucau
>> >>
>> >>
>> >> 2014-10-20 10:17 GMT+02:00 Alex Soto <asot...@gmail.com>:
>> >> > Yes I like the header approach as well, but then I see no way to
>> >> implement
>> >> > it directly using subresources.
>> >> >
>> >> > 2014-10-20 10:14 GMT+02:00 Romain Manni-Bucau <
>> rmannibu...@tomitribe.com
>> >> >:
>> >> >
>> >> >> most of real impl uses path (/v1) but i like header solution. allows
>> >> >> to handle default correctly without rewrite magic and to add it for
>> v2
>> >> >> once forgotten for v1 :)
>> >> >> Romain Manni-Bucau
>> >> >> Twitter: @rmannibucau
>> >> >> Blog: http://rmannibucau.wordpress.com/
>> >> >> LinkedIn: http://fr.linkedin.com/in/rmannibucau
>> >> >> Github: https://github.com/rmannibucau
>> >> >>
>> >> >>
>> >> >>
>> >> >> 2014-10-20 10:10 GMT+02:00 Jean-Louis Monteiro <
>> >> jlmonte...@tomitribe.com>:
>> >> >> > Right. No magic solution.
>> >> >> >
>> >> >> > I've seen the content type pattern, but it has many drawbacks so I
>> >> would
>> >> >> > not go with this one.
>> >> >> >
>> >> >> > --
>> >> >> > Jean-Louis Monteiro
>> >> >> > http://twitter.com/jlouismonteiro
>> >> >> > http://www.tomitribe.com
>> >> >> >
>> >> >> > On Sun, Oct 19, 2014 at 1:48 PM, Alex Soto <asot...@gmail.com>
>> wrote:
>> >> >> >
>> >> >> >> Yes this is what I though about creating a central place, but I
>> was
>> >> >> >> thinking about using a rewrite instead of a subresource. I am
>> going
>> >> to
>> >> >> >> google a bit about this pattern. For what I see there is no magic
>> >> >> solution
>> >> >> >> yet :(
>> >> >> >>
>> >> >> >> Thanks.
>> >> >> >>
>> >> >> >> 2014-10-19 13:44 GMT+02:00 Romain Manni-Bucau <
>> >> >> rmannibu...@tomitribe.com>:
>> >> >> >>
>> >> >> >> > Hi
>> >> >> >> >
>> >> >> >> > What about sub resource locator pattern?
>> >> >> >> >
>> >> >> >> > For versioning I used a sub resource facade delegating to the
>> real
>> >> >> >> > service then. This is just a router but it allows to put all the
>> >> logic
>> >> >> >> > in a single place.
>> >> >> >> > Romain Manni-Bucau
>> >> >> >> > Twitter: @rmannibucau
>> >> >> >> > Blog: http://rmannibucau.wordpress.com/
>> >> >> >> > LinkedIn: http://fr.linkedin.com/in/rmannibucau
>> >> >> >> > Github: https://github.com/rmannibucau
>> >> >> >> >
>> >> >> >> >
>> >> >> >> >
>> >> >> >> > 2014-10-19 13:19 GMT+02:00 Alex Soto <asot...@gmail.com>:
>> >> >> >> > > Hi guys,
>> >> >> >> > >
>> >> >> >> > > this is more a design question than a question about how to do
>> >> >> >> something
>> >> >> >> > > with JAX-RS.
>> >> >> >> > >
>> >> >> >> > > Currently I am developing an API using JAX-RS which must be
>> >> >> >> versionable.
>> >> >> >> > > That means that the API will evolve and client must specify
>> which
>> >> >> >> version
>> >> >> >> > > of the API want to use. There are a lot of strategies but
>> >> finally I
>> >> >> >> > decided
>> >> >> >> > > to use the one using Header and ContentType. Let me show an
>> >> example:
>> >> >> >> > >
>> >> >> >> > > @Consumes*({*"application/vnd.blog.v1+xml"*,*
>> >> >> >> > "application/vnd.blog.v1+json"
>> >> >> >> > > *})*
>> >> >> >> > >
>> >> >> >> > > @Produces*({*"application/vnd.blog.v1+xml"*,*
>> >> >> >> > "application/vnd.blog.v1+json"
>> >> >> >> > > *})*
>> >> >> >> > >
>> >> >> >> > > *public* *class* Book*RestfulService* *{*
>> >> >> >> > >
>> >> >> >> > >
>> >> >> >> > >
>> >> >> >> > >     @GET
>> >> >> >> > >
>> >> >> >> > >     @Path*(*"/books"*)*
>> >> >> >> > >
>> >> >> >> > >    ….
>> >> >> >> > >
>> >> >> >> > > }
>> >> >> >> > >
>> >> >> >> > > @Consumes*({*"application/vnd.blog.v1+xml"*,*
>> >> >> >> > "application/vnd.blog.v1+json"
>> >> >> >> > > *})*
>> >> >> >> > >
>> >> >> >> > > @Produces*({*"application/vnd.blog.v1+xml"*,*
>> >> >> >> > "application/vnd.blog.v1+json"
>> >> >> >> > > *})*
>> >> >> >> > >
>> >> >> >> > > *public* *class* Author*RestfulService* *{*
>> >> >> >> > >
>> >> >> >> > >
>> >> >> >> > >
>> >> >> >> > >     @GET
>> >> >> >> > >
>> >> >> >> > >     @Path*(*“/authors”*)*
>> >> >> >> > >
>> >> >> >> > >    ….
>> >> >> >> > >
>> >> >> >> > > }
>> >> >> >> > >
>> >> >> >> > > That's an example of version one, but now let's say I have a
>> >> >> >> modification
>> >> >> >> > > only in Author endpoint. I can do it and then the restful
>> will be
>> >> >> v2.
>> >> >> >> So
>> >> >> >> > I
>> >> >> >> > > will have something like:
>> >> >> >> > >
>> >> >> >> > > @Consumes*({*"application/vnd.blog.v2+xml"*,*
>> >> >> >> > "application/vnd.blog.v2+json"
>> >> >> >> > > *})*
>> >> >> >> > >
>> >> >> >> > > @Produces*({*"application/vnd.blog.v2+xml"*,*
>> >> >> >> > "application/vnd.blog.v2+json"
>> >> >> >> > > *})*
>> >> >> >> > >
>> >> >> >> > > *public* *class* Author2*RestfulService* *{*
>> >> >> >> > >
>> >> >> >> > >
>> >> >> >> > >
>> >> >> >> > >     @GET
>> >> >> >> > >
>> >> >> >> > >     @Path*(*“/authors”*)*
>> >> >> >> > >
>> >> >> >> > >    ….
>> >> >> >> > >
>> >> >> >> > > }
>> >> >> >> > > The problem is that because Book has not received any
>> >> modification,
>> >> >> I
>> >> >> >> > > should add @Consumes and @Produces with v2 as well, something
>> >> like:
>> >> >> >> > >
>> >> >> >> > > @Consumes*({*"application/vnd.blog.v1+xml"*,*
>> >> >> >> > "application/vnd.blog.v1+json",
>> >> >> >> > > "application/vnd.blog.v2+xml"*,*
>> >> "application/vnd.blog.v2+json"*})*
>> >> >> >> > >
>> >> >> >> > > @Produces*({*"application/vnd.blog.v1+xml"*,*
>> >> >> >> > "application/vnd.blog.v1+json",
>> >> >> >> > > ....*})*
>> >> >> >> > >
>> >> >> >> > > *public* *class* Book*RestfulService* *{*
>> >> >> >> > >
>> >> >> >> > > *}*
>> >> >> >> > >
>> >> >> >> > > So now it is easy but if I have 25 services then I would need
>> to
>> >> go
>> >> >> one
>> >> >> >> > by
>> >> >> >> > > one and add the media type as well. The problem is that I can
>> >> miss
>> >> >> one
>> >> >> >> > and
>> >> >> >> > > then the API had a misplaced endpoint.
>> >> >> >> > >
>> >> >> >> > > One thing that I have thought about it is create a rewriting
>> >> filter
>> >> >> >> > where I
>> >> >> >> > > can intercept the calls and then redirect to the correct
>> >> endpoint.
>> >> >> In
>> >> >> >> > this
>> >> >> >> > > way all the rules will be placed in a single place.
>> >> >> >> > >
>> >> >> >> > > Any hints/experience on this?
>> >> >> >> > >
>> >> >> >> > > Thank you so much.
>> >> >> >> > >
>> >> >> >> > >
>> >> >> >> > > --
>> >> >> >> > > +----------------------------------------------------------+
>> >> >> >> > >   Alex Soto Bueno
>> >> >> >> > >   www.lordofthejars.com
>> >> >> >> > > +----------------------------------------------------------+
>> >> >> >> >
>> >> >> >>
>> >> >> >>
>> >> >> >>
>> >> >> >> --
>> >> >> >> +----------------------------------------------------------+
>> >> >> >>   Alex Soto Bueno - Computer Engineer
>> >> >> >>   www.lordofthejars.com
>> >> >> >> +----------------------------------------------------------+
>> >> >> >>
>> >> >>
>> >> >
>> >> >
>> >> >
>> >> > --
>> >> > +----------------------------------------------------------+
>> >> >   Alex Soto Bueno - Computer Engineer
>> >> >   www.lordofthejars.com
>> >> > +----------------------------------------------------------+
>> >>
>> >
>> >
>> >
>> > --
>> > +----------------------------------------------------------+
>> >   Alex Soto Bueno - Computer Engineer
>> >   www.lordofthejars.com
>> > +----------------------------------------------------------+
>>
>
>
>
> --
> +----------------------------------------------------------+
>   Alex Soto Bueno - Computer Engineer
>   www.lordofthejars.com
> +----------------------------------------------------------+

Reply via email to