Skip to content

Instantly share code, notes, and snippets.

@abhirockzz
Last active March 7, 2016 18:26
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/5b4abe9716d9c772817d to your computer and use it in GitHub Desktop.
Save abhirockzz/5b4abe9716d9c772817d to your computer and use it in GitHub Desktop.
Step 1: Define a custom annotation with the @NamedBinding annotation
@NameBinding
@Target({ ElementType.TYPE, ElementType.METHOD })
@Retention(value = RetentionPolicy.RUNTIME)
public @interface Audited { }
Step 2: Apply the custom annotation on the filter or interceptor
@Provider
@Audited
public class AuditFilter implements ContainerRequestFilter {
//filter implementation....
}
Step 3: Apply the same annotation to the required resource class or method
@GET
@Path("{id}")
@Produces("application/json")
@Audited
public Response find(@PathParam("id") String custId){
//search and return customer info
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment