4 Replies Latest reply on Feb 17, 2008 2:13 PM by pmuir

    Annotation Interception Question

    kasim


      So with the Seam's version of Interceptors it appears to make the code look MUCH nicer.

      I have 2 questions. I gather i can only do it at the class level, and not the method level??

      Secondly. Inside the annotation itself, can i define it as a Seam component? It doesnt appear i can because I was trying to inject a few items and they didn't get injected. I tried using Contexts.lookup to look them up and while it can look up the current object i want it doesnt appear to lookup other items.

      Any other ide i can use?

        • 1. Re: Annotation Interception Question
          monkeyden

          You mean @AroundInvoke? The example uses it on a method:

          http://docs.jboss.com/seam/2.0.1.GA/reference/en/html_single/#d0e4342

          • 2. Re: Annotation Interception Question
            monkeyden

            Ah, I see what you mean. I was looking at the EJB3 example.

            @Target(TYPE)
            @Retention(RUNTIME)
            @Interceptors(LoggedInInterceptor.class)
            public @interface LoggedIn {}

            • 3. Re: Annotation Interception Question
              kasim

               

              "monkeyden" wrote:
              Ah, I see what you mean. I was looking at the EJB3 example.

              @Target(TYPE)
              @Retention(RUNTIME)
              @Interceptors(LoggedInInterceptor.class)
              public @interface LoggedIn {}


              Yeah ... when you do that if you look at the doco its only at the class level.

              That parts not TOOO big of a deal since i just force the user to have two annotations. One at hte class level that the implementation does all the work. Then a marker on the method so i just check.

              The lack of being able to inject other Seam components though does kind of suck.

              There are ways around it since all i am essentially doing is packing it into a message and sending to a queue, but still sucks. Especially if i wanted to do somemthing more complicated. hmmm ...

              • 4. Re: Annotation Interception Question
                pmuir

                1) Its classlevel only - we have an ancient open issue for this, but with Web Beans on the way, I don't think this will see light before then. Your approach is the best workaround I know of.

                2) You should be able inject other components using Component.getInstance/Contexts lookup. What is the lifecycle of this request? JSF? Post your code.