title: Spring - get Method for a given request in Interceptor/Filter
body: <p>Various <code>@RequestMapping</code> methods inside my <code>@Controller</code> classes have custom annotations that I want to analyze at runtime. </p>
  
  <p>E.g:</p>
  
  <pre><code>@Controller
  @RequestMapping("/bla")
  @RequireCommunityLevel("...")
  @AnotherCustomAnnotation(value = "...")
  public class FakeController {
  
      // ...
      @RequireScore(level = Score.Platinum, score = 8500)
      @RequestMapping("/blabla")
      @AnotherCustomAnnotation(value = "...")
      public DTOResponse&lt;MySpecialModel&gt; getMySpecialModels() {
          // ...
      }
  
  }
  </code></pre>
  
  <p>When I receive a request in my custom <code>Interceptor</code> and <code>Filter</code> classes, I want to analyze which <code>Method</code> the request is going to call. </p>
  
  <p>I have worked in the past with custom frameworks based on <code>Javax Servlet</code> and <code>Jetty</code> and often implemented some kind of <strong>method-registry</strong> one could interrogate.</p>
  
  <p>For example:</p>
  
  <pre><code>public class CustomFilter extends Filter {
  
      @Inject
      private MyMethodRegistry registry;
  
      @Override
      public void doFilter(
        ServletRequest request, 
        ServletResponse response,
        FilterChain chain) throws IOException, ServletException {
  
          // get the request path
          final String path = getPath(request); 
  
          final Method m = this.registry.getMethodForPath(path);
  
          // that's what I mean to do
          if (m.getAnnotation(RequireScore.class) != null) { ... }
  
          if (m.getDeclaringClass().getAnnotation(AnotherCustomAnnotation.class != null) { ... }
  
          chain.doFilter(request, response);
      }
  }
  </code></pre>
  
  <p>I'm looking for a similar way in <code>Spring</code>, possibly a built-in utility to analyze at runtime the <code>Annotation</code>'s on my <code>@RequestMapping</code> methods. All of this should happen within my Interceptor/Filter.</p>