1 Reply Latest reply on Oct 31, 2007 8:12 AM by Pete Muir

    Interceptor not working!

    John Smith Newbie

      Hi,

      I've looked through the forum and found a few posts regarding interceptors, but none seam to help me with my problem, when the annotated method is called the @AroundInvoke method is not called.

      Any ideas where I'm going wrong would be greatly appreciated

      The annotation :

      package com.ricall.security;
      
      import java.lang.annotation.ElementType;
      import java.lang.annotation.Retention;
      import java.lang.annotation.RetentionPolicy;
      import java.lang.annotation.Target;
      import org.jboss.seam.annotations.Interceptors;
      
      @Target(ElementType.METHOD)
      @Retention(RetentionPolicy.RUNTIME)
      @Interceptors(com.ricall.security.SecurityManager.class)
      public @interface IsAuthorised {
      
       long securityRole();
      }


      The interceptor

      package com.ricall.security;
      
      import javax.interceptor.AroundInvoke;
      import javax.interceptor.InvocationContext;
      import org.jboss.seam.ScopeType;
      import org.jboss.seam.annotations.In;
      import org.jboss.seam.annotations.Interceptor;
      import org.jboss.seam.annotations.Logger;
      import org.jboss.seam.annotations.Name;
      import org.jboss.seam.annotations.Out;
      import org.jboss.seam.annotations.Scope;
      import org.jboss.seam.log.Log;
      import com.ricall.domain.security.SecurityCredentials;
      import com.ricall.domain.subsite.Subsite;
      import com.ricall.domain.user.User;
      import com.ricall.exception.RicallException;
      import com.ricall.repository.security.SecurityCredentialsRepository;
      import com.ricall.repository.subsite.SubsiteRepository;
      import com.ricall.repository.user.UserRepository;
      
      @Name("securityManagerService")
      @Scope(ScopeType.APPLICATION)
      @Interceptor
      public class SecurityManager {
      
       @AroundInvoke
       public Object authorise(InvocationContext invocation) throws Exception {
       Object[] params = invocation.getParameters();
       if (params != null) {
       for (Object obj : params) {
      
       System.out.println(obj);
       }
       }
      
       throw new RicallSecurityException("cannot do this! hands off!");
       }
      etc....
      }
      
      


      The annotated method

      @Create
       @IsAuthorised(securityRole = SecurityManager.isAdmin)
       @Begin(join = true)
       public void create() {
       log.debug("In @Create, beginning conversation");
       userFolderSearchCriteria = new UserFolderSearchCriteria();
       }


      I've also tried annotated non @Create methods