[jboss-cvs] JBossAS SVN: r62773 - trunk/ejb3/src/main/org/jboss/ejb3/stateful.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Thu May 3 00:04:49 EDT 2007
Author: bstansberry at jboss.com
Date: 2007-05-03 00:04:49 -0400 (Thu, 03 May 2007)
New Revision: 62773
Modified:
trunk/ejb3/src/main/org/jboss/ejb3/stateful/StatefulClusterProxyFactory.java
Log:
[EJBTHREE-948] Use deployment-qualified ejb name in FamilyClusterInfo.familyName
[EJBTHREE-949] Update FCI when cluster topology changes
Modified: trunk/ejb3/src/main/org/jboss/ejb3/stateful/StatefulClusterProxyFactory.java
===================================================================
--- trunk/ejb3/src/main/org/jboss/ejb3/stateful/StatefulClusterProxyFactory.java 2007-05-03 04:02:47 UTC (rev 62772)
+++ trunk/ejb3/src/main/org/jboss/ejb3/stateful/StatefulClusterProxyFactory.java 2007-05-03 04:04:49 UTC (rev 62773)
@@ -22,6 +22,8 @@
package org.jboss.ejb3.stateful;
import java.lang.reflect.InvocationTargetException;
+import java.util.ArrayList;
+import java.util.List;
import javax.naming.NamingException;
@@ -38,10 +40,12 @@
import org.jboss.ejb3.ProxyFactoryHelper;
import org.jboss.ejb3.remoting.RemoteProxyFactory;
import org.jboss.ha.framework.interfaces.ClusteringTargetsRepository;
+import org.jboss.ha.framework.interfaces.DistributedReplicantManager;
import org.jboss.ha.framework.interfaces.FirstAvailable;
import org.jboss.ha.framework.interfaces.HAPartition;
import org.jboss.ha.framework.interfaces.LoadBalancePolicy;
import org.jboss.ha.framework.server.HATarget;
+import org.jboss.logging.Logger;
import org.jboss.naming.Util;
import org.jboss.remoting.InvokerLocator;
@@ -54,12 +58,16 @@
*
* @version $Revision$
*/
-public class StatefulClusterProxyFactory extends BaseStatefulProxyFactory implements RemoteProxyFactory
+public class StatefulClusterProxyFactory extends BaseStatefulProxyFactory
+ implements RemoteProxyFactory, DistributedReplicantManager.ReplicantListener
{
+ private static final Logger log = Logger.getLogger(StatefulClusterProxyFactory.class);
+
public static final String FACTORY_ATTRIBUTE = ",element=ProxyFactory,partition=";
private RemoteBinding binding;
private InvokerLocator locator;
+ private DistributedReplicantManager drm;
private HATarget hatarget;
private String proxyFamilyName;
private LoadBalancePolicy lbPolicy;
@@ -91,7 +99,7 @@
Clustered clustered = (Clustered) advisor.resolveAnnotation(Clustered.class);
if (clustered == null) throw new RuntimeException("Could not find @Clustered annotation. Cannot deploy.");
String partitionName = ((StatefulContainer) container).getPartitionName();
- proxyFamilyName = container.getEjbName() + locator.getProtocol() + partitionName;
+ proxyFamilyName = ((StatefulContainer) container).getDeploymentQualifiedName() + locator.getProtocol() + partitionName;
HAPartition partition = (HAPartition) container.getInitialContext().lookup("/HAPartition/" + partitionName);
hatarget = new HATarget(partition, proxyFamilyName, locator, HATarget.ENABLE_INVOCATIONS);
ClusteringTargetsRepository.initTarget(proxyFamilyName, hatarget.getReplicants());
@@ -105,7 +113,12 @@
lbPolicy = (LoadBalancePolicy) clustered.loadBalancePolicy().newInstance();
}
wrapper = new FamilyWrapper(proxyFamilyName, hatarget.getReplicants());
+
+ this.drm = partition.getDistributedReplicantManager();
+ drm.registerListener(proxyFamilyName, this);
+
super.start();
+
Class[] interfaces = {ProxyFactory.class};
String targetId = getTargetId();
Object factoryProxy = Remoting.createPojiProxy(targetId, interfaces, ProxyFactoryHelper.getClientBindUrl(binding));
@@ -136,6 +149,7 @@
String partitionName = ((StatefulContainer) container).getPartitionName();
Object[] args = {new StatefulClusteredProxy(containerId, stack.createInterceptors((Advisor) container, null),
wrapper, lbPolicy, partitionName)};
+
return proxyConstructor.newInstance(args);
}
catch (InstantiationException e)
@@ -165,6 +179,7 @@
{
Dispatcher.singleton.unregisterTarget(getTargetId());
hatarget.destroy();
+ drm.unregisterListener(proxyFamilyName, this);
((StatefulContainer) container).getClusterFamilies().remove(proxyFamilyName);
Util.unbind(container.getInitialContext(), jndiName + PROXY_FACTORY_NAME);
super.stop();
@@ -185,5 +200,21 @@
String partition = ((StatefulContainer) container).getPartitionName();
return container.getObjectName().getCanonicalName() + FACTORY_ATTRIBUTE + partition;
}
+
+ public synchronized void replicantsChanged (String key,
+ List newReplicants,
+ int newReplicantsViewId)
+ {
+ try
+ {
+ // Update the FamilyClusterInfo with the new targets
+ ArrayList targets = new ArrayList(newReplicants);
+ wrapper.get().updateClusterInfo(targets, newReplicantsViewId);
+ }
+ catch (Exception e)
+ {
+ log.error(e);
+ }
+ }
}
More information about the jboss-cvs-commits
mailing list