[jboss-cvs] JBossAS SVN: r62774 - trunk/ejb3/src/main/org/jboss/ejb3/stateless.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Thu May 3 00:05:15 EDT 2007
Author: bstansberry at jboss.com
Date: 2007-05-03 00:05:14 -0400 (Thu, 03 May 2007)
New Revision: 62774
Modified:
trunk/ejb3/src/main/org/jboss/ejb3/stateless/BaseStatelessProxyFactory.java
trunk/ejb3/src/main/org/jboss/ejb3/stateless/StatelessClusterProxyFactory.java
Log:
[EJBTHREE-948] Use deployment-qualified ejb name in FamilyClusterInfo.familyName
[EJBTHREE-949] Update FCI and refresh JNDI when cluster topology changes
Modified: trunk/ejb3/src/main/org/jboss/ejb3/stateless/BaseStatelessProxyFactory.java
===================================================================
--- trunk/ejb3/src/main/org/jboss/ejb3/stateless/BaseStatelessProxyFactory.java 2007-05-03 04:04:49 UTC (rev 62773)
+++ trunk/ejb3/src/main/org/jboss/ejb3/stateless/BaseStatelessProxyFactory.java 2007-05-03 04:05:14 UTC (rev 62774)
@@ -222,15 +222,7 @@
Object proxy = createProxy();
//describeClass(proxy.getClass());
- try
- {
- Util.rebind(container.getInitialContext(), jndiName, proxy);
- } catch (NamingException e)
- {
- NamingException namingException = new NamingException("Could not bind stateless proxy with ejb name " + container.getEjbName() + " into JNDI under jndiName: " + container.getInitialContext().getNameInNamespace() + "/" + jndiName);
- namingException.setRootCause(e);
- throw namingException;
- }
+ bindProxy(proxy);
}
public void stop() throws Exception
@@ -242,6 +234,20 @@
protected abstract void initializeJndiName();
+ protected void bindProxy(Object proxy) throws NamingException
+ {
+ try
+ {
+ log.debug("Binding proxy for " + container.getEjbName() + " in JNDI at " + jndiName);
+ Util.rebind(container.getInitialContext(), jndiName, proxy);
+ } catch (NamingException e)
+ {
+ NamingException namingException = new NamingException("Could not bind stateless proxy with ejb name " + container.getEjbName() + " into JNDI under jndiName: " + container.getInitialContext().getNameInNamespace() + "/" + jndiName);
+ namingException.setRootCause(e);
+ throw namingException;
+ }
+ }
+
public void setContainer(Container container)
{
this.container = container;
Modified: trunk/ejb3/src/main/org/jboss/ejb3/stateless/StatelessClusterProxyFactory.java
===================================================================
--- trunk/ejb3/src/main/org/jboss/ejb3/stateless/StatelessClusterProxyFactory.java 2007-05-03 04:04:49 UTC (rev 62773)
+++ trunk/ejb3/src/main/org/jboss/ejb3/stateless/StatelessClusterProxyFactory.java 2007-05-03 04:05:14 UTC (rev 62774)
@@ -22,6 +22,9 @@
package org.jboss.ejb3.stateless;
import java.lang.reflect.InvocationTargetException;
+import java.util.ArrayList;
+import java.util.List;
+
import org.jboss.annotation.ejb.Clustered;
import org.jboss.annotation.ejb.RemoteBinding;
import org.jboss.aop.Advisor;
@@ -33,10 +36,12 @@
import org.jboss.ejb3.remoting.RemoteProxyFactory;
import org.jboss.ejb3.stateful.StatefulContainer;
import org.jboss.ha.framework.interfaces.ClusteringTargetsRepository;
+import org.jboss.ha.framework.interfaces.DistributedReplicantManager;
import org.jboss.ha.framework.interfaces.HAPartition;
import org.jboss.ha.framework.interfaces.LoadBalancePolicy;
import org.jboss.ha.framework.interfaces.RandomRobin;
import org.jboss.ha.framework.server.HATarget;
+import org.jboss.logging.Logger;
import org.jboss.remoting.InvokerLocator;
@@ -46,14 +51,19 @@
* @author <a href="mailto:bill at jboss.org">Bill Burke</a>
* @version $Revision$
*/
-public class StatelessClusterProxyFactory extends BaseStatelessProxyFactory implements RemoteProxyFactory
+public class StatelessClusterProxyFactory extends BaseStatelessProxyFactory
+ implements RemoteProxyFactory, DistributedReplicantManager.ReplicantListener
{
+ private static final Logger log = Logger.getLogger(StatelessClusterProxyFactory.class);
+
private RemoteBinding binding;
private InvokerLocator locator;
+ private DistributedReplicantManager drm;
private HATarget hatarget;
private String proxyFamilyName;
private LoadBalancePolicy lbPolicy;
private FamilyWrapper wrapper;
+ private Object proxy;
public void setRemoteBinding(RemoteBinding binding)
{
@@ -81,7 +91,7 @@
Clustered clustered = (Clustered) advisor.resolveAnnotation(Clustered.class);
if (clustered == null) throw new RuntimeException("Could not find @Clustered annotation. Cannot deploy.");
String partitionName = ((StatelessContainer) container).getPartitionName();
- proxyFamilyName = container.getEjbName() + locator.getProtocol() + partitionName;
+ proxyFamilyName = ((StatelessContainer) 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());
@@ -95,13 +105,19 @@
lbPolicy = (LoadBalancePolicy) clustered.loadBalancePolicy().newInstance();
}
wrapper = new FamilyWrapper(proxyFamilyName, hatarget.getReplicants());
+
+ this.drm = partition.getDistributedReplicantManager();
+ drm.registerListener(proxyFamilyName, this);
+
super.start();
}
public void stop() throws Exception
{
super.stop();
+ proxy = null;
hatarget.destroy();
+ drm.unregisterListener(proxyFamilyName, this);
((StatelessContainer) container).getClusterFamilies().remove(proxyFamilyName);
}
@@ -121,8 +137,10 @@
return proxyConstructor.newInstance(args);
*/
String partitionName = ((StatelessContainer) container).getPartitionName();
- return constructProxy(new StatelessClusteredProxy(containerId, stack.createInterceptors((Advisor) container, null),
- wrapper, lbPolicy, partitionName));
+
+ proxy = constructProxy(new StatelessClusteredProxy(containerId, stack.createInterceptors((Advisor) container, null),
+ wrapper, lbPolicy, partitionName));
+ return proxy;
}
/*
catch (InstantiationException e)
@@ -153,4 +171,24 @@
return handle;
}
+
+ 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);
+
+ // Rebind the proxy as the old one has been serialized
+ if (proxy != null)
+ bindProxy(proxy);
+ }
+ catch (Exception e)
+ {
+ log.error(e);
+ }
+ }
}
More information about the jboss-cvs-commits
mailing list