2 Replies Latest reply on Feb 22, 2007 8:36 AM by dsouza

    Annotations with interceptor behavior

    dsouza

      I was reading in Bill Burke's "Enterprise JavaBeans 3.0" book that I can create an annotation that will take on an interceptor's behavior by declaring the annotation itself with an interceptor such as in the example:

      @Interceptors(com.titan.interceptors.AuditInterceptors)
      public @interface Audit{
      }
      


      So that this:

      @Audit
      public Object myMethod(){
      }
      


      would be the same as placing the actual interceptor on my method. However, it's just not working for me. If I use a regular interceptor everything is fine, but if I try to do the annotation thing it doesn't work. The interceptor is simply not called.

      I also was carefull to create the annotation with a Runtime retention type and appropriate target but still, nothing.

      Any ideas on what I might be doing wrong?

        • 1. Re: Annotations with interceptor behavior
          mazz

          did you add it to your ejb-jar.xml? Bill's book has examples on how you add them to your XML descriptor. I use this custom interceptor stuff with JBoss EJB3 and it works wonderfully :)

          • 2. Re: Annotations with interceptor behavior
            dsouza

            Actually I don't have an ejb-jar.xml file. I'm trying to avoid xml and use annotations for everything instead.
            From the book I was under the impression that xml was not necessary to do this, at least that's what I understood from the last page in the "Interceptors" chapter. Thanks, anyway.