title: Jersey - dynamically picking resource method
body: <p>I want to dynamically call a resource methods in Jersey based on certain annotation. For example if I have two identical resources in different packages with similar resource method like this...</p>
  
  <pre><code>package com.mycompany.controller.v1;
  
  @Component(value = "UsersControllerv1")
  @Path("/users")
  public class UsersController {
  
      @GET
      @Version("v1")
      @Produces({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON})
      public Response getUsers() {
      }
  }
  
  
  package com.mycompany.controller.v2;
  
  @Component(value = "UsersControllerv2")
  @Path("/users")
  public class UsersController {
  
      @GET
      @Version("v2")
      @Produces({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON})
      public Response getUsers() {
      }
  }
  </code></pre>
  
  <p>Where @Version is a custom annotation which specifies the version of the api. Is there anyway I can intercept a request (possibly using a ResourceFilterFactory) which specifies a version as a header parameter and call the specific resource method with a matching version</p>
  
  <p>If try this I get the following error at startup</p>
  
  <pre><code>12-Sep-2012 14:36:00 com.sun.jersey.spi.inject.Errors processErrorMessages
  SEVERE: The following errors and warnings have been detected with resource and/or provider classes:
  SEVERE: Conflicting URI templates. The URI template /users for root resource class   com.mycompany.controller.v2.UsersController and the URI template /users transform to the same regular expression /users(/.*)?
  12-Sep-2012 14:36:00 com.sun.jersey.spi.spring.container.servlet.SpringServlet initiate
  SEVERE: Exception occurred when intialization
  com.sun.jersey.spi.inject.Errors$ErrorMessagesException
      at com.sun.jersey.spi.inject.Errors.processErrorMessages(Errors.java:170)
      at com.sun.jersey.spi.inject.Errors.postProcess(Errors.java:136)
      at com.sun.jersey.spi.inject.Errors.processWithErrors(Errors.java:199)
      at com.sun.jersey.server.impl.application.WebApplicationImpl.initiate(WebApplicationImpl.java:771)
      at com.sun.jersey.spi.spring.container.servlet.SpringServlet.initiate(SpringServlet.java:117)
      at com.sun.jersey.spi.container.servlet.ServletContainer$InternalWebComponent.initiate(ServletContainer.java:318)
      at com.sun.jersey.spi.container.servlet.WebComponent.load(WebComponent.java:609)
      at com.sun.jersey.spi.container.servlet.WebComponent.init(WebComponent.java:210)
      at com.sun.jersey.spi.container.servlet.ServletContainer.init(ServletContainer.java:373)
      at com.sun.jersey.spi.container.servlet.ServletContainer.init(ServletContainer.java:719)
      at org.eclipse.jetty.servlet.FilterHolder.doStart(FilterHolder.java:114)
  </code></pre>