Skip to content

Instantly share code, notes, and snippets.

@abhirockzz
Created October 28, 2016 03:44
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save abhirockzz/077010092ade2163f64b6f7bf3c9e424 to your computer and use it in GitHub Desktop.
Save abhirockzz/077010092ade2163f64b6f7bf3c9e424 to your computer and use it in GitHub Desktop.
Registering a JAX-RS filter dynamically based on resource class & method criteria
@Provider
public class DynamicFilter implements DynamicFeature {
@Override
public void configure(ResourceInfo resInfo, FeatureContext ctx) {
if (UserResource.class.equals(resInfo.getResourceClass()) &&
resInfo.getResourceMethod().getName().contains("PUT")) {
ctx.register(AuthenticationFilter.class);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment