title: Dynamic binding of a filter in Jersey doesn't work for sub-resources
body: <p>I created a Jersey filter and I need it assigned to some resources (not all). Therefore, I'm using dynamic binding to achieve that.</p>
  
  <pre><code>public class MyDynamicFeature implements DynamicFeature {
  
      @Override
      public void configure(ResourceInfo resourceInfo, FeatureContext featureContext) {
          Path resourcePath = resourceInfo.getResourceClass().getAnnotation(Path.class);
          if (resourcePath != null &amp;&amp; resourcePath.value().contains("/v2/"))
          {
              featureContext.register(MyFilter.class);
          }
      }
  }
  </code></pre>
  
  <p>So I want this filter to be applied to all methods in those resources that contain a certain string in their paths. Some of those resources use sub-resource locators to define sub-resources. E.g.,</p>
  
  <pre><code>@Path("/v2/resource_path")
  @Consumes({ ... })
  @Produces({ ... })
  class MyResource 
  {
      @Path("/subresource_path")
      public MySubResource getSubResource(@Context ResourceContext rc)
      {
          return rc.getResource(MySubResource.class);
      }   
  }
  </code></pre>
  
  <p>Even though Jersey documentation claims </p>
  
  <blockquote>
    <p>The configure method will be executed once for each resource method that is defined in the application.</p>
  </blockquote>
  
  <p>the <code>configure</code> method in <code>MyDynamicFeature</code> shown above doesn't get called for <code>getSubResource</code> method of <code>MyResource</code> class at all. It does get called for all the rest of the methods in <code>MyResource</code> class though (which I omitted in the example).</p>
  
  <p>Is there a way to make this work for sub-resources? I need my filter to be applied to <code>MySubResource</code> as well.</p>
  
  <p>We use Jersey 2.21.</p>