[jboss-cvs] jboss-seam/src/main/org/jboss/seam/interceptors ...

Gavin King gavin.king at jboss.com
Sun Feb 11 14:48:12 EST 2007


  User: gavin   
  Date: 07/02/11 14:48:12

  Modified:    src/main/org/jboss/seam/interceptors      
                        BijectionInterceptor.java
                        BusinessProcessInterceptor.java
                        ConversationInterceptor.java
                        ConversationalInterceptor.java
                        RollbackInterceptor.java ValidationInterceptor.java
  Log:
  optimize interceptor stack
  
  Revision  Changes    Path
  1.29      +10 -89    jboss-seam/src/main/org/jboss/seam/interceptors/BijectionInterceptor.java
  
  (In the diff below, changes in quantity of whitespace are not shown.)
  
  Index: BijectionInterceptor.java
  ===================================================================
  RCS file: /cvsroot/jboss/jboss-seam/src/main/org/jboss/seam/interceptors/BijectionInterceptor.java,v
  retrieving revision 1.28
  retrieving revision 1.29
  diff -u -b -r1.28 -r1.29
  --- BijectionInterceptor.java	9 Feb 2007 03:44:22 -0000	1.28
  +++ BijectionInterceptor.java	11 Feb 2007 19:48:12 -0000	1.29
  @@ -1,18 +1,12 @@
  -//$Id: BijectionInterceptor.java,v 1.28 2007/02/09 03:44:22 gavin Exp $
  +//$Id: BijectionInterceptor.java,v 1.29 2007/02/11 19:48:12 gavin Exp $
   package org.jboss.seam.interceptors;
   
  -import static org.jboss.seam.util.EJB.POST_ACTIVATE;
  -import static org.jboss.seam.util.EJB.POST_CONSTRUCT;
  -import static org.jboss.seam.util.EJB.PRE_DESTROY;
  -import static org.jboss.seam.util.EJB.PRE_PASSIVATE;
   
  -import java.lang.reflect.Method;
   
  +import org.jboss.seam.Component;
   import org.jboss.seam.log.LogProvider;
   import org.jboss.seam.log.Logging;
   import org.jboss.seam.annotations.AroundInvoke;
  -import org.jboss.seam.annotations.Create;
  -import org.jboss.seam.annotations.Destroy;
   import org.jboss.seam.annotations.Interceptor;
   import org.jboss.seam.intercept.InvocationContext;
   
  @@ -31,14 +25,6 @@
      
      private boolean reentrant; //OK, since all Seam components are single-threaded
      
  -   private static boolean isLifecycleMethod(Method method)
  -   {
  -      return method==null || //EJB 3 JavaDoc says InvocationContext.getMethod() returns null for lifecycle callbacks!
  -            method.isAnnotationPresent(Create.class) || method.isAnnotationPresent(Destroy.class) ||
  -            method.isAnnotationPresent(POST_CONSTRUCT) || method.isAnnotationPresent(PRE_DESTROY) ||
  -            method.isAnnotationPresent(PRE_PASSIVATE) || method.isAnnotationPresent(POST_ACTIVATE);
  -   }
  -
      @AroundInvoke
      public Object aroundInvoke(InvocationContext invocation) throws Exception
      {
  @@ -55,85 +41,20 @@
            reentrant = true;
            try
            {
  -            return bijectNonreentrantComponent(invocation);
  -         }
  -         finally
  -         {
  -            reentrant = false;
  -         }
  -      }
  -   }
  -   
  -   private Object bijectNonreentrantComponent(InvocationContext invocation) throws Exception
  -   {
  -      
  -      if ( getComponent().needsInjection() ) //only needed to hush the log message
  -      {
  -         if ( log.isTraceEnabled() )
  -         {
  -            log.trace("injecting dependencies of: " + getComponent().getName());
  -         }
  -         getComponent().inject( invocation.getTarget(), !isLifecycleMethod( invocation.getMethod() ) );
  -      }
  -      
  +            Component component = getComponent();
  +            boolean enforceRequired = !component.isLifecycleMethod( invocation.getMethod() );
  +            component.inject( invocation.getTarget(), enforceRequired );
         Object result = invocation.proceed();
  +            component.outject( invocation.getTarget(), enforceRequired );
  +            component.disinject( invocation.getTarget() );
  +            return result;
         
  -      if ( getComponent().needsOutjection() ) //only needed to hush the log message
  -      {
  -         if ( log.isTraceEnabled() )
  -         {
  -            log.trace("outjecting dependencies of: " + getComponent().getName());
  -         }
  -         getComponent().outject( invocation.getTarget(), !isLifecycleMethod( invocation.getMethod() ) );
  -      }
  -      
  -      if ( getComponent().needsInjection() ) //only needed to hush the log message
  -      {
  -         if ( log.isTraceEnabled() )
  -         {
  -            log.trace("disinjecting dependencies of: " + getComponent().getName());
  -         }
  -         getComponent().disinject( invocation.getTarget() );
  -      }
  -      
  -      //method parameter injection?
  -      /*Method method = invocation.getMethod();
  -      if (method!=null) //TODO: YEW! for unit tests
  -      {
  -         //TODO: could this be slow?
  -         Annotation[][] allParameterAnnotations = method.getParameterAnnotations();
  -         for( int i=0; i<allParameterAnnotations.length; i++ )
  -         {
  -            Annotation[] paramAnns = allParameterAnnotations[i];
  -            for ( Annotation ann: paramAnns )
  -            {
  -               if (ann instanceof In)
  -               {
  -                  String name = ( (In) ann ).value();
  -                  if (name==null)
  -                  {
  -                     throw new IllegalArgumentException("@RequestIn must specify a parameter name when used in a method parameter");
                     }
  -                  invocation.getParameters()[i] = Component.getInstance(name);
  -               }
  -               else if (ann instanceof RequestParameter)
  -               {
  -                  String name = ( (RequestParameter) ann ).value();
  -                  if (name==null)
  +         finally
                     {
  -                     throw new IllegalArgumentException("@RequestParameter must specify a parameter name when used in a method parameter");
  -                  }
  -                  invocation.getParameters()[i] = Component.convertMultiValueRequestParameter( 
  -                        Component.getRequestParameters(), 
  -                        name, 
  -                        method.getParameterTypes()[i] 
  -                     );
  -               }
  +            reentrant = false;
               }
            }
  -      }*/
  -      
  -      return result;
      }
   
   }
  
  
  
  1.51      +2 -2      jboss-seam/src/main/org/jboss/seam/interceptors/BusinessProcessInterceptor.java
  
  (In the diff below, changes in quantity of whitespace are not shown.)
  
  Index: BusinessProcessInterceptor.java
  ===================================================================
  RCS file: /cvsroot/jboss/jboss-seam/src/main/org/jboss/seam/interceptors/BusinessProcessInterceptor.java,v
  retrieving revision 1.50
  retrieving revision 1.51
  diff -u -b -r1.50 -r1.51
  --- BusinessProcessInterceptor.java	9 Feb 2007 03:44:22 -0000	1.50
  +++ BusinessProcessInterceptor.java	11 Feb 2007 19:48:12 -0000	1.51
  @@ -29,10 +29,10 @@
    * Interceptor which handles interpretation of jBPM-related annotations.
    *
    * @author <a href="mailto:steve at hibernate.org">Steve Ebersole </a>
  - * @version $Revision: 1.50 $
  + * @version $Revision: 1.51 $
    */
   @Interceptor(stateless=true,
  -             around={ValidationInterceptor.class, BijectionInterceptor.class, OutcomeInterceptor.class})
  +             around={ValidationInterceptor.class, BijectionInterceptor.class})
   public class BusinessProcessInterceptor extends AbstractInterceptor
   {
      private static final long serialVersionUID = 758197867958840918L;
  
  
  
  1.59      +2 -2      jboss-seam/src/main/org/jboss/seam/interceptors/ConversationInterceptor.java
  
  (In the diff below, changes in quantity of whitespace are not shown.)
  
  Index: ConversationInterceptor.java
  ===================================================================
  RCS file: /cvsroot/jboss/jboss-seam/src/main/org/jboss/seam/interceptors/ConversationInterceptor.java,v
  retrieving revision 1.58
  retrieving revision 1.59
  diff -u -b -r1.58 -r1.59
  --- ConversationInterceptor.java	9 Feb 2007 03:44:22 -0000	1.58
  +++ ConversationInterceptor.java	11 Feb 2007 19:48:12 -0000	1.59
  @@ -1,4 +1,4 @@
  -//$Id: ConversationInterceptor.java,v 1.58 2007/02/09 03:44:22 gavin Exp $
  +//$Id: ConversationInterceptor.java,v 1.59 2007/02/11 19:48:12 gavin Exp $
   package org.jboss.seam.interceptors;
   
   import java.lang.reflect.Method;
  @@ -27,7 +27,7 @@
    * @author Gavin King
    */
   @Interceptor(stateless=true,
  -             around={ValidationInterceptor.class, BijectionInterceptor.class, OutcomeInterceptor.class},
  +             around={ValidationInterceptor.class, BijectionInterceptor.class},
                within=BusinessProcessInterceptor.class)
   public class ConversationInterceptor extends AbstractInterceptor
   {
  
  
  
  1.14      +2 -2      jboss-seam/src/main/org/jboss/seam/interceptors/ConversationalInterceptor.java
  
  (In the diff below, changes in quantity of whitespace are not shown.)
  
  Index: ConversationalInterceptor.java
  ===================================================================
  RCS file: /cvsroot/jboss/jboss-seam/src/main/org/jboss/seam/interceptors/ConversationalInterceptor.java,v
  retrieving revision 1.13
  retrieving revision 1.14
  diff -u -b -r1.13 -r1.14
  --- ConversationalInterceptor.java	9 Feb 2007 03:44:22 -0000	1.13
  +++ ConversationalInterceptor.java	11 Feb 2007 19:48:12 -0000	1.14
  @@ -1,4 +1,4 @@
  -//$Id: ConversationalInterceptor.java,v 1.13 2007/02/09 03:44:22 gavin Exp $
  +//$Id: ConversationalInterceptor.java,v 1.14 2007/02/11 19:48:12 gavin Exp $
   package org.jboss.seam.interceptors;
   
   import java.lang.reflect.Method;
  @@ -28,7 +28,7 @@
    * @author Gavin King
    */
   @Interceptor(stateless=true,
  -             around={ValidationInterceptor.class, BijectionInterceptor.class, OutcomeInterceptor.class, BusinessProcessInterceptor.class})
  +             around={ValidationInterceptor.class, BijectionInterceptor.class, BusinessProcessInterceptor.class})
   public class ConversationalInterceptor extends AbstractInterceptor
   {
      private static final long serialVersionUID = 1127583515811479385L;
  
  
  
  1.17      +2 -2      jboss-seam/src/main/org/jboss/seam/interceptors/RollbackInterceptor.java
  
  (In the diff below, changes in quantity of whitespace are not shown.)
  
  Index: RollbackInterceptor.java
  ===================================================================
  RCS file: /cvsroot/jboss/jboss-seam/src/main/org/jboss/seam/interceptors/RollbackInterceptor.java,v
  retrieving revision 1.16
  retrieving revision 1.17
  diff -u -b -r1.16 -r1.17
  --- RollbackInterceptor.java	9 Feb 2007 03:44:22 -0000	1.16
  +++ RollbackInterceptor.java	11 Feb 2007 19:48:12 -0000	1.17
  @@ -1,4 +1,4 @@
  -//$Id: RollbackInterceptor.java,v 1.16 2007/02/09 03:44:22 gavin Exp $
  +//$Id: RollbackInterceptor.java,v 1.17 2007/02/11 19:48:12 gavin Exp $
   package org.jboss.seam.interceptors;
   
   import static org.jboss.seam.ComponentType.JAVA_BEAN;
  @@ -21,7 +21,7 @@
    * 
    * @author Gavin King
    */
  - at Interceptor(stateless=true, around=OutcomeInterceptor.class)
  + at Interceptor(stateless=true)
   public class RollbackInterceptor extends AbstractInterceptor 
   {
      private static final long serialVersionUID = 5551801508325093417L;
  
  
  
  1.28      +5 -4      jboss-seam/src/main/org/jboss/seam/interceptors/ValidationInterceptor.java
  
  (In the diff below, changes in quantity of whitespace are not shown.)
  
  Index: ValidationInterceptor.java
  ===================================================================
  RCS file: /cvsroot/jboss/jboss-seam/src/main/org/jboss/seam/interceptors/ValidationInterceptor.java,v
  retrieving revision 1.27
  retrieving revision 1.28
  diff -u -b -r1.27 -r1.28
  --- ValidationInterceptor.java	9 Feb 2007 03:44:22 -0000	1.27
  +++ ValidationInterceptor.java	11 Feb 2007 19:48:12 -0000	1.28
  @@ -1,4 +1,4 @@
  -//$Id: ValidationInterceptor.java,v 1.27 2007/02/09 03:44:22 gavin Exp $
  +//$Id: ValidationInterceptor.java,v 1.28 2007/02/11 19:48:12 gavin Exp $
   package org.jboss.seam.interceptors;
   
   import java.lang.reflect.Method;
  @@ -14,6 +14,7 @@
   import org.jboss.seam.annotations.AroundInvoke;
   import org.jboss.seam.annotations.IfInvalid;
   import org.jboss.seam.annotations.Interceptor;
  +import org.jboss.seam.annotations.Outcome;
   import org.jboss.seam.core.FacesMessages;
   import org.jboss.seam.intercept.InvocationContext;
   
  @@ -26,8 +27,7 @@
    * @deprecated
    * @author Gavin King
    */
  - at Interceptor(stateless=true,
  -             within={BijectionInterceptor.class, OutcomeInterceptor.class})
  + at Interceptor(stateless=true, within=BijectionInterceptor.class)
   @SuppressWarnings("deprecation")
   public class ValidationInterceptor extends AbstractInterceptor
   {
  @@ -60,7 +60,8 @@
                  }
                  FacesMessages.instance().add(iv);
               }
  -            return ifInvalid.outcome();
  +            String outcome = ifInvalid.outcome();
  +            return Outcome.REDISPLAY.equals(outcome) ? null : outcome;
            }
         }
         else
  
  
  



More information about the jboss-cvs-commits mailing list