title: How to get resource method matched to URI before Jersey invokes it?
body: <p>I'm trying to implement a <a href="https://jersey.java.net/nonav/apidocs/1.5/jersey/com/sun/jersey/spi/container/ContainerRequestFilter.html" rel="noreferrer"><code>ContainerRequestFilter</code></a> that does custom validation of a request's parameters. I need to look up the resource method that will be matched to the URI so that I can scrape custom annotations from the method's parameters.</p>
  
  <p>Based on <a href="https://stackoverflow.com/a/7422899/697449">this answer</a> I should be able to inject <a href="https://jersey.java.net/nonav/apidocs/latest/jersey/com/sun/jersey/api/core/ExtendedUriInfo.html" rel="noreferrer"><code>ExtendedUriInfo</code></a> and then use it to match the method:</p>
  
  <pre><code>public final class MyRequestFilter implements ContainerRequestFilter {
  
      @Context private ExtendedUriInfo uriInfo;
  
      @Override
      public ContainerRequest filter(ContainerRequest containerRequest) {
  
          System.out.println(uriInfo.getMatchedMethod());
  
          return containerRequest;
      }
  }
  </code></pre>
  
  <p>But <a href="https://jersey.java.net/nonav/apidocs/latest/jersey/com/sun/jersey/api/core/ExtendedUriInfo.html#getMatchedMethod%28%29" rel="noreferrer"><code>getMatchedMethod</code></a> apparently returns <code>null</code>, all the way up until the method is actually invoked (at which point it's too late for me to do validation).</p>
  
  <p>How can I retrieve the <code>Method</code> that will be matched to a given URI, before the resource method is invoked?</p>
  
  <hr>
  
  <p>For those interested, I'm trying to roll my own required parameter validation, as described in <a href="https://java.net/jira/browse/JERSEY-351" rel="noreferrer">JERSEY-351</a>.</p>