protected void setupInvokers() throws Exception {
String partitionName = container.getBeanMetaData().getClusterConfigMetaData().getPartitionName();
HAPartition partition = HAPartitionLocator.getHAPartitionLocator().getHAPartition(partitionName, null);
this.drm = partition.getDistributedReplicantManager ();
replicantName = jmxName.toString ();
ObjectName oname = new ObjectName(invokerMetaData.getInvokerMBean());
jrmp = (InvokerHA)Registry.lookup(oname);
if (jrmp == null)
throw new RuntimeException("home JRMPInvokerHA is null: " + oname);
target = new HATarget(partition, replicantName, jrmp.getStub (), HATarget.MAKE_INVOCATIONS_WAIT);
jrmp.registerBean(jmxName, target);
String clusterFamilyName = partitionName + "/" + jmxName + "/";
// make ABSOLUTLY sure we do register with the DRM AFTER the HATarget
// otherwise we will refresh the *old* home in JNDI (ie before the proxy
// is re-generated)
//
drm.registerListener (replicantName, this);
ClassLoader cl = Thread.currentThread().getContextClassLoader();
Class clazz;
LoadBalancePolicy policy;
clazz = cl.loadClass(container.getBeanMetaData().getClusterConfigMetaData().getHomeLoadBalancePolicy());
policy = (LoadBalancePolicy)clazz.newInstance();
homeInvoker = jrmp.createProxy(jmxName, policy, clusterFamilyName + "H");
// (Re-)Bind the home invoker in the JNDI naming space
InitialContext ctx = new InitialContext();
String homeName = jndiBinding + "-HomeInvoker";
log.debug("(re-)Binding Home invoker under: " + homeName);
Util.rebind(ctx,
// Jndi name
homeName,
// The home invoker
homeInvoker
);
clazz = cl.loadClass(container.getBeanMetaData().getClusterConfigMetaData().getBeanLoadBalancePolicy());
policy = (LoadBalancePolicy)clazz.newInstance();
beanInvoker = jrmp.createProxy(jmxName, policy, clusterFamilyName + "R");
// (Re-)Bind the remote invoker in the JNDI naming space
String beanName = jndiBinding + "-RemoteInvoker";
log.debug("(re-)Binding Remote invoker under: " + beanName);
Util.rebind(ctx,
// Jndi name
beanName,
// The bean invoker
beanInvoker
);
JRMPInvokerProxyHA.colocation.add(new Integer(jmxNameHash));
}
|