djencks     2004/07/07 18:17:32

  Modified:    modules/core/src/java/org/openejb
                        AbstractInstanceContext.java
                        AbstractInterceptorBuilder.java
                        EJBInvocationImpl.java GenericEJBContainer.java
                        InstanceContextFactory.java InterceptorBuilder.java
  Added:       modules/core/src/java/org/openejb TwoChains.java
  Log:

  A lot more work to route system lifecycle calls through a partial interceptor stack 
(OPENEJB-5).  All that is left is ejbCreate methods when called by the container (slsb 
and mdb)
  
  Revision  Changes    Path
  1.3       +31 -3     
openejb/modules/core/src/java/org/openejb/AbstractInstanceContext.java
  
  Index: AbstractInstanceContext.java
  ===================================================================
  RCS file: 
/home/projects/openejb/scm/openejb/modules/core/src/java/org/openejb/AbstractInstanceContext.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- AbstractInstanceContext.java      31 May 2004 23:48:23 -0000      1.2
  +++ AbstractInstanceContext.java      7 Jul 2004 22:17:32 -0000       1.3
  @@ -24,6 +24,8 @@
   import javax.ejb.EnterpriseBean;
   
   import org.openejb.proxy.EJBProxyFactory;
  +import org.openejb.dispatch.SystemMethodIndices;
  +import org.apache.geronimo.core.service.Interceptor;
   
   
   /**
  @@ -37,15 +39,25 @@
       private final Map connectionManagerMap = new HashMap();
       private final Set unshareableResources;
       private final Set applicationManagedSecurityResources;
  -    //this sucks, but the CMP instance is not available until after the superclass 
constructor executes.
  +    //this not being final sucks, but the CMP instance is not available until after 
the superclass constructor executes.
       protected EnterpriseBean instance;
       private final EJBProxyFactory proxyFactory;
  +    private final EJBInvocation ejbActivateInvocation;
  +    private final EJBInvocation ejbPassivateInvocation;
  +    //initialized in subclass, can't be final :-((
  +    protected EJBInvocation setContextInvocation;
  +    protected EJBInvocation unsetContextInvocation;
  +    protected final Interceptor systemChain;
   
  -    public AbstractInstanceContext(Set unshareableResources, Set 
applicationManagedSecurityResources, EnterpriseBean instance, EJBProxyFactory 
proxyFactory) {
  +
  +    public AbstractInstanceContext(SystemMethodIndices systemMethodIndices, 
Interceptor systemChain, Set unshareableResources, Set 
applicationManagedSecurityResources, EnterpriseBean instance, EJBProxyFactory 
proxyFactory) {
           this.unshareableResources = unshareableResources;
           this.applicationManagedSecurityResources = 
applicationManagedSecurityResources;
           this.instance = instance;
           this.proxyFactory = proxyFactory;
  +        this.systemChain = systemChain;
  +        ejbActivateInvocation = systemMethodIndices.getEjbActivateInvocation(this);
  +        ejbPassivateInvocation = 
systemMethodIndices.getEjbPassivateInvocation(this);
       }
   
       public Object getId() {
  @@ -89,6 +101,22 @@
   
       public EJBProxyFactory getProxyFactory() {
           return proxyFactory;
  +    }
  +
  +    public void ejbActivate() throws Throwable {
  +        systemChain.invoke(ejbActivateInvocation);
  +    }
  +
  +    public void ejbPassivate() throws Throwable {
  +        systemChain.invoke(ejbPassivateInvocation);
  +    }
  +
  +    public void setContext() throws Throwable {
  +        systemChain.invoke(setContextInvocation);
  +    }
  +
  +    public void unsetContext() throws Throwable {
  +        systemChain.invoke(unsetContextInvocation);
       }
   
   }
  
  
  
  1.7       +1 -4      
openejb/modules/core/src/java/org/openejb/AbstractInterceptorBuilder.java
  
  Index: AbstractInterceptorBuilder.java
  ===================================================================
  RCS file: 
/home/projects/openejb/scm/openejb/modules/core/src/java/org/openejb/AbstractInterceptorBuilder.java,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- AbstractInterceptorBuilder.java   31 May 2004 23:48:23 -0000      1.6
  +++ AbstractInterceptorBuilder.java   7 Jul 2004 22:17:32 -0000       1.7
  @@ -144,7 +144,4 @@
           this.instanceFactory = instanceFactory;
       }
   
  -    public Interceptor getLifecycleInterceptorChain() {
  -        return null;
  -    }
   }
  
  
  
  1.2       +9 -1      openejb/modules/core/src/java/org/openejb/EJBInvocationImpl.java
  
  Index: EJBInvocationImpl.java
  ===================================================================
  RCS file: 
/home/projects/openejb/scm/openejb/modules/core/src/java/org/openejb/EJBInvocationImpl.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- EJBInvocationImpl.java    1 Mar 2004 07:14:42 -0000       1.1
  +++ EJBInvocationImpl.java    7 Jul 2004 22:17:32 -0000       1.2
  @@ -93,6 +93,14 @@
           this.id = id;
       }
   
  +    public EJBInvocationImpl(int index, Object[] arguments, EJBInstanceContext 
instanceContext) {
  +        this.type = EJBInterfaceType.LIFECYCLE;
  +        this.index = index;
  +        this.arguments = arguments;
  +        this.id = null;
  +        this.instanceContext = instanceContext;
  +    }
  +
       public int getMethodIndex() {
           return index;
       }
  
  
  
  1.13      +5 -4      
openejb/modules/core/src/java/org/openejb/GenericEJBContainer.java
  
  Index: GenericEJBContainer.java
  ===================================================================
  RCS file: 
/home/projects/openejb/scm/openejb/modules/core/src/java/org/openejb/GenericEJBContainer.java,v
  retrieving revision 1.12
  retrieving revision 1.13
  diff -u -r1.12 -r1.13
  --- GenericEJBContainer.java  2 Jun 2004 05:33:40 -0000       1.12
  +++ GenericEJBContainer.java  7 Jul 2004 22:17:32 -0000       1.13
  @@ -131,9 +131,10 @@
           interceptorBuilder.setTransactionManager(transactionManager);
           
interceptorBuilder.setTrackedConnectionAssociator(trackedConnectionAssociator);
           interceptorBuilder.setInstancePool(pool);
  -        interceptor = interceptorBuilder.buildInterceptorChain();
  +        TwoChains chains = interceptorBuilder.buildInterceptorChains();
  +        interceptor = chains.getUserChain();
   
  -        
contextFactory.setLifecycleInterceptorChain(interceptorBuilder.getLifecycleInterceptorChain());
  +        contextFactory.setSystemChain(chains.getSystemChain());
   
           // initialize the user transaction
           if (userTransaction != null) {
  @@ -174,7 +175,7 @@
               }
           }
   
  -        EJBInvocationImpl invocation = new EJBInvocationImpl(invocationType, 
primKey, index, args);
  +        EJBInvocation invocation = new EJBInvocationImpl(invocationType, primKey, 
index, args);
   
           InvocationResult result = null;
           try {
  
  
  
  1.4       +2 -2      
openejb/modules/core/src/java/org/openejb/InstanceContextFactory.java
  
  Index: InstanceContextFactory.java
  ===================================================================
  RCS file: 
/home/projects/openejb/scm/openejb/modules/core/src/java/org/openejb/InstanceContextFactory.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- InstanceContextFactory.java       31 May 2004 23:48:23 -0000      1.3
  +++ InstanceContextFactory.java       7 Jul 2004 22:17:32 -0000       1.4
  @@ -64,7 +64,7 @@
   
       void setProxyFactory(EJBProxyFactory proxyFactory);
   
  -    void setLifecycleInterceptorChain(Interceptor lifecycleInterceptorChain);
  +    void setSystemChain(Interceptor lifecycleInterceptorChain);
   
       void setSignatures(InterfaceMethodSignature[] signatures);
   }
  
  
  
  1.6       +2 -3      
openejb/modules/core/src/java/org/openejb/InterceptorBuilder.java
  
  Index: InterceptorBuilder.java
  ===================================================================
  RCS file: 
/home/projects/openejb/scm/openejb/modules/core/src/java/org/openejb/InterceptorBuilder.java,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- InterceptorBuilder.java   31 May 2004 23:48:23 -0000      1.5
  +++ InterceptorBuilder.java   7 Jul 2004 22:17:32 -0000       1.6
  @@ -67,7 +67,6 @@
   
       void setInstanceFactory(InstanceFactory instanceFactory);
   
  -    Interceptor buildInterceptorChain();
  +    TwoChains buildInterceptorChains();
   
  -    Interceptor getLifecycleInterceptorChain();
   }
  
  
  
  1.1                  openejb/modules/core/src/java/org/openejb/TwoChains.java
  
  Index: TwoChains.java
  ===================================================================
  /* ====================================================================
   * Redistribution and use of this software and associated documentation
   * ("Software"), with or without modification, are permitted provided
   * that the following conditions are met:
   *
   * 1. Redistributions of source code must retain copyright
   *    statements and notices.  Redistributions must also contain a
   *    copy of this document.
   *
   * 2. Redistributions in binary form must reproduce this list of
   *    conditions and the following disclaimer in the documentation
   *    and/or other materials provided with the distribution.
   *
   * 3. The name "OpenEJB" must not be used to endorse or promote
   *    products derived from this Software without prior written
   *    permission of The OpenEJB Group.  For written permission,
   *    please contact [EMAIL PROTECTED]
   *
   * 4. Products derived from this Software may not be called "OpenEJB"
   *    nor may "OpenEJB" appear in their names without prior written
   *    permission of The OpenEJB Group. OpenEJB is a registered
   *    trademark of The OpenEJB Group.
   *
   * 5. Due credit should be given to the OpenEJB Project
   *    (http://openejb.org/).
   *
   * THIS SOFTWARE IS PROVIDED BY THE OPENEJB GROUP AND CONTRIBUTORS
   * ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT
   * NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
   * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL
   * THE OPENEJB GROUP OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
   * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
   * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
   * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
   * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
   * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
   * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
   * OF THE POSSIBILITY OF SUCH DAMAGE.
   *
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the OpenEJB Project.  For more information
   * please see <http://openejb.org/>.
   *
   * ====================================================================
   */
  package org.openejb;
  
  import org.apache.geronimo.core.service.Interceptor;
  
  /**
   *
   *
   * @version $Revision: 1.1 $ $Date: 2004/07/07 22:17:32 $
   *
   * */
  public class TwoChains {
  
      private final Interceptor userChain;
      private final Interceptor systemChain;
  
      public TwoChains(Interceptor userChain, Interceptor systemChain) {
          this.userChain = userChain;
          this.systemChain = systemChain;
      }
  
      public Interceptor getUserChain() {
          return userChain;
      }
  
      public Interceptor getSystemChain() {
          return systemChain;
      }
  }
  
  
  

Reply via email to