gdamour 2005/12/21 09:21:54
Modified: modules/core/src/java/org/openejb/sfsb
StatefulInstanceContextFactory.java
StatefulInterceptorBuilder.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 +18 -14
openejb/modules/core/src/java/org/openejb/sfsb/StatefulInstanceContextFactory.java
Index: StatefulInstanceContextFactory.java
===================================================================
RCS file:
/home/projects/openejb/scm/openejb/modules/core/src/java/org/openejb/sfsb/StatefulInstanceContextFactory.java,v
retrieving revision 1.12
retrieving revision 1.13
diff -u -r1.12 -r1.13
--- StatefulInstanceContextFactory.java 1 Mar 2005 23:34:30 -0000
1.12
+++ StatefulInstanceContextFactory.java 21 Dec 2005 14:21:54 -0000
1.13
@@ -53,18 +53,17 @@
import javax.ejb.SessionBean;
import javax.ejb.SessionContext;
+import org.apache.geronimo.core.service.Interceptor;
import org.apache.geronimo.transaction.InstanceContext;
import org.apache.geronimo.transaction.context.TransactionContextManager;
import org.apache.geronimo.transaction.context.UserTransactionImpl;
-import org.apache.geronimo.core.service.Interceptor;
-
import org.openejb.EJBInstanceFactory;
import org.openejb.EJBInstanceFactoryImpl;
import org.openejb.InstanceContextFactory;
-import org.openejb.timer.BasicTimerService;
import org.openejb.dispatch.InterfaceMethodSignature;
import org.openejb.dispatch.SystemMethodIndices;
import org.openejb.proxy.EJBProxyFactory;
+import org.openejb.timer.BasicTimerService;
/**
*
@@ -72,15 +71,15 @@
* @version $Revision$ $Date$
*/
public class StatefulInstanceContextFactory implements
InstanceContextFactory, Serializable {
- private final Object containerId;
+ protected final Object containerId;
private final EJBInstanceFactory factory;
- private final UserTransactionImpl userTransaction;
- private final Set unshareableResources;
- private final Set applicationManagedSecurityResources;
- private transient EJBProxyFactory proxyFactory;
- private transient Interceptor systemChain;
- private transient SystemMethodIndices systemMethodIndices;
- private transient TransactionContextManager transactionContextManager;
+ protected final UserTransactionImpl userTransaction;
+ protected final Set unshareableResources;
+ protected final Set applicationManagedSecurityResources;
+ protected transient EJBProxyFactory proxyFactory;
+ protected transient Interceptor systemChain;
+ protected transient SystemMethodIndices systemMethodIndices;
+ protected transient TransactionContextManager transactionContextManager;
public StatefulInstanceContextFactory(Object containerId, Class
beanClass, UserTransactionImpl userTransaction, Set unshareableResources, Set
applicationManagedSecurityResources) {
this.containerId = containerId;
@@ -116,10 +115,11 @@
if (proxyFactory == null) {
throw new IllegalStateException("ProxyFacory has not been set");
}
+
return new StatefulInstanceContext(
containerId,
proxyFactory,
- (SessionBean) factory.newInstance(),
+ createInstance(),
createInstanceId(),
transactionContextManager, userTransaction,
systemMethodIndices, systemChain, unshareableResources,
@@ -127,12 +127,16 @@
}
private static int nextId;
- private StatefulInstanceId createInstanceId() {
+ private Object createInstanceId() {
synchronized(this) {
return new StatefulInstanceId(nextId++);
}
}
+ protected SessionBean createInstance() throws Exception {
+ return (SessionBean) factory.newInstance();
+ }
+
private static class StatefulInstanceId implements Serializable {
private final int id;
1.9 +5 -2
openejb/modules/core/src/java/org/openejb/sfsb/StatefulInterceptorBuilder.java
Index: StatefulInterceptorBuilder.java
===================================================================
RCS file:
/home/projects/openejb/scm/openejb/modules/core/src/java/org/openejb/sfsb/StatefulInterceptorBuilder.java,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -r1.8 -r1.9
--- StatefulInterceptorBuilder.java 18 Apr 2005 19:05:13 -0000 1.8
+++ StatefulInterceptorBuilder.java 21 Dec 2005 14:21:54 -0000 1.9
@@ -49,11 +49,11 @@
import org.apache.geronimo.core.service.Interceptor;
import org.apache.geronimo.naming.java.ComponentContextInterceptor;
-
import org.openejb.AbstractInterceptorBuilder;
import org.openejb.ConnectionTrackingInterceptor;
import org.openejb.SystemExceptionInterceptor;
import org.openejb.TwoChains;
+import org.openejb.cluster.server.ClusteredInstanceInterceptor;
import org.openejb.dispatch.DispatchInterceptor;
import org.openejb.security.EJBIdentityInterceptor;
import org.openejb.security.EJBRunAsInterceptor;
@@ -92,6 +92,9 @@
}
if (useContextHandler) {
firstInterceptor = new
PolicyContextHandlerEJBInterceptor(firstInterceptor);
+ }
+ if (clustered) {
+ firstInterceptor = new
ClusteredInstanceInterceptor(firstInterceptor);
}
firstInterceptor = new StatefulInstanceInterceptor(firstInterceptor,
containerId, instanceFactory, instanceCache, transactionContextManager);
firstInterceptor = new
TransactionContextInterceptor(firstInterceptor, transactionContextManager,
transactionPolicyManager);