gdamour     2005/12/21 09:21:49

  Modified:    modules/core/src/java/org/openejb
                        AbstractInterceptorBuilder.java
                        GenericEJBContainer.java
                        InstanceContextFactory.java InterceptorBuilder.java
  Log:

  GERONIMO-1397 Clustering of SFSB
  
  First step of many others to add the clustering of SFSB.
  
  This check-in adds the following features:
  * definition of an EJBClusterManager, which abstracts an EJB Cluster node;
  * this EJB cluster node is a standard GBean (the default or
  WADI implementation is DefaultEJBClusterManager);
  * in an openejb-jar.xml DD, a SFSB can declare a reference to this node via
  the ejb-cluster-reference element;
  * when the SFSB container is started, the EJB cluster node notifies
  the cluster that it is running a specific SFSB container;
  * when a clustered SFSB InstanceContext is created, an array of nodes running
  the container of this SFSB is associated to the InstanceContext. Note that
  this array of nodes is updated upon start-up of a clustered SFSB container or
  upon node failure;
  * this array of nodes capable of running the created SFSB is propagated to
  clients. Actually, this array is propagated at each EJB invocation.
  
  Revision  Changes    Path
  1.13      +5 -1      
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.12
  retrieving revision 1.13
  diff -u -r1.12 -r1.13
  --- AbstractInterceptorBuilder.java   18 Apr 2005 19:04:58 -0000      1.12
  +++ AbstractInterceptorBuilder.java   21 Dec 2005 14:21:49 -0000      1.13
  @@ -81,6 +81,7 @@
       protected transient InstancePool instancePool;
       protected InstanceCache instanceCache;
       protected InstanceFactory instanceFactory;
  +    protected boolean clustered;
   
       public void setContainerId(Object containerID) {
           assert (containerID != null) : "containerID is null!";
  @@ -152,4 +153,7 @@
           this.instanceFactory = instanceFactory;
       }
   
  +    public void setClustered(boolean clustered) {
  +        this.clustered = clustered;
  +    }
   }
  
  
  
  1.59      +48 -8     
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.58
  retrieving revision 1.59
  diff -u -r1.58 -r1.59
  --- GenericEJBContainer.java  4 Dec 2005 02:37:52 -0000       1.58
  +++ GenericEJBContainer.java  21 Dec 2005 14:21:49 -0000      1.59
  @@ -52,6 +52,7 @@
   import java.rmi.RemoteException;
   import java.util.Iterator;
   import java.util.Map;
  +
   import javax.ejb.EJBHome;
   import javax.ejb.EJBLocalHome;
   import javax.ejb.EJBLocalObject;
  @@ -72,9 +73,10 @@
   import org.apache.geronimo.gbean.GBeanLifecycle;
   import org.apache.geronimo.j2ee.j2eeobjectnames.NameFactory;
   import org.apache.geronimo.kernel.Kernel;
  +import org.apache.geronimo.management.J2EEManagedObject;
  +import org.apache.geronimo.naming.enc.EnterpriseNamingContext;
   import org.apache.geronimo.naming.reference.ClassLoaderAwareReference;
   import org.apache.geronimo.naming.reference.KernelAwareReference;
  -import org.apache.geronimo.naming.enc.EnterpriseNamingContext;
   import org.apache.geronimo.security.ContextManager;
   import org.apache.geronimo.security.deploy.DefaultPrincipal;
   import org.apache.geronimo.security.util.ConfigurationUtil;
  @@ -82,17 +84,21 @@
   import org.apache.geronimo.transaction.TrackedConnectionAssociator;
   import org.apache.geronimo.transaction.context.TransactionContextManager;
   import org.apache.geronimo.transaction.context.UserTransactionImpl;
  -import org.apache.geronimo.management.J2EEManagedObject;
  -
  +import org.openejb.cache.InstanceCache;
   import org.openejb.cache.InstancePool;
   import org.openejb.client.EJBObjectHandler;
   import org.openejb.client.EJBObjectProxy;
  +import org.openejb.cluster.server.ClusteredEJBContainer;
  +import org.openejb.cluster.server.ClusteredInstanceCache;
  +import org.openejb.cluster.server.ClusteredInstanceContextFactory;
  +import org.openejb.cluster.server.DefaultClusteredEJBContainer;
  +import org.openejb.cluster.server.EJBClusterManager;
  +import org.openejb.corba.TSSBean;
   import org.openejb.dispatch.InterfaceMethodSignature;
   import org.openejb.dispatch.SystemMethodIndices;
   import org.openejb.proxy.EJBProxyFactory;
   import org.openejb.proxy.ProxyInfo;
   import org.openejb.timer.BasicTimerServiceImpl;
  -import org.openejb.corba.TSSBean;
   
   
   /**
  @@ -119,6 +125,9 @@
       private final Subject runAsSubject;
       private final BasicTimerServiceImpl timerService;
   
  +    private final EJBClusterManager clusterManager;
  +    private final ClusteredEJBContainer clusteredEJBContainer;
  +    
       //corba security configuration
       private final TSSBean tssBean;
       //corba tx import policies
  @@ -130,6 +139,7 @@
                                  String ejbName,
                                  ProxyInfo proxyInfo,
                                  InterfaceMethodSignature[] signatures,
  +                               InstanceCache instanceCache,
                                  InstanceContextFactory contextFactory,
                                  InterceptorBuilder interceptorBuilder,
                                  InstancePool pool,
  @@ -146,7 +156,8 @@
                                  Subject runAsSubject,
                                  TSSBean tssBean, Serializable 
homeTxPolicyConfig,
                                  Serializable remoteTxPolicyConfig,
  -                               ClassLoader classLoader) throws Exception {
  +                               ClassLoader classLoader,
  +                               EJBClusterManager clusterManager) throws 
Exception {
   
           assert (containerId != null);
           assert (ejbName != null && ejbName.length() > 0);
  @@ -171,6 +182,8 @@
           this.proxyInfo = proxyInfo;
           this.proxyFactory = new EJBProxyFactory(this);
   
  +        this.clusterManager = clusterManager;
  +        
           // create ReadOnlyContext
           Context enc = null;
           if (componentContext != null) {
  @@ -212,6 +225,21 @@
               timerService = null;
           }
   
  +        if (null != clusterManager) {
  +            if (false == instanceCache instanceof ClusteredInstanceCache) {
  +                throw new IllegalArgumentException("instanceCache MUST be a" 
+
  +                        " ClusteredInstanceCache instance.");
  +            } else if (false == contextFactory instanceof 
ClusteredInstanceContextFactory) {
  +                throw new IllegalArgumentException("contextFactory MUST be 
a" +
  +                    " ClusteredInstanceContextFactory instance.");
  +            }
  +            clusteredEJBContainer = new DefaultClusteredEJBContainer(this,
  +                    (ClusteredInstanceCache) instanceCache,
  +                    (ClusteredInstanceContextFactory) contextFactory);
  +        } else {
  +            clusteredEJBContainer = null;
  +        }
  +        
           // initialize the user transaction
           if (userTransaction != null) {
               userTransaction.setUp(transactionContextManager, 
trackedConnectionAssociator);
  @@ -399,11 +427,18 @@
           if (tssBean != null) {
               tssBean.registerContainer(this);
           }
  -
  +        //TODO we are giving out a direct reference, not a proxy
  +        if (null != clusterManager) {
  +            clusterManager.addEJBContainer(clusteredEJBContainer);
  +        }
  +        
           log.debug("GenericEJBContainer '" + containerId + "' started");
       }
   
       public void doStop() throws Exception {
  +        if (null != clusterManager) {
  +            clusterManager.removeEJBContainer(clusteredEJBContainer);
  +        }
           if (tssBean != null) {
               tssBean.unregisterContainer(this);
           }
  @@ -453,6 +488,7 @@
           infoFactory.addAttribute("ejbName", String.class, true);
           infoFactory.addAttribute("proxyInfo", ProxyInfo.class, true);
           infoFactory.addAttribute("signatures", 
InterfaceMethodSignature[].class, true);
  +        infoFactory.addAttribute("instanceCache", InstanceCache.class, true);
           infoFactory.addAttribute("contextFactory", 
InstanceContextFactory.class, true);
           infoFactory.addAttribute("interceptorBuilder", 
InterceptorBuilder.class, true);
           infoFactory.addAttribute("pool", InstancePool.class, true);
  @@ -472,6 +508,8 @@
   
           infoFactory.addReference("TSSBean", TSSBean.class);
   
  +        infoFactory.addReference("EJBClusterManager", 
EJBClusterManager.class);
  +
           infoFactory.addAttribute("objectName", String.class, false);
           infoFactory.addInterface(J2EEManagedObject.class);
           infoFactory.addAttribute("kernel", Kernel.class, false);
  @@ -498,6 +536,7 @@
               "ejbName",
               "proxyInfo",
               "signatures",
  +            "instanceCache",
               "contextFactory",
               "interceptorBuilder",
               "pool",
  @@ -515,7 +554,8 @@
               "TSSBean",
               "homeTxPolicyConfig",
               "remoteTxPolicyConfig",
  -            "classLoader"});
  +            "classLoader",
  +            "EJBClusterManager"});
   
           GBEAN_INFO = infoFactory.getBeanInfo();
       }
  
  
  
  1.8       +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.7
  retrieving revision 1.8
  diff -u -r1.7 -r1.8
  --- InstanceContextFactory.java       5 Oct 2004 07:04:00 -0000       1.7
  +++ InstanceContextFactory.java       21 Dec 2005 14:21:49 -0000      1.8
  @@ -51,9 +51,9 @@
   import org.apache.geronimo.transaction.context.TransactionContextManager;
   import org.apache.geronimo.core.service.Interceptor;
   
  -import org.openejb.proxy.EJBProxyFactory;
   import org.openejb.dispatch.InterfaceMethodSignature;
   import org.openejb.dispatch.SystemMethodIndices;
  +import org.openejb.proxy.EJBProxyFactory;
   import org.openejb.timer.BasicTimerService;
   
   
  
  
  
  1.12      +3 -1      
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.11
  retrieving revision 1.12
  diff -u -r1.11 -r1.12
  --- InterceptorBuilder.java   18 Apr 2005 19:04:58 -0000      1.11
  +++ InterceptorBuilder.java   21 Dec 2005 14:21:49 -0000      1.12
  @@ -68,4 +68,6 @@
       TwoChains buildInterceptorChains();
   
       void setContainerId(Object containerID);
  +    
  +    void setClustered(boolean clustered);
   }
  
  
  

Reply via email to