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

Gavin King gavin.king at jboss.com
Tue Oct 10 02:43:16 EDT 2006


  User: gavin   
  Date: 06/10/10 02:43:16

  Modified:    src/main/org/jboss/seam/interceptors              
                        AbstractInterceptor.java
                        AsynchronousInterceptor.java
                        BijectionInterceptor.java
                        ConversationInterceptor.java
                        ConversationalInterceptor.java
                        RemoveInterceptor.java RollbackInterceptor.java
                        TransactionInterceptor.java
                        ValidationInterceptor.java
  Removed:     src/main/org/jboss/seam/interceptors              
                        ClientSideInterceptor.java EventType.java
                        Interceptor.java JavaBeanInterceptor.java
                        SeamInvocationContext.java
  Log:
  refactored interceptor fwk, fixed serialization problems
  
  Revision  Changes    Path
  1.7       +9 -39     jboss-seam/src/main/org/jboss/seam/interceptors/AbstractInterceptor.java
  
  (In the diff below, changes in quantity of whitespace are not shown.)
  
  Index: AbstractInterceptor.java
  ===================================================================
  RCS file: /cvsroot/jboss/jboss-seam/src/main/org/jboss/seam/interceptors/AbstractInterceptor.java,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -b -r1.6 -r1.7
  --- AbstractInterceptor.java	26 Sep 2006 00:29:53 -0000	1.6
  +++ AbstractInterceptor.java	10 Oct 2006 06:43:16 -0000	1.7
  @@ -1,12 +1,8 @@
  -//$Id: AbstractInterceptor.java,v 1.6 2006/09/26 00:29:53 gavin Exp $
  +//$Id: AbstractInterceptor.java,v 1.7 2006/10/10 06:43:16 gavin Exp $
   package org.jboss.seam.interceptors;
   
   import java.io.Serializable;
   
  -import javax.ejb.PostActivate;
  -import javax.ejb.PrePassivate;
  -import javax.interceptor.InvocationContext;
  -
   import org.jboss.seam.Component;
   
   /**
  @@ -14,50 +10,24 @@
    * 
    * @author Gavin King
    */
  -class AbstractInterceptor implements Serializable
  +public class AbstractInterceptor implements Serializable
   {
  -   protected transient Component component;
  +   private transient Component component; //a cache of the Component reference
      private String componentName;
   
      public void setComponent(Component component)
      {
  +      componentName = component.getName();
         this.component = component;
      }
      
  -   @PrePassivate
  -   public void initComponentName(InvocationContext invocation)
  -   {
  -      try
  -      {
  -         invocation.proceed();
  -      }
  -      catch (RuntimeException e)
  -      {
  -         throw e;
  -      }
  -      catch (Exception e)
  +   protected Component getComponent()
         {
  -         throw new RuntimeException("exception in @PrePassivate", e);
  -      }
  -      componentName = component.getName();
  -   }
  -   
  -   @PostActivate
  -   public void initComponent(InvocationContext invocation)
  +      if (component==null)
      {
         component = Component.forName(componentName);
  -      try
  -      {
  -         invocation.proceed();
  -      }
  -      catch (RuntimeException e)
  -      {
  -         throw e;
  -      }
  -      catch (Exception e)
  -      {
  -         throw new RuntimeException("exception in @PostActivate", e);
         }
  +      return component;
      }
   
   }
  
  
  
  1.3       +1 -1      jboss-seam/src/main/org/jboss/seam/interceptors/AsynchronousInterceptor.java
  
  (In the diff below, changes in quantity of whitespace are not shown.)
  
  Index: AsynchronousInterceptor.java
  ===================================================================
  RCS file: /cvsroot/jboss/jboss-seam/src/main/org/jboss/seam/interceptors/AsynchronousInterceptor.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -b -r1.2 -r1.3
  --- AsynchronousInterceptor.java	10 Oct 2006 02:33:22 -0000	1.2
  +++ AsynchronousInterceptor.java	10 Oct 2006 06:43:16 -0000	1.3
  @@ -23,7 +23,7 @@
               !Contexts.getEventContext().isSet(Dispatcher.EXECUTING_ASYNCHRONOUS_CALL);
         if ( scheduleAsync )
         {
  -         Timer timer = Dispatcher.instance().scheduleInvocation(invocation, component);
  +         Timer timer = Dispatcher.instance().scheduleInvocation(invocation, getComponent());
            //if the method returns a Timer, return it to the client
            return invocation.getMethod().getReturnType().equals(Timer.class) ? timer : null;
         }
  
  
  
  1.20      +10 -10    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.19
  retrieving revision 1.20
  diff -u -b -r1.19 -r1.20
  --- BijectionInterceptor.java	2 Oct 2006 04:17:59 -0000	1.19
  +++ BijectionInterceptor.java	10 Oct 2006 06:43:16 -0000	1.20
  @@ -1,4 +1,4 @@
  -//$Id: BijectionInterceptor.java,v 1.19 2006/10/02 04:17:59 gavin Exp $
  +//$Id: BijectionInterceptor.java,v 1.20 2006/10/10 06:43:16 gavin Exp $
   package org.jboss.seam.interceptors;
   
   import java.lang.reflect.Method;
  @@ -39,33 +39,33 @@
      @AroundInvoke
      public Object bijectTargetComponent(InvocationContext invocation) throws Exception
      {
  -      if ( component.needsInjection() ) //only needed to hush the log message
  +      if ( getComponent().needsInjection() ) //only needed to hush the log message
         {
            if ( log.isTraceEnabled() )
            {
  -            log.trace("injecting dependencies of: " + component.getName());
  +            log.trace("injecting dependencies of: " + getComponent().getName());
            }
  -         component.inject( invocation.getTarget(), !isLifecycleMethod( invocation.getMethod() ) );
  +         getComponent().inject( invocation.getTarget(), !isLifecycleMethod( invocation.getMethod() ) );
         }
         
         Object result = invocation.proceed();
         
  -      if ( component.needsOutjection() ) //only needed to hush the log message
  +      if ( getComponent().needsOutjection() ) //only needed to hush the log message
         {
            if ( log.isTraceEnabled() )
            {
  -            log.trace("outjecting dependencies of: " + component.getName());
  +            log.trace("outjecting dependencies of: " + getComponent().getName());
            }
  -         component.outject( invocation.getTarget(), isLifecycleMethod( invocation.getMethod() ) );
  +         getComponent().outject( invocation.getTarget(), isLifecycleMethod( invocation.getMethod() ) );
         }
         
  -      if ( component.needsInjection() ) //only needed to hush the log message
  +      if ( getComponent().needsInjection() ) //only needed to hush the log message
         {
            if ( log.isTraceEnabled() )
            {
  -            log.trace("disinjecting dependencies of: " + component.getName());
  +            log.trace("disinjecting dependencies of: " + getComponent().getName());
            }
  -         component.disinject( invocation.getTarget() );
  +         getComponent().disinject( invocation.getTarget() );
         }
         
         //method parameter injection?
  
  
  
  1.49      +3 -3      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.48
  retrieving revision 1.49
  diff -u -b -r1.48 -r1.49
  --- ConversationInterceptor.java	2 Oct 2006 04:17:59 -0000	1.48
  +++ ConversationInterceptor.java	10 Oct 2006 06:43:16 -0000	1.49
  @@ -1,4 +1,4 @@
  -//$Id: ConversationInterceptor.java,v 1.48 2006/10/02 04:17:59 gavin Exp $
  +//$Id: ConversationInterceptor.java,v 1.49 2006/10/10 06:43:16 gavin Exp $
   package org.jboss.seam.interceptors;
   
   import java.lang.reflect.Method;
  @@ -192,13 +192,13 @@
         if ( !Manager.instance().isLongRunningConversation() )
         {
            log.debug("Beginning long-running conversation");
  -         Manager.instance().beginConversation( component.getName() );
  +         Manager.instance().beginConversation( getComponent().getName() );
            beginNavigation(pageflowName);
         }
         else if (nested)
         {
            log.debug("Beginning nested conversation");
  -         Manager.instance().beginNestedConversation( component.getName() );
  +         Manager.instance().beginNestedConversation( getComponent().getName() );
            beginNavigation(pageflowName);
         }
      }
  
  
  
  1.6       +7 -7      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.5
  retrieving revision 1.6
  diff -u -b -r1.5 -r1.6
  --- ConversationalInterceptor.java	2 Oct 2006 04:17:59 -0000	1.5
  +++ ConversationalInterceptor.java	10 Oct 2006 06:43:16 -0000	1.6
  @@ -1,4 +1,4 @@
  -//$Id: ConversationalInterceptor.java,v 1.5 2006/10/02 04:17:59 gavin Exp $
  +//$Id: ConversationalInterceptor.java,v 1.6 2006/10/10 06:43:16 gavin Exp $
   package org.jboss.seam.interceptors;
   
   import java.lang.reflect.Method;
  @@ -43,11 +43,11 @@
         {
            String outcome = methodIsConversational(method) ? 
                  method.getAnnotation(Conversational.class).ifNotBegunOutcome() :
  -               component.getBeanClass().getAnnotation(Conversational.class).ifNotBegunOutcome();
  +               getComponent().getBeanClass().getAnnotation(Conversational.class).ifNotBegunOutcome();
            
            if ( "".equals(outcome) )
            {
  -            throw new IllegalStateException( "no long-running conversation for @Conversational bean: " + component.getName() );
  +            throw new IllegalStateException( "no long-running conversation for @Conversational bean: " + getComponent().getName() );
            }
            else
            {
  @@ -57,7 +57,7 @@
                  
                  if ( log.isDebugEnabled() )
                  {
  -                  log.debug( "no long-running conversation for @Conversational bean: " + component.getName() );
  +                  log.debug( "no long-running conversation for @Conversational bean: " + getComponent().getName() );
                  }
                  FacesMessages.instance().addFromResourceBundle( 
                        FacesMessage.SEVERITY_WARN, 
  @@ -110,16 +110,16 @@
      }
   
      private boolean componentIsConversational() {
  -      return component.getBeanClass().isAnnotationPresent(Conversational.class);
  +      return getComponent().getBeanClass().isAnnotationPresent(Conversational.class);
      }
   
      private boolean componentShouldBeInitiator() {
  -      return component.getBeanClass().getAnnotation(Conversational.class).initiator();
  +      return getComponent().getBeanClass().getAnnotation(Conversational.class).initiator();
      }
   
      private boolean componentIsInitiator()
      {
  -      return component.getName().equals( Manager.instance().getCurrentConversationInitiator() );
  +      return getComponent().getName().equals( Manager.instance().getCurrentConversationInitiator() );
      }
   
   }
  
  
  
  1.15      +4 -4      jboss-seam/src/main/org/jboss/seam/interceptors/RemoveInterceptor.java
  
  (In the diff below, changes in quantity of whitespace are not shown.)
  
  Index: RemoveInterceptor.java
  ===================================================================
  RCS file: /cvsroot/jboss/jboss-seam/src/main/org/jboss/seam/interceptors/RemoveInterceptor.java,v
  retrieving revision 1.14
  retrieving revision 1.15
  diff -u -b -r1.14 -r1.15
  --- RemoveInterceptor.java	2 Oct 2006 04:17:59 -0000	1.14
  +++ RemoveInterceptor.java	10 Oct 2006 06:43:16 -0000	1.15
  @@ -1,4 +1,4 @@
  -//$Id: RemoveInterceptor.java,v 1.14 2006/10/02 04:17:59 gavin Exp $
  +//$Id: RemoveInterceptor.java,v 1.15 2006/10/10 06:43:16 gavin Exp $
   package org.jboss.seam.interceptors;
   
   import java.lang.reflect.Method;
  @@ -55,7 +55,7 @@
            if ( !exception.getClass().isAnnotationPresent(ApplicationException.class) ) 
            {
               //it is a "system exception"
  -            if ( component.getType()==ComponentType.STATEFUL_SESSION_BEAN )
  +            if ( getComponent().getType()==ComponentType.STATEFUL_SESSION_BEAN )
               {
                  remove();
               }
  @@ -81,8 +81,8 @@
      private void remove() {
         //TODO: account for roles, by checking which role the component
         //      is actually bound to (need getInvokedBusinessObject())
  -      component.getScope().getContext().remove( component.getName() );
  -      log.debug("Stateful component was removed: " + component.getName());
  +      getComponent().getScope().getContext().remove( getComponent().getName() );
  +      log.debug("Stateful component was removed: " + getComponent().getName());
      }
   
   }
  
  
  
  1.10      +3 -3      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.9
  retrieving revision 1.10
  diff -u -b -r1.9 -r1.10
  --- RollbackInterceptor.java	2 Oct 2006 04:17:59 -0000	1.9
  +++ RollbackInterceptor.java	10 Oct 2006 06:43:16 -0000	1.10
  @@ -1,4 +1,4 @@
  -//$Id: RollbackInterceptor.java,v 1.9 2006/10/02 04:17:59 gavin Exp $
  +//$Id: RollbackInterceptor.java,v 1.10 2006/10/10 06:43:16 gavin Exp $
   package org.jboss.seam.interceptors;
   
   import java.util.Arrays;
  @@ -37,7 +37,7 @@
                     outcomeList.contains(result);
               if ( isRollback )
               {
  -               if ( component.getType()==ComponentType.JAVA_BEAN )
  +               if ( getComponent().getType()==ComponentType.JAVA_BEAN )
                  {
                     //For JavaBeans, we assume the UT is accessible
                     Transactions.setUserTransactionRollbackOnly();
  @@ -56,7 +56,7 @@
         {
            //Any exception that propagates out of a JavaBean component
            //causes a transaction rollback
  -         if ( component.getType()==ComponentType.JAVA_BEAN )
  +         if ( getComponent().getType()==ComponentType.JAVA_BEAN )
            {
               try
               {
  
  
  
  1.7       +1 -1      jboss-seam/src/main/org/jboss/seam/interceptors/TransactionInterceptor.java
  
  (In the diff below, changes in quantity of whitespace are not shown.)
  
  Index: TransactionInterceptor.java
  ===================================================================
  RCS file: /cvsroot/jboss/jboss-seam/src/main/org/jboss/seam/interceptors/TransactionInterceptor.java,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -b -r1.6 -r1.7
  --- TransactionInterceptor.java	2 Oct 2006 04:17:59 -0000	1.6
  +++ TransactionInterceptor.java	10 Oct 2006 06:43:16 -0000	1.7
  @@ -21,7 +21,7 @@
      @AroundInvoke
      public Object doInTransactionIfNecessary(InvocationContext invocation) throws Exception
      {
  -      boolean begin = ( isTransactional( invocation.getMethod() ) || isTransactional( component.getBeanClass() ) ) &&
  +      boolean begin = ( isTransactional( invocation.getMethod() ) || isTransactional( getComponent().getBeanClass() ) ) &&
               !Transactions.isTransactionActiveOrMarkedRollback();
         UserTransaction userTransaction = begin ? Transactions.getUserTransaction() : null;
   
  
  
  
  1.21      +3 -3      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.20
  retrieving revision 1.21
  diff -u -b -r1.20 -r1.21
  --- ValidationInterceptor.java	2 Oct 2006 04:17:59 -0000	1.20
  +++ ValidationInterceptor.java	10 Oct 2006 06:43:16 -0000	1.21
  @@ -1,4 +1,4 @@
  -//$Id: ValidationInterceptor.java,v 1.20 2006/10/02 04:17:59 gavin Exp $
  +//$Id: ValidationInterceptor.java,v 1.21 2006/10/10 06:43:16 gavin Exp $
   package org.jboss.seam.interceptors;
   
   import java.lang.reflect.Method;
  @@ -39,7 +39,7 @@
         if ( method.isAnnotationPresent(IfInvalid.class) )
         {
            IfInvalid ifInvalid = method.getAnnotation(IfInvalid.class);
  -         InvalidValue[] invalidValues = component.getValidator()
  +         InvalidValue[] invalidValues = getComponent().getValidator()
                  .getInvalidValues( invocation.getTarget() );
            if (invalidValues.length==0)
            {
  @@ -47,7 +47,7 @@
            }
            else
            {
  -            log.debug("invalid component state: " + component.getName());
  +            log.debug("invalid component state: " + getComponent().getName());
               for (InvalidValue iv : invalidValues)
               {
                  log.debug("invalid value: " + iv);
  
  
  



More information about the jboss-cvs-commits mailing list