2 Replies Latest reply on Jun 26, 2013 1:27 PM by viccari

    Apply Filter or Interceptor on specific method using NameBinding


      I tried to create filters and interceptors that would apply only to a specific method using an annotation derived from NameBinding.


      I'm using JBoss 7.1.1.Final, where I did upgrade the modules by unzipping resteasy-jaxrs-3.0-beta-1 zip .


      I have a couple of classes which define restful services, and I created (following examples as in http://docs.jboss.org/resteasy/docs/3.0-beta-1/javadocs/javax/ws/rs/NameBinding.html)


      1) an annotation


      @Target({ ElementType.TYPE, ElementType.METHOD })

      @Retention(value = RetentionPolicy.RUNTIME)

      public @interface FrontierResponse {

                String value() default "";





           a Filter class , like



      public class FrontierResponseFilter implements ContainerResponseFilter {



                private Logger log;


        /* (non-Javadoc)

                 * @see javax.ws.rs.container.ContainerResponseFilter#filter(javax.ws.rs.container.ContainerRequestContext, javax.ws.rs.container.ContainerResponseContext)



                public void filter(ContainerRequestContext ctx,

                                    ContainerResponseContext respctx) throws IOException {

        log.info("Frontier response filter :"+ctx.getMethod());




           a restful service class, with a method annotated with the previous annotation






                public List<NodeType> listNodesInSchema(@PathParam("schema") String schema,

                                    @PathParam("db") String db) {


        log.info("Calling listNodesInSchema..."+schema+" "+db);


      I noticed that :

      1) if the filter class does not contain the @Provider annotation, then the filter is not applied at all...


      2) if the filter class is annotated with @Provider...then ALL restful method do get filtered !


      I do not know where I can have done something wrong, I suspect a bad installation, bad if somebody could enlight me I would

      be grateful ;-)