Hi David
I need a little bit more help.
Lets say you have some root resource class with the following locator method :
@Path("/")
public class RootResourceClass {
@Path("/service/{version}")
Object getAuthenticationService(int version) {
return version == 3 ? new org.foo.bar.v3.AuthenticateServiceImpl() :
org.foo.bar.v4.AuthenticateServiceImpl() ;
}
}
You said both AuthenticateService implementations share the common sublocator
path, so does the above sample is close enough to the
way you do it in the actual code ?
Can you please post a sample root resource class showing how
AuthenticateService instances are returned ?
Thanks, Sergey
*Here are the service interfaces:*
=====
@Path("/v3")
public interface AuthenticationService {
@GET
@Path("/authenticate/{uid}:{pass}")
public Response authenticate(@PathParam("uid") String username,
@PathParam("pass") String password);
}
=====
@Path("/v4")
public interface AuthenticationService {
@GET
@Path("/authenticate/{uid}:{pass}")
public Response authenticate(@PathParam("uid") String username,
@PathParam("pass") String password);
@GET
@Path("/authenticate/validate/{token}")
public Response validate(@PathParam("token") String token);
}
=====
I'm presuming those 2 AuthenticationService(s) are in different packages ?
Yes, two separate interfaces. They just happen to share common sub-locator
paths.
So if you do "/v4/authenticate/validate/BTaaZUycRa" then no operation can
be found unless you remove a bean which implements
AuthenticationService with /v3 ?
Correct. The validate is hidden until the the v3 bean is removed. But
authenticate method works fine on both, presumable because it exists in
both.