2 Replies Latest reply on Jan 4, 2007 12:25 PM by Vimal Mayank

    Method Interceptor does not work

    Vimal Mayank Newbie


      I am having troubles getting my method level annotation back by an interceptor to work.

      Here is my annotation class:

      @Target({TYPE, METHOD})
      public @interface Authorized {
       Permission[] value();

      Here is my interceptor class
      public class AuthorizationInterceptor
       public Object checkAuthorization(InvocationContext invocation) throws Exception
       System.out.println("I am inside Authorization Interceptor");
       return invocation.proceed();

      I have a stateful session bean in default scope (Conversation) which has this Authorized Annotation on a method exposed in the local interface. Code is as follows:
      public class ModelUploadAction implements ModelUpload {
       public String uploadFile() {
      // Do some stuff

      I expect the echo line "I am inside the Authorization interceptor" to print, whenever uploadFile method is invoked as a page action, which is not happening.

      I am using Seam 1.0.1GA along with Jboss4.0.4GA

      However, if I move the @Authorized annotation to the class level, it works and I can see the echo line on the console.

      We are using this mechanism to implement some custom permissions which vary depending on the method which is invoked on the session bean. So I can't have that annotation at the class level. On the flip side we have a couple of scenarios where this annotation needs to be on the class level. That is why the annotation is defined to have the capability to present both on the class level as well as the method level.

      I have also tried to include
      @Around( { BijectionInterceptor.class, ValidationInterceptor.class,
      ConversationInterceptor.class, BusinessProcessInterceptor.class })
      in my inteceptor class to see if that works. But that does not work either.

      Could somebody suggest where I am going wrong?

      Your help is appreciated.