djencks     2004/07/07 18:17:33

  Modified:    modules/core/src/java/org/openejb/entity/bmp
                        BMPContainerBuilder.java BMPInstanceContext.java
                        BMPInstanceContextFactory.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.8       +32 -12    
openejb/modules/core/src/java/org/openejb/entity/bmp/BMPContainerBuilder.java
  
  Index: BMPContainerBuilder.java
  ===================================================================
  RCS file: 
/home/projects/openejb/scm/openejb/modules/core/src/java/org/openejb/entity/bmp/BMPContainerBuilder.java,v
  retrieving revision 1.7
  retrieving revision 1.8
  diff -u -r1.7 -r1.8
  --- BMPContainerBuilder.java  3 Jun 2004 07:27:01 -0000       1.7
  +++ BMPContainerBuilder.java  7 Jul 2004 22:17:33 -0000       1.8
  @@ -63,7 +63,12 @@
   import org.openejb.entity.EntityInstanceFactory;
   import org.openejb.entity.EntityInterceptorBuilder;
   import org.openejb.entity.HomeMethod;
  -import org.openejb.entity.EJBLoadOperation;
  +import org.openejb.entity.dispatch.EJBActivateOperation;
  +import org.openejb.entity.dispatch.EJBLoadOperation;
  +import org.openejb.entity.dispatch.EJBPassivateOperation;
  +import org.openejb.entity.dispatch.EJBStoreOperation;
  +import org.openejb.entity.dispatch.SetEntityContextOperation;
  +import org.openejb.entity.dispatch.UnsetEntityContextOperation;
   
   /**
    *
  @@ -90,7 +95,7 @@
   
           // build the context factory
           InstanceContextFactory contextFactory = new 
BMPInstanceContextFactory(getContainerId(), beanClass, getUnshareableResources(), 
getApplicationManagedSecurityResources());
  -        EntityInstanceFactory instanceFactory = new 
EntityInstanceFactory(getComponentContext(), contextFactory);
  +        EntityInstanceFactory instanceFactory = new 
EntityInstanceFactory(contextFactory);
   
           // build the pool
           InstancePool pool = createInstancePool(instanceFactory);
  @@ -102,7 +107,7 @@
           }
       }
   
  -    protected LinkedHashMap buildVopMap(final Class beanClass) throws Exception{
  +   protected LinkedHashMap buildVopMap(final Class beanClass) throws Exception{
           LinkedHashMap vopMap = new LinkedHashMap();
   
           // get the context set unset method objects
  @@ -125,12 +130,6 @@
               if (Object.class == beanMethod.getDeclaringClass()) {
                   continue;
               }
  -            if (setEntityContext.equals(beanMethod)) {
  -                continue;
  -            }
  -            if (unsetEntityContext.equals(beanMethod)) {
  -                continue;
  -            }
   
               // create a VirtualOperation for the method (if the method is 
understood)
               String name = beanMethod.getName();
  @@ -170,11 +169,32 @@
                   vopMap.put(
                           MethodHelper.translateToInterface(signature),
                           new BMPFinderMethod(beanClass, signature));
  -            } else if (name.equals("ejbLoad") || name.equals("ejbStore")) {
  +            } else if (name.equals("ejbActivate")) {
  +                vopMap.put(
  +                        MethodHelper.translateToInterface(signature)
  +                        , EJBActivateOperation.INSTANCE);
  +            } else if (name.equals("ejbLoad")) {
  +                vopMap.put(
  +                        MethodHelper.translateToInterface(signature)
  +                        , EJBLoadOperation.INSTANCE);
  +            } else if (name.equals("ejbPassivate")) {
  +                vopMap.put(
  +                        MethodHelper.translateToInterface(signature)
  +                        , EJBPassivateOperation.INSTANCE);
  +            } else if (name.equals("ejbStore")) {
  +                vopMap.put(
  +                        MethodHelper.translateToInterface(signature)
  +                        , EJBStoreOperation.INSTANCE);
  +            } else if (setEntityContext.equals(beanMethod)) {
  +                vopMap.put(
  +                        MethodHelper.translateToInterface(signature)
  +                        , SetEntityContextOperation.INSTANCE);
  +            } else if (unsetEntityContext.equals(beanMethod)) {
                   vopMap.put(
                           MethodHelper.translateToInterface(signature)
  -                        , new EJBLoadOperation(beanClass, signature));
  +                        , UnsetEntityContextOperation.INSTANCE);
               } else if (name.startsWith("ejb")) {
  +                //TODO this shouldn't happen?
                   continue;
               } else {
                   vopMap.put(
  
  
  
  1.5       +4 -3      
openejb/modules/core/src/java/org/openejb/entity/bmp/BMPInstanceContext.java
  
  Index: BMPInstanceContext.java
  ===================================================================
  RCS file: 
/home/projects/openejb/scm/openejb/modules/core/src/java/org/openejb/entity/bmp/BMPInstanceContext.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- BMPInstanceContext.java   31 May 2004 23:48:23 -0000      1.4
  +++ BMPInstanceContext.java   7 Jul 2004 22:17:33 -0000       1.5
  @@ -54,6 +54,7 @@
   import org.apache.geronimo.core.service.Interceptor;
   import org.openejb.entity.EntityInstanceContext;
   import org.openejb.proxy.EJBProxyFactory;
  +import org.openejb.dispatch.SystemMethodIndices;
   
   /**
    *
  @@ -62,8 +63,8 @@
    */
   public final class BMPInstanceContext extends EntityInstanceContext {
   
  -    public BMPInstanceContext(Object containerId, EJBProxyFactory proxyFactory, 
EntityBean instance, Interceptor lifecycleInterceptorChain, int loadIndex, int 
storeIndex, Set unshareableResources, Set applicationManagedSecurityResources) throws 
Exception {
  -        super(containerId, proxyFactory, instance, lifecycleInterceptorChain, 
loadIndex, storeIndex, unshareableResources, applicationManagedSecurityResources);
  +    public BMPInstanceContext(Object containerId, EJBProxyFactory proxyFactory, 
EntityBean instance, Interceptor lifecycleInterceptorChain, SystemMethodIndices 
systemMethodIndices, Set unshareableResources, Set 
applicationManagedSecurityResources) throws Exception {
  +        super(containerId, proxyFactory, instance, lifecycleInterceptorChain, 
systemMethodIndices, unshareableResources, applicationManagedSecurityResources);
       }
   
   }
  
  
  
  1.7       +9 -16     
openejb/modules/core/src/java/org/openejb/entity/bmp/BMPInstanceContextFactory.java
  
  Index: BMPInstanceContextFactory.java
  ===================================================================
  RCS file: 
/home/projects/openejb/scm/openejb/modules/core/src/java/org/openejb/entity/bmp/BMPInstanceContextFactory.java,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- BMPInstanceContextFactory.java    31 May 2004 23:48:23 -0000      1.6
  +++ BMPInstanceContextFactory.java    7 Jul 2004 22:17:33 -0000       1.7
  @@ -51,6 +51,7 @@
   import java.util.Set;
   
   import javax.ejb.EntityBean;
  +import javax.ejb.EntityContext;
   
   import org.apache.geronimo.core.service.Interceptor;
   import org.apache.geronimo.transaction.InstanceContext;
  @@ -58,6 +59,7 @@
   import org.openejb.EJBInstanceFactoryImpl;
   import org.openejb.InstanceContextFactory;
   import org.openejb.dispatch.InterfaceMethodSignature;
  +import org.openejb.dispatch.SystemMethodIndices;
   import org.openejb.proxy.EJBProxyFactory;
   
   /**
  @@ -71,9 +73,8 @@
       private final Set unshareableResources;
       private final Set applicationManagedSecurityResources;
       private transient EJBProxyFactory proxyFactory;
  -    private transient Interceptor lifecycleInterceptorChain;
  -    private transient int loadIndex = -1;
  -    private transient int storeIndex = -1;
  +    private transient Interceptor systemChain;
  +    private SystemMethodIndices systemMethodIndices;
   
       public BMPInstanceContextFactory(Object containerId, Class beanClass, Set 
unshareableResources, Set applicationManagedSecurityResources) {
           this.containerId = containerId;
  @@ -86,26 +87,18 @@
           this.proxyFactory = proxyFactory;
       }
   
  -    public void setLifecycleInterceptorChain(Interceptor lifecycleInterceptorChain) 
{
  -        this.lifecycleInterceptorChain = lifecycleInterceptorChain;
  +    public void setSystemChain(Interceptor systemChain) {
  +        this.systemChain = systemChain;
       }
   
       public void setSignatures(InterfaceMethodSignature[] signatures) {
  -        for (int i = 0; i < signatures.length; i++) {
  -            InterfaceMethodSignature signature = signatures[i];
  -            if (signature.getMethodName().equals("ejbLoad")) {
  -                loadIndex = i;
  -            } else if (signature.getMethodName().equals("ejbStore")) {
  -
  -                storeIndex = i;
  -            }
  -        }
  +        systemMethodIndices = 
SystemMethodIndices.createSystemMethodIndices(signatures, "setEntityContext", 
EntityContext.class.getName(), "unsetEntityContext");
       }
   
       public InstanceContext newInstance() throws Exception {
           if (proxyFactory == null) {
               throw new IllegalStateException("ProxyFacory has not been set");
           }
  -        return new BMPInstanceContext(containerId, proxyFactory, (EntityBean) 
factory.newInstance(), lifecycleInterceptorChain, loadIndex, storeIndex, 
unshareableResources, applicationManagedSecurityResources);
  +        return new BMPInstanceContext(containerId, proxyFactory, (EntityBean) 
factory.newInstance(), systemChain, systemMethodIndices, unshareableResources, 
applicationManagedSecurityResources);
       }
   }
  
  
  

Reply via email to