gdamour     2005/12/21 09:21:55

  Modified:    modules/openejb-builder/src/java/org/openejb/deployment
                        AbstractContainerBuilder.java
                        BMPContainerBuilder.java CMPContainerBuilder.java
                        ContainerBuilder.java EntityBuilder.java
                        RemoteEJBReferenceBuilder.java SessionBuilder.java
                        StatefulContainerBuilder.java
                        StatelessContainerBuilder.java
  Added:       modules/openejb-builder/src/java/org/openejb/deployment
                        ClusteredSFContainerStrategy.java
                        DefaultBMPContainerStrategy.java
                        DefaultSFContainerStrategy.java
                        DefaultSLContainerStrategy.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.17      +46 -15    
openejb/modules/openejb-builder/src/java/org/openejb/deployment/AbstractContainerBuilder.java
  
  Index: AbstractContainerBuilder.java
  ===================================================================
  RCS file: 
/home/projects/openejb/scm/openejb/modules/openejb-builder/src/java/org/openejb/deployment/AbstractContainerBuilder.java,v
  retrieving revision 1.16
  retrieving revision 1.17
  diff -u -r1.16 -r1.17
  --- AbstractContainerBuilder.java     1 Oct 2005 08:44:09 -0000       1.16
  +++ AbstractContainerBuilder.java     21 Dec 2005 14:21:54 -0000      1.17
  @@ -51,6 +51,7 @@
   import java.util.Arrays;
   import java.util.Map;
   import java.util.Set;
  +
   import javax.ejb.TimedObject;
   import javax.ejb.Timer;
   import javax.management.ObjectName;
  @@ -67,6 +68,7 @@
   import org.openejb.GenericEJBContainer;
   import org.openejb.InstanceContextFactory;
   import org.openejb.InterceptorBuilder;
  +import org.openejb.cache.InstanceCache;
   import org.openejb.cache.InstanceFactory;
   import org.openejb.cache.InstancePool;
   import org.openejb.deployment.corba.TransactionImportPolicyBuilder;
  @@ -112,13 +114,14 @@
       //todo use object names here for build configuration rather than in 
ModuleBuilder.
       private TransactionContextManager transactionContextManager;
       private TrackedConnectionAssociator trackedConnectionAssociator;
  -
  +    
       private ObjectName transactedTimerName;
  +    protected ContainerStrategy containerStrategy;
       private ObjectName nonTransactedTimerName;
  -
  +    private ObjectName ejbClusterManagerName;
  +    
       //corba tx import
   
  -
       public ClassLoader getClassLoader() {
           return classLoader;
       }
  @@ -358,9 +361,12 @@
           if (tssBeanObjectName != null) {
               gbean.setReferencePattern("TSSBean", tssBeanObjectName);
           }
  +        if (null != ejbClusterManagerName) {
  +            gbean.setReferencePattern("EJBClusterManager", 
ejbClusterManagerName);
  +        }
           return gbean;
       }
  -
  +    
       protected abstract Object buildIt(boolean buildContainer) throws 
Exception;
   
       protected InterceptorBuilder 
initializeInterceptorBuilder(InterceptorBuilder interceptorBuilder, 
InterfaceMethodSignature[] signatures, VirtualOperation[] vtable) {
  @@ -374,6 +380,7 @@
           interceptorBuilder.setPolicyContextId(policycontextId);
           interceptorBuilder.setTransactionPolicyManager(new 
TransactionPolicyManager(buildTransactionPolicies(transactionPolicySource, 
signatures)));
           interceptorBuilder.setPermissionManager(new 
PermissionManager(ejbName, signatures));
  +        interceptorBuilder.setClustered(isClustered());
           return interceptorBuilder;
       }
   
  @@ -427,6 +434,22 @@
           }
       }
   
  +    public void setContainerStrategy(ContainerStrategy containerStrategy) {
  +        this.containerStrategy = containerStrategy;
  +    }
  +
  +    public ObjectName getEjbClusterManagerName() {
  +        return ejbClusterManagerName;
  +    }
  +    
  +    public void setEjbClusterManagerName(ObjectName ejbClusterManagerName) {
  +        this.ejbClusterManagerName = ejbClusterManagerName;
  +    }
  +
  +    public boolean isClustered() {
  +        return null != ejbClusterManagerName;
  +    }
  +    
       protected ProxyInfo createProxyInfo() throws ClassNotFoundException {
           ClassLoader classLoader = getClassLoader();
           Class homeInterface = loadOptionalClass(homeInterfaceName, 
classLoader);
  @@ -457,15 +480,19 @@
           return ClassLoading.loadClass(className, classLoader);
       }
   
  -    protected EJBContainer createContainer(InterfaceMethodSignature[] 
signatures,
  -                                           InstanceContextFactory 
contextFactory,
  -                                           InterceptorBuilder 
interceptorBuilder,
  -                                           InstancePool pool) throws 
Exception {
  +    protected EJBContainer createContainer(
  +            InterfaceMethodSignature[] signatures,
  +            InstanceCache instanceCache,
  +            InstanceContextFactory contextFactory,
  +            InterceptorBuilder interceptorBuilder,
  +            InstancePool pool)
  +            throws Exception {
   
           return new GenericEJBContainer(getContainerId(),
                   getEJBName(),
                   createProxyInfo(),
                   signatures,
  +                instanceCache,
                   contextFactory,
                   interceptorBuilder,
                   pool,
  @@ -483,24 +510,28 @@
                   null,
                   getHomeTxPolicyConfig(),
                   getRemoteTxPolicyConfig(),
  -                Thread.currentThread().getContextClassLoader());
  +                Thread.currentThread().getContextClassLoader(),
  +                null); // EJBClusterManager
       }
   
       protected GBeanData buildGBeanData() {
           return new GBeanData(GenericEJBContainer.GBEAN_INFO);
       }
       
  -    protected GBeanData createConfiguration(ClassLoader cl, 
InterfaceMethodSignature[] signatures,
  -                                            InstanceContextFactory 
contextFactory,
  -                                            InterceptorBuilder 
interceptorBuilder,
  -                                            InstancePool pool,
  -                                            ObjectName timerName) throws 
Exception {
  +    protected GBeanData createConfiguration(ClassLoader cl,
  +            InterfaceMethodSignature[] signatures,
  +            InstanceCache instanceCache,
  +            InstanceContextFactory contextFactory,
  +            InterceptorBuilder interceptorBuilder,
  +            InstancePool pool,
  +            ObjectName timerName) throws Exception {
   
           GBeanData gbean = buildGBeanData();
           gbean.setAttribute("containerID", getContainerId());
           gbean.setAttribute("ejbName", getEJBName());
           gbean.setAttribute("proxyInfo", createProxyInfo());
           gbean.setAttribute("signatures", signatures);
  +        gbean.setAttribute("instanceCache", instanceCache);
           gbean.setAttribute("contextFactory", contextFactory);
           gbean.setAttribute("interceptorBuilder", interceptorBuilder);
           gbean.setAttribute("pool", pool);
  
  
  
  1.5       +5 -5      
openejb/modules/openejb-builder/src/java/org/openejb/deployment/BMPContainerBuilder.java
  
  Index: BMPContainerBuilder.java
  ===================================================================
  RCS file: 
/home/projects/openejb/scm/openejb/modules/openejb-builder/src/java/org/openejb/deployment/BMPContainerBuilder.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- BMPContainerBuilder.java  19 Feb 2005 18:24:43 -0000      1.4
  +++ BMPContainerBuilder.java  21 Dec 2005 14:21:54 -0000      1.5
  @@ -49,6 +49,7 @@
   
   import java.lang.reflect.Method;
   import java.util.LinkedHashMap;
  +
   import javax.ejb.TimedObject;
   import javax.ejb.Timer;
   import javax.management.ObjectName;
  @@ -68,7 +69,6 @@
   import org.openejb.entity.bmp.BMPCreateMethod;
   import org.openejb.entity.bmp.BMPEntityInterceptorBuilder;
   import org.openejb.entity.bmp.BMPFinderMethod;
  -import org.openejb.entity.bmp.BMPInstanceContextFactory;
   import org.openejb.entity.bmp.BMPRemoveMethod;
   import org.openejb.entity.dispatch.EJBActivateOperation;
   import org.openejb.entity.dispatch.EJBLoadOperation;
  @@ -115,7 +115,7 @@
           InterceptorBuilder interceptorBuilder = 
initializeInterceptorBuilder(new BMPEntityInterceptorBuilder(), signatures, 
vtable);
   
           // build the context factory
  -        InstanceContextFactory contextFactory = new 
BMPInstanceContextFactory(getContainerId(), beanClass, 
getUnshareableResources(), getApplicationManagedSecurityResources());
  +        InstanceContextFactory contextFactory = 
containerStrategy.newInstanceContextFactory();
           EntityInstanceFactory instanceFactory = new 
EntityInstanceFactory(contextFactory);
   
           // build the pool
  @@ -124,9 +124,9 @@
           ObjectName timerName = getTimerName(beanClass);
   
           if (buildContainer) {
  -            return createContainer(signatures, contextFactory, 
interceptorBuilder, pool);
  +            return createContainer(signatures, null, contextFactory, 
interceptorBuilder, pool);
           } else {
  -            return createConfiguration(classLoader, signatures, 
contextFactory, interceptorBuilder, pool, timerName);
  +            return createConfiguration(classLoader, signatures, null, 
contextFactory, interceptorBuilder, pool, timerName);
           }
       }
   
  
  
  
  1.33      +11 -5     
openejb/modules/openejb-builder/src/java/org/openejb/deployment/CMPContainerBuilder.java
  
  Index: CMPContainerBuilder.java
  ===================================================================
  RCS file: 
/home/projects/openejb/scm/openejb/modules/openejb-builder/src/java/org/openejb/deployment/CMPContainerBuilder.java,v
  retrieving revision 1.32
  retrieving revision 1.33
  diff -u -r1.32 -r1.33
  --- CMPContainerBuilder.java  14 Dec 2005 13:31:32 -0000      1.32
  +++ CMPContainerBuilder.java  21 Dec 2005 14:21:54 -0000      1.33
  @@ -64,6 +64,7 @@
   import org.openejb.EJBContainer;
   import org.openejb.InstanceContextFactory;
   import org.openejb.InterceptorBuilder;
  +import org.openejb.cache.InstanceCache;
   import org.openejb.cache.InstancePool;
   import org.openejb.dispatch.EJBTimeoutOperation;
   import org.openejb.dispatch.InterfaceMethodSignature;
  @@ -341,9 +342,9 @@
           ObjectName timerName = getTimerName(beanClass);
   
           if (buildContainer) {
  -            return createContainer(signatures, contextFactory, 
interceptorBuilder, pool);
  +            return createContainer(signatures, null, contextFactory, 
interceptorBuilder, pool);
           }
  -        return createConfiguration(classLoader, signatures, contextFactory, 
interceptorBuilder, pool, timerName);
  +        return createConfiguration(classLoader, signatures, null, 
contextFactory, interceptorBuilder, pool, timerName);
       }
   
       private LinkedHashMap createCMPFieldAccessors(SQLQueryBuilder 
queryBuilder, LinkedHashMap cmrFieldAccessor) throws QueryException {
  @@ -718,6 +719,7 @@
       }
       
       protected EJBContainer createContainer(InterfaceMethodSignature[] 
signatures,
  +            InstanceCache instanceCache, 
               InstanceContextFactory contextFactory,
               InterceptorBuilder interceptorBuilder,
               InstancePool pool) throws Exception {
  @@ -727,6 +729,7 @@
                   getEJBName(),
                   createProxyInfo(),
                   signatures,
  +                instanceCache,
                   contextFactory,
                   interceptorBuilder,
                   pool,
  @@ -745,16 +748,19 @@
                   getHomeTxPolicyConfig(),
                   getRemoteTxPolicyConfig(),
                   Thread.currentThread().getContextClassLoader(),
  +                null, // EJBClusterManager
                   cache,
                   factory);
       }
       
  -    protected GBeanData createConfiguration(ClassLoader cl, 
InterfaceMethodSignature[] signatures,
  +    protected GBeanData createConfiguration(ClassLoader cl,
  +            InterfaceMethodSignature[] signatures,
  +            InstanceCache instanceCache,
               InstanceContextFactory contextFactory,
               InterceptorBuilder interceptorBuilder,
               InstancePool pool,
               ObjectName timerName) throws Exception {
  -        GBeanData gbean = super.createConfiguration(cl, signatures, 
contextFactory, interceptorBuilder, pool, timerName);
  +        GBeanData gbean = super.createConfiguration(cl, signatures, 
instanceCache, contextFactory, interceptorBuilder, pool, timerName);
           
           gbean.setAttribute("frontEndCacheDelegate", cache);
           gbean.setAttribute("cacheFactory", factory);
  
  
  
  1.8       +17 -2     
openejb/modules/openejb-builder/src/java/org/openejb/deployment/ContainerBuilder.java
  
  Index: ContainerBuilder.java
  ===================================================================
  RCS file: 
/home/projects/openejb/scm/openejb/modules/openejb-builder/src/java/org/openejb/deployment/ContainerBuilder.java,v
  retrieving revision 1.7
  retrieving revision 1.8
  diff -u -r1.7 -r1.8
  --- ContainerBuilder.java     2 Jun 2005 02:57:01 -0000       1.7
  +++ ContainerBuilder.java     21 Dec 2005 14:21:54 -0000      1.8
  @@ -45,6 +45,7 @@
   package org.openejb.deployment;
   
   import java.util.Map;
  +
   import javax.management.ObjectName;
   
   import org.apache.geronimo.gbean.GBeanData;
  @@ -53,6 +54,8 @@
   import org.apache.geronimo.transaction.context.TransactionContextManager;
   import org.apache.geronimo.transaction.context.UserTransactionImpl;
   import org.openejb.EJBContainer;
  +import org.openejb.InstanceContextFactory;
  +import org.openejb.cache.InstanceCache;
   import org.openejb.deployment.corba.TransactionImportPolicyBuilder;
   import org.openejb.transaction.TransactionPolicySource;
   
  @@ -139,4 +142,16 @@
       TransactionImportPolicyBuilder getTransactionImportPolicyBuilder();
   
       void setTransactionImportPolicyBuilder(TransactionImportPolicyBuilder 
transactionImportPolicyBuilder);
  +
  +    ObjectName getEjbClusterManagerName();
  +    
  +    void setEjbClusterManagerName(ObjectName ejbClusterName);
  +    
  +    void setContainerStrategy(ContainerStrategy containerStrategy);
  +
  +    public interface ContainerStrategy {
  +        public InstanceCache newInstanceCache();
  +    
  +        public InstanceContextFactory newInstanceContextFactory();
  +    }
   }
  
  
  
  1.22      +1 -0      
openejb/modules/openejb-builder/src/java/org/openejb/deployment/EntityBuilder.java
  
  Index: EntityBuilder.java
  ===================================================================
  RCS file: 
/home/projects/openejb/scm/openejb/modules/openejb-builder/src/java/org/openejb/deployment/EntityBuilder.java,v
  retrieving revision 1.21
  retrieving revision 1.22
  diff -u -r1.21 -r1.22
  --- EntityBuilder.java        9 Sep 2005 06:43:23 -0000       1.21
  +++ EntityBuilder.java        21 Dec 2005 14:21:54 -0000      1.22
  @@ -115,6 +115,7 @@
           String ejbName = entityBean.getEjbName().getStringValue().trim();
   
           BMPContainerBuilder builder = new BMPContainerBuilder();
  +        builder.setContainerStrategy(new 
DefaultBMPContainerStrategy(builder));
           builder.setClassLoader(cl);
           builder.setContainerId(containerObjectName.getCanonicalName());
           builder.setEJBName(ejbName);
  
  
  
  1.8       +17 -14    
openejb/modules/openejb-builder/src/java/org/openejb/deployment/RemoteEJBReferenceBuilder.java
  
  Index: RemoteEJBReferenceBuilder.java
  ===================================================================
  RCS file: 
/home/projects/openejb/scm/openejb/modules/openejb-builder/src/java/org/openejb/deployment/RemoteEJBReferenceBuilder.java,v
  retrieving revision 1.7
  retrieving revision 1.8
  diff -u -r1.7 -r1.8
  --- RemoteEJBReferenceBuilder.java    1 Dec 2005 08:34:55 -0000       1.7
  +++ RemoteEJBReferenceBuilder.java    21 Dec 2005 14:21:54 -0000      1.8
  @@ -48,35 +48,33 @@
   package org.openejb.deployment;
   
   import java.net.URI;
  -import java.util.Set;
  -import java.util.Collection;
  -import java.util.ArrayList;
  -import java.util.Iterator;
  +import java.net.UnknownHostException;
  +
   import javax.management.ObjectName;
   import javax.naming.Reference;
   
   import org.apache.geronimo.common.DeploymentException;
  -import org.apache.geronimo.common.UnresolvedEJBRefException;
  +import org.apache.geronimo.gbean.GBeanData;
   import org.apache.geronimo.gbean.GBeanInfo;
   import org.apache.geronimo.gbean.GBeanInfoBuilder;
  -import org.apache.geronimo.gbean.GBeanData;
   import org.apache.geronimo.j2ee.deployment.EJBReferenceBuilder;
   import org.apache.geronimo.j2ee.deployment.NamingContext;
   import org.apache.geronimo.j2ee.j2eeobjectnames.NameFactory;
  -import org.apache.geronimo.kernel.jmx.JMXUtil;
  -import org.apache.geronimo.kernel.GBeanNotFoundException;
  -
  +import org.openejb.client.ServerMetaData;
  +import org.openejb.client.naming.RemoteEJBAddr;
   import org.openejb.client.naming.RemoteEJBObjectFactory;
   import org.openejb.client.naming.RemoteEJBRefAddr;
  -import org.openejb.corba.CORBAHandleDelegate;
  -import org.openejb.corba.proxy.CORBAProxyReference;
  -import org.openejb.proxy.ProxyInfo;
   
   
   /**
    */
   public class RemoteEJBReferenceBuilder extends OpenEJBReferenceBuilder {
  -
  +    private final ServerMetaData server;
  +    
  +    public RemoteEJBReferenceBuilder(String host, int port) throws 
UnknownHostException {
  +        server = new ServerMetaData("BOOT", host, port);
  +    }
  +    
       public Reference createEJBLocalReference(String objectName, GBeanData 
gbeanData, boolean isSession, String localHome, String local) {
           throw new UnsupportedOperationException("Application client cannot 
have a local ejb ref");
       }
  @@ -86,7 +84,7 @@
       }
   
       protected Reference buildRemoteReference(String objectName, boolean 
session, String home, String remote) {
  -        RemoteEJBRefAddr addr = new RemoteEJBRefAddr(objectName);
  +        RemoteEJBRefAddr addr = new RemoteEJBRefAddr(new 
RemoteEJBAddr(server, objectName));
           Reference reference = new Reference(null, addr, 
RemoteEJBObjectFactory.class.getName(), null);
           return reference;
       }
  @@ -97,6 +95,11 @@
           GBeanInfoBuilder infoFactory = 
GBeanInfoBuilder.createStatic(RemoteEJBReferenceBuilder.class, 
NameFactory.MODULE_BUILDER); //TODO decide what type this should be
           infoFactory.addInterface(EJBReferenceBuilder.class);
   
  +        infoFactory.addAttribute("host", String.class, true);
  +        infoFactory.addAttribute("port", int.class, true);
  +
  +        infoFactory.setConstructor(new String[]{"host", "port"});
  +        
           GBEAN_INFO = infoFactory.getBeanInfo();
       }
   
  
  
  
  1.35      +19 -2     
openejb/modules/openejb-builder/src/java/org/openejb/deployment/SessionBuilder.java
  
  Index: SessionBuilder.java
  ===================================================================
  RCS file: 
/home/projects/openejb/scm/openejb/modules/openejb-builder/src/java/org/openejb/deployment/SessionBuilder.java,v
  retrieving revision 1.34
  retrieving revision 1.35
  diff -u -r1.34 -r1.35
  --- SessionBuilder.java       21 Aug 2005 07:36:30 -0000      1.34
  +++ SessionBuilder.java       21 Dec 2005 14:21:54 -0000      1.35
  @@ -98,6 +98,7 @@
   import org.openejb.slsb.HandlerChainConfiguration;
   import org.openejb.transaction.TransactionPolicySource;
   import org.openejb.transaction.TransactionPolicyType;
  +import org.openejb.xbeans.ejbjar.OpenejbEjbClusterReferenceType;
   import org.openejb.xbeans.ejbjar.OpenejbSessionBeanType;
   import org.openejb.xbeans.ejbjar.OpenejbTssType;
   import org.openejb.xbeans.ejbjar.OpenejbWebServiceSecurityType;
  @@ -239,6 +240,7 @@
           boolean isStateless = 
"Stateless".equals(sessionBean.getSessionType().getStringValue().trim());
           if (isStateless) {
               builder = new StatelessContainerBuilder();
  +            builder.setContainerStrategy(new 
DefaultSLContainerStrategy(builder));
               
builder.setTransactedTimerName(earContext.getTransactedTimerName());
               
builder.setNonTransactedTimerName(earContext.getNonTransactedTimerName());
               
builder.setServiceEndpointName(OpenEJBModuleBuilder.getJ2eeStringValue(sessionBean.getServiceEndpoint()));
  @@ -246,6 +248,21 @@
               containerSecurityBuilder.addToPermissions(toBeChecked, ejbName, 
"ServiceEndpoint", builder.getServiceEndpointName(), cl);
           } else {
               builder = new StatefulContainerBuilder();
  +            if (null == openejbSessionBean ||
  +                    false == openejbSessionBean.isSetEjbClusterReference()) {
  +                builder.setContainerStrategy(new 
DefaultSFContainerStrategy(builder));
  +            } else if (openejbSessionBean.isSetEjbClusterReference()) {
  +                builder.setContainerStrategy(new 
ClusteredSFContainerStrategy(builder));
  +                OpenejbEjbClusterReferenceType ejbClusterReference = 
openejbSessionBean.getEjbClusterReference();
  +                ObjectName clusterObjectName; 
  +                String name = ejbClusterReference.getTargetName();
  +                try {
  +                    clusterObjectName = ObjectName.getInstance(name);
  +                } catch (MalformedObjectNameException e) {
  +                    throw new DeploymentException("Invalid object name for 
ejb-cluster-reference", e);
  +                }
  +                builder.setEjbClusterManagerName(clusterObjectName);
  +            }
           }
           builder.setClassLoader(cl);
           builder.setContainerId(sessionObjectName.getCanonicalName());
  @@ -255,7 +272,7 @@
           
builder.setRemoteInterfaceName(OpenEJBModuleBuilder.getJ2eeStringValue(sessionBean.getRemote()));
           
builder.setLocalHomeInterfaceName(OpenEJBModuleBuilder.getJ2eeStringValue(sessionBean.getLocalHome()));
           
builder.setLocalInterfaceName(OpenEJBModuleBuilder.getJ2eeStringValue(sessionBean.getLocal()));
  -
  +        
           SecurityConfiguration securityConfiguration = 
earContext.getSecurityConfiguration();
           if (securityConfiguration != null) {
               containerSecurityBuilder.addToPermissions(toBeChecked, ejbName, 
"Home", builder.getHomeInterfaceName(), cl);
  @@ -292,7 +309,7 @@
               }
           }
           
builder.setTransactionImportPolicyBuilder(getModuleBuilder().getTransactionImportPolicyBuilder());
  -
  +        
           processEnvironmentRefs(builder, earContext, ejbModule, sessionBean, 
openejbSessionBean, userTransaction, cl);
   
           ObjectName tssBeanObjectName = null;
  
  
  
  1.5       +14 -8     
openejb/modules/openejb-builder/src/java/org/openejb/deployment/StatefulContainerBuilder.java
  
  Index: StatefulContainerBuilder.java
  ===================================================================
  RCS file: 
/home/projects/openejb/scm/openejb/modules/openejb-builder/src/java/org/openejb/deployment/StatefulContainerBuilder.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- StatefulContainerBuilder.java     1 Mar 2005 23:34:37 -0000       1.4
  +++ StatefulContainerBuilder.java     21 Dec 2005 14:21:54 -0000      1.5
  @@ -51,9 +51,10 @@
   import java.util.LinkedHashMap;
   
   import org.openejb.EJBComponentType;
  +import org.openejb.InstanceContextFactory;
   import org.openejb.InterceptorBuilder;
  +import org.openejb.cache.InstanceCache;
   import org.openejb.cache.InstancePool;
  -import org.openejb.cache.SimpleInstanceCache;
   import org.openejb.dispatch.InterfaceMethodSignature;
   import org.openejb.dispatch.MethodHelper;
   import org.openejb.dispatch.MethodSignature;
  @@ -64,7 +65,6 @@
   import org.openejb.sfsb.BusinessMethod;
   import org.openejb.sfsb.CreateMethod;
   import org.openejb.sfsb.RemoveMethod;
  -import org.openejb.sfsb.StatefulInstanceContextFactory;
   import org.openejb.sfsb.StatefulInstanceFactory;
   import org.openejb.sfsb.StatefulInterceptorBuilder;
   import org.openejb.slsb.dispatch.EJBActivateOperation;
  @@ -78,8 +78,13 @@
       protected int getEJBComponentType() {
           return EJBComponentType.STATEFUL;
       }
  -
  +    
       protected Object buildIt(boolean buildContainer) throws Exception {
  +        if (null == containerStrategy) {
  +            throw new IllegalStateException("SFSBContainerStrategy has not" +
  +                    " been set.");
  +        }
  +        
           // get the bean class
           ClassLoader classLoader = getClassLoader();
           Class beanClass = classLoader.loadClass(getBeanClassName());
  @@ -90,22 +95,23 @@
           VirtualOperation[] vtable = (VirtualOperation[]) 
vopMap.values().toArray(new VirtualOperation[vopMap.size()]);
   
           // build the instance factory
  -        StatefulInstanceContextFactory contextFactory = new 
StatefulInstanceContextFactory(getContainerId(), beanClass, 
getUserTransaction(), getUnshareableResources(), 
getApplicationManagedSecurityResources());
  +        InstanceContextFactory contextFactory = 
containerStrategy.newInstanceContextFactory();
           StatefulInstanceFactory instanceFactory = new 
StatefulInstanceFactory(contextFactory);
   
           // create and intitalize the interceptor moduleBuilder
           InterceptorBuilder interceptorBuilder = 
initializeInterceptorBuilder(new StatefulInterceptorBuilder(), signatures, 
vtable);
           interceptorBuilder.setInstanceFactory(instanceFactory);
  -        interceptorBuilder.setInstanceCache(new SimpleInstanceCache());
  +        InstanceCache instanceCache = containerStrategy.newInstanceCache();
  +        interceptorBuilder.setInstanceCache(instanceCache);
   
           // build the pool
           InstancePool pool = createInstancePool(instanceFactory);
   
           if (buildContainer) {
  -            return createContainer(signatures, contextFactory, 
interceptorBuilder, pool);
  +            return createContainer(signatures, instanceCache, 
contextFactory, interceptorBuilder, pool);
           } else {
               //stateful has no timers
  -            return createConfiguration(classLoader, signatures, 
contextFactory, interceptorBuilder, pool, null);
  +            return createConfiguration(classLoader, signatures, 
instanceCache, contextFactory, interceptorBuilder, pool, null);
           }
       }
   
  
  
  
  1.6       +7 -6      
openejb/modules/openejb-builder/src/java/org/openejb/deployment/StatelessContainerBuilder.java
  
  Index: StatelessContainerBuilder.java
  ===================================================================
  RCS file: 
/home/projects/openejb/scm/openejb/modules/openejb-builder/src/java/org/openejb/deployment/StatelessContainerBuilder.java,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- StatelessContainerBuilder.java    16 Apr 2005 02:21:04 -0000      1.5
  +++ StatelessContainerBuilder.java    21 Dec 2005 14:21:54 -0000      1.6
  @@ -49,12 +49,13 @@
   
   import java.lang.reflect.Method;
   import java.util.LinkedHashMap;
  +
   import javax.ejb.TimedObject;
   import javax.ejb.Timer;
   import javax.management.ObjectName;
   
   import org.openejb.EJBComponentType;
  -import org.openejb.InterceptorBuilder;
  +import org.openejb.InstanceContextFactory;
   import org.openejb.cache.InstancePool;
   import org.openejb.dispatch.EJBTimeoutOperation;
   import org.openejb.dispatch.InterfaceMethodSignature;
  @@ -63,11 +64,11 @@
   import org.openejb.slsb.BusinessMethod;
   import org.openejb.slsb.CreateMethod;
   import org.openejb.slsb.EJBCreateMethod;
  +import org.openejb.slsb.HandlerChainConfiguration;
   import org.openejb.slsb.RemoveMethod;
   import org.openejb.slsb.StatelessInstanceContextFactory;
   import org.openejb.slsb.StatelessInstanceFactory;
   import org.openejb.slsb.StatelessInterceptorBuilder;
  -import org.openejb.slsb.HandlerChainConfiguration;
   import org.openejb.slsb.dispatch.SetSessionContextOperation;
   
   /**
  @@ -106,7 +107,7 @@
           
interceptorBuilder.setHandlerChainConfiguration(getHandlerChainConfiguration());
   
           // build the instance factory
  -        StatelessInstanceContextFactory contextFactory = new 
StatelessInstanceContextFactory(getContainerId(), beanClass, 
getUserTransaction(), getUnshareableResources(), 
getApplicationManagedSecurityResources());
  +        InstanceContextFactory contextFactory = 
containerStrategy.newInstanceContextFactory();
           StatelessInstanceFactory instanceFactory = new 
StatelessInstanceFactory(contextFactory);
   
           // build the pool
  @@ -116,9 +117,9 @@
   
           if (buildContainer) {
               //TODO add timer to sig.
  -            return createContainer(signatures, contextFactory, 
interceptorBuilder, pool);
  +            return createContainer(signatures, null, contextFactory, 
interceptorBuilder, pool);
           } else {
  -            return createConfiguration(classLoader, signatures, 
contextFactory, interceptorBuilder, pool, timerName);
  +            return createConfiguration(classLoader, signatures, null, 
contextFactory, interceptorBuilder, pool, timerName);
           }
       }
   
  
  
  
  1.1                  
openejb/modules/openejb-builder/src/java/org/openejb/deployment/ClusteredSFContainerStrategy.java
  
  Index: ClusteredSFContainerStrategy.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 the

   *    above copyright notice, 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.

   *

   * Copyright 2005 (C) The OpenEJB Group. All Rights Reserved.

   *

   * $Id: ClusteredSFContainerStrategy.java,v 1.1 2005/12/21 14:21:54 gdamour 
Exp $

   */

  package org.openejb.deployment;

  

  import org.openejb.InstanceContextFactory;

  import org.openejb.cache.InstanceCache;

  import org.openejb.cache.SimpleInstanceCache;

  import org.openejb.cluster.server.DefaultClusteredInstanceCache;

  import org.openejb.cluster.sfsb.ClusteredSFInstanceContextFactory;

  import org.openejb.deployment.ContainerBuilder.ContainerStrategy;

  

  /**

   * 

   * @version $Revision: 1.1 $ $Date: 2005/12/21 14:21:54 $

   */

  public class ClusteredSFContainerStrategy implements ContainerStrategy {

      private final ContainerBuilder builder;

      

      public ClusteredSFContainerStrategy(ContainerBuilder builder) {

          this.builder = builder;

      }

  

      public InstanceCache newInstanceCache() {

          return new DefaultClusteredInstanceCache(new SimpleInstanceCache());

      }

  

      public InstanceContextFactory newInstanceContextFactory() {

          ClassLoader classLoader = builder.getClassLoader();

          Class beanClass;

          try {

              beanClass = classLoader.loadClass(builder.getBeanClassName());

          } catch (ClassNotFoundException e) {

              throw (IllegalStateException) new 
IllegalStateException().initCause(e);

          }

          

          return new ClusteredSFInstanceContextFactory(

                  builder.getContainerId(),

                  beanClass,

                  builder.getUserTransaction(),

                  builder.getUnshareableResources(),

                  builder.getApplicationManagedSecurityResources());

      }

  }

  
  
  
  1.1                  
openejb/modules/openejb-builder/src/java/org/openejb/deployment/DefaultBMPContainerStrategy.java
  
  Index: DefaultBMPContainerStrategy.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 the

   *    above copyright notice, 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.

   *

   * Copyright 2005 (C) The OpenEJB Group. All Rights Reserved.

   *

   * $Id: DefaultBMPContainerStrategy.java,v 1.1 2005/12/21 14:21:54 gdamour 
Exp $

   */

  package org.openejb.deployment;

  

  import org.openejb.InstanceContextFactory;

  import org.openejb.cache.InstanceCache;

  import org.openejb.cache.SimpleInstanceCache;

  import org.openejb.deployment.ContainerBuilder.ContainerStrategy;

  import org.openejb.entity.bmp.BMPInstanceContextFactory;

  import org.openejb.sfsb.StatefulInstanceContextFactory;

  

  /**

   * 

   * @version $Revision: 1.1 $ $Date: 2005/12/21 14:21:54 $

   */

  public class DefaultBMPContainerStrategy implements ContainerStrategy {

      private final ContainerBuilder builder;

      

      public DefaultBMPContainerStrategy(ContainerBuilder builder) {

          this.builder = builder;

      }

  

      public InstanceCache newInstanceCache() {

          throw new UnsupportedOperationException("No InstanceCache is defined" 
+

                  " for a BMP.");

      }

  

      public InstanceContextFactory newInstanceContextFactory() {

          ClassLoader classLoader = builder.getClassLoader();

          Class beanClass;

          try {

              beanClass = classLoader.loadClass(builder.getBeanClassName());

          } catch (ClassNotFoundException e) {

              throw (IllegalStateException) new 
IllegalStateException().initCause(e);

          }

          

          return new BMPInstanceContextFactory(

                  builder.getContainerId(),

                  beanClass,

                  builder.getUnshareableResources(),

                  builder.getApplicationManagedSecurityResources());

      }

  }

  
  
  
  1.1                  
openejb/modules/openejb-builder/src/java/org/openejb/deployment/DefaultSFContainerStrategy.java
  
  Index: DefaultSFContainerStrategy.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 the

   *    above copyright notice, 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.

   *

   * Copyright 2005 (C) The OpenEJB Group. All Rights Reserved.

   *

   * $Id: DefaultSFContainerStrategy.java,v 1.1 2005/12/21 14:21:54 gdamour Exp 
$

   */

  package org.openejb.deployment;

  

  import org.openejb.InstanceContextFactory;

  import org.openejb.cache.InstanceCache;

  import org.openejb.cache.SimpleInstanceCache;

  import org.openejb.deployment.ContainerBuilder.ContainerStrategy;

  import org.openejb.sfsb.StatefulInstanceContextFactory;

  

  /**

   * 

   * @version $Revision: 1.1 $ $Date: 2005/12/21 14:21:54 $

   */

  public class DefaultSFContainerStrategy implements ContainerStrategy {

      private final ContainerBuilder builder;

      

      public DefaultSFContainerStrategy(ContainerBuilder builder) {

          this.builder = builder;

      }

  

      public InstanceCache newInstanceCache() {

          return new SimpleInstanceCache();

      }

  

      public InstanceContextFactory newInstanceContextFactory() {

          ClassLoader classLoader = builder.getClassLoader();

          Class beanClass;

          try {

              beanClass = classLoader.loadClass(builder.getBeanClassName());

          } catch (ClassNotFoundException e) {

              throw (IllegalStateException) new 
IllegalStateException().initCause(e);

          }

          

          return new StatefulInstanceContextFactory(

                  builder.getContainerId(),

                  beanClass,

                  builder.getUserTransaction(),

                  builder.getUnshareableResources(),

                  builder.getApplicationManagedSecurityResources());

      }

  }

  
  
  
  1.1                  
openejb/modules/openejb-builder/src/java/org/openejb/deployment/DefaultSLContainerStrategy.java
  
  Index: DefaultSLContainerStrategy.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 the

   *    above copyright notice, 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.

   *

   * Copyright 2005 (C) The OpenEJB Group. All Rights Reserved.

   *

   * $Id: DefaultSLContainerStrategy.java,v 1.1 2005/12/21 14:21:54 gdamour Exp 
$

   */

  package org.openejb.deployment;

  

  import org.openejb.InstanceContextFactory;

  import org.openejb.cache.InstanceCache;

  import org.openejb.deployment.ContainerBuilder.ContainerStrategy;

  import org.openejb.slsb.StatelessInstanceContextFactory;

  

  /**

   * 

   * @version $Revision: 1.1 $ $Date: 2005/12/21 14:21:54 $

   */

  public class DefaultSLContainerStrategy implements ContainerStrategy {

      private final ContainerBuilder builder;

      

      public DefaultSLContainerStrategy(ContainerBuilder builder) {

          this.builder = builder;

      }

  

      public InstanceCache newInstanceCache() {

          throw new UnsupportedOperationException("No InstanceCache is defined" 
+

                  " for a SLSB.");

      }

  

      public InstanceContextFactory newInstanceContextFactory() {

          ClassLoader classLoader = builder.getClassLoader();

          Class beanClass;

          try {

              beanClass = classLoader.loadClass(builder.getBeanClassName());

          } catch (ClassNotFoundException e) {

              throw (IllegalStateException) new 
IllegalStateException().initCause(e);

          }

  

          return new StatelessInstanceContextFactory(

                  builder.getContainerId(),

                  beanClass,

                  builder.getUserTransaction(),

                  builder.getUnshareableResources(),

                  builder.getApplicationManagedSecurityResources());

      }

  }

  
  
  

Reply via email to