0 Replies Latest reply on Apr 5, 2012 11:16 PM by wei feng

    The interceptor in seam2.2+jboss6.x is not working

    wei feng Newbie

      I build a Interceptor and annotation like this:

       

       

      import org.jboss.seam.annotations.intercept.AroundInvoke;

      import org.jboss.seam.contexts.Contexts;

      import org.jboss.seam.intercept.InvocationContext;

       

      public class LoggedInInterceptor {

          @AroundInvoke

          public Object checkLoggedIn(InvocationContext invocation)

              throws Exception {

              System.out.println("hello");

              boolean isLoggedIn = Contexts.getSessionContext()

                  .get("loggedIn")!=null;

              if (isLoggedIn) {

                  //the user is already logged in return invocation.proceed();

              } else {

                  //the user is not logged in, fwd to login page return "login";

              }

              return invocation.proceed();

          }

      }

       

       

      import org.jboss.seam.annotations.intercept.Interceptors;

       

      @Interceptors(LoggedInInterceptor.class)

      public @interface LoggedIn {}

       

       

       

      And i put it in my Seam Action Class

       

      import javax.ejb.Stateless;

      import javax.interceptor.Interceptors;

       

      import org.domain.etf.intercept.LoggedIn;

      import org.jboss.seam.annotations.In;

      import org.jboss.seam.annotations.Logger;

      import org.jboss.seam.annotations.Name;

      import org.jboss.seam.ejb.SeamInterceptor;

      import org.jboss.seam.international.StatusMessages;

      import org.jboss.seam.log.Log;

       

      @Stateless

      @Name("send")

      @LoggedIn

      @Interceptors(SeamInterceptor.class)

      public class SendBean implements SendAction

      {

          @Logger private Log log;

       

          @In StatusMessages statusMessages;

       

          public void sendTo()

          {

              // implement your business logic here

              log.info("send.sendTo() action called");

              statusMessages.add("sendTo");

          }

       

          // add additional action methods

       

      }

       

       

      Thanks for help!