User: slaboure
Date: 01/11/09 14:51:38
Modified: src/main/org/jboss/ejb/plugins/jrmp13/server
JRMPContainerInvokerHA.java
Log:
Added SFSB support for clustering.
Revision Changes Path
1.9 +76 -7
jbossmx/src/main/org/jboss/ejb/plugins/jrmp13/server/JRMPContainerInvokerHA.java
Index: JRMPContainerInvokerHA.java
===================================================================
RCS file:
/cvsroot/jboss/jbossmx/src/main/org/jboss/ejb/plugins/jrmp13/server/JRMPContainerInvokerHA.java,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -r1.8 -r1.9
--- JRMPContainerInvokerHA.java 2001/11/01 04:13:57 1.8
+++ JRMPContainerInvokerHA.java 2001/11/09 22:51:38 1.9
@@ -29,6 +29,7 @@
import org.jboss.ejb.plugins.jrmp.interfaces.ContainerRemote;
import org.jboss.ejb.plugins.jrmp13.interfaces.HomeProxyHA;
import org.jboss.ejb.plugins.jrmp13.interfaces.StatelessSessionProxyHA;
+import org.jboss.ejb.plugins.jrmp13.interfaces.StatefulSessionProxyHA;
import org.jboss.ejb.plugins.jrmp13.interfaces.EntityProxyHA;
import org.jboss.ejb.plugins.jrmp13.interfaces.StatefulSessionProxy;
import org.jboss.ejb.plugins.jrmp13.interfaces.EntityProxy;
@@ -40,17 +41,27 @@
import org.jboss.ha.framework.interfaces.RoundRobin;
import org.jboss.ha.framework.interfaces.FirstAvailable;
import org.jboss.ha.framework.interfaces.LoadBalancePolicy;
+import
org.jboss.ha.hasessionstate.interfaces.HASessionState.HASessionStateTopologyListener;
+import org.jboss.ha.hasessionstate.interfaces.HASessionState;
/**
* HA JRMP Container delegate
*
* @see <related>
* @author <a href="mailto:[EMAIL PROTECTED]">Bill Burke</a>
- * @version $Revision: 1.8 $
+ * @author <a href="mailto:[EMAIL PROTECTED]">Sacha Labourey</a>
+ * @version $Revision: 1.9 $
+ *
+ * <p><b>Revisions:</b>
+ *
+ * <p><b>20010911 Sacha Labourey:</b>
+ * <ul>
+ * <li> Added support for SFSB
+ * </ul>
*/
public final class JRMPContainerInvokerHA
- implements ContainerInvoker
-{
+ implements ContainerInvoker, HASessionStateTopologyListener
+{
static Logger log = Logger.create(JRMPContainerInvoker.class);
EJBHome home;
EJBObject statelessObject;
@@ -60,12 +71,16 @@
HomeProxyHA homeProxy;
StatelessSessionProxyHA statelessProxy;
- protected HARMIServerImpl harmi;
+ protected HARMIServerImpl harmi;
protected HAPartition partition;
protected String partitionName;
protected Class homeLoadBalancePolicyClass;
protected Class beanLoadBalancePolicyClass;
-
+
+ protected HARMIServerImpl harmiSF;
+ protected HAPartition partitionSF;
+ protected String haSessionStateName =
org.jboss.metadata.ClusterConfigMetaData.DEFAULT_SESSION_STATE_NAME;
+
public
JRMPContainerInvokerHA(org.jboss.ejb.plugins.jrmp.server.JRMPContainerInvokerHA ci)
{
this.ci = ci;
@@ -81,12 +96,14 @@
ClusterConfigMetaData config =
container.getBeanMetaData().getClusterConfigMetaData();
String homeLoadBalancePolicy = null;
- String beanLoadBalancePolicy = null;
+ String beanLoadBalancePolicy = null;
+
if (config != null)
{
this.partitionName = config.getPartitionName();
homeLoadBalancePolicy = config.getHomeLoadBalancePolicy();
beanLoadBalancePolicy = config.getBeanLoadBalancePolicy();
+ haSessionStateName = config.getHaSessionStateName ();
}
else
{
@@ -177,6 +194,24 @@
ContainerRemote beanStub =
(ContainerRemote)harmi.createHAStub((LoadBalancePolicy)beanLoadBalancePolicyClass.newInstance());
statelessProxy.setHAProxy(beanStub);
}
+
+ // SFSB work
+ //
+ if (!(container.getBeanMetaData() instanceof EntityMetaData) &&
+ ((SessionMetaData)container.getBeanMetaData()).isStateful())
+ {
+ // first get the HASessionState we work with
+ //
+ HASessionState hass = (HASessionState) new
InitialContext().lookup(this.haSessionStateName);
+ hass.subscribe (this);
+ this.partitionSF = hass.getCurrentHAPartition ();
+
+ // the partition may not yet exists
+ //
+ if (this.partitionSF != null)
+ this.harmiSF = new HARMIServerImpl (this.partitionSF,
ci.getJndiName(), ContainerRemote.class, ci);
+ }
+
}
catch (Exception ex)
{
@@ -223,9 +258,42 @@
return statelessObject;
}
+ // For SFSB only
+ //
+ public void newSessionStateTopology (HAPartition haSubPartition, boolean
partitionHasChanged)
+ {
+ if (partitionHasChanged)
+ try
+ {
+ if (this.partitionSF == null)
+ this.harmiSF = new HARMIServerImpl (this.partitionSF,
ci.getJndiName(), ContainerRemote.class, ci);
+ else
+ this.harmiSF.updateHAPartition (haSubPartition);
+ }
+ catch (Exception e)
+ {
+ e.printStackTrace ();
+ }
+ }
+
public EJBObject getStatefulSessionEJBObject(Object id)
{
- throw new RuntimeException("NOT IMPLEMENTED");
+ ContainerRemote stub = null;
+ try
+ {
+ if (harmiSF == null)
+ log.info ("Not yet able to create EJBObject for SFSB: HAPartition not
yet ready");
+ else
+ stub =
(ContainerRemote)harmiSF.createHAStub((LoadBalancePolicy)beanLoadBalancePolicyClass.newInstance());
+ }
+ catch (Exception ie)
+ {
+ log.error("failed to create load balance class", ie);
+ }
+ return
(EJBObject)Proxy.newProxyInstance(((ContainerInvokerContainer)container).getRemoteClass().getClassLoader(),
+ new Class[] {
((ContainerInvokerContainer)container).getRemoteClass() },
+ new StatefulSessionProxyHA(ci.getJndiName(), stub, id,
ci.isOptimized()));
+
}
public EJBObject getEntityEJBObject(Object id)
@@ -256,5 +324,6 @@
}
return list;
}
+
}
_______________________________________________
Jboss-development mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/jboss-development