Methods Summary |
---|
public java.lang.Object | createProxy()
try
{
Object containerId = container.getObjectName().getCanonicalName();
String stackName = "ClusteredStatefulSessionClientInterceptors";
if (binding.interceptorStack() != null && !binding.interceptorStack().equals(""))
{
stackName = binding.interceptorStack();
}
AdviceStack stack = AspectManager.instance().getAdviceStack(stackName);
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)
{
throw new RuntimeException(e); //To change body of catch statement use Options | File Templates.
}
catch (IllegalAccessException e)
{
throw new RuntimeException(e); //To change body of catch statement use Options | File Templates.
}
catch (IllegalArgumentException e)
{
throw new RuntimeException(e); //To change body of catch statement use Options | File Templates.
}
catch (InvocationTargetException e)
{
throw new RuntimeException(e.getTargetException()); //To change body of catch statement use Options | File Templates.
}
|
public java.lang.Object | createProxy(java.lang.Object id)
throw new RuntimeException("NYI");
|
protected StatefulHandleImpl | getHandle()
StatefulHandleImpl handle = new StatefulHandleImpl();
RemoteBinding remoteBinding = (RemoteBinding)advisor.resolveAnnotation(RemoteBinding.class);
if (remoteBinding != null)
handle.jndiName = remoteBinding.jndiBinding();
return handle;
|
protected java.lang.Class[] | getInterfaces()
Class[] remoteInterfaces = ProxyFactoryHelper.getRemoteInterfaces(container);
Class[] interfaces = new Class[remoteInterfaces.length + 1];
System.arraycopy(remoteInterfaces, 0, interfaces, 0, remoteInterfaces.length);
interfaces[remoteInterfaces.length] = JBossProxy.class;
return interfaces;
|
protected java.lang.String | getTargetId()
assert jndiName != null : "jndiName is null";
String partition = ((StatefulContainer) container).getPartitionName();
return jndiName + PROXY_FACTORY_NAME + "@" + partition;
|
protected void | initializeJndiName()
jndiName = ProxyFactoryHelper.getRemoteJndiName(container, binding);
|
public synchronized void | replicantsChanged(java.lang.String key, java.util.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);
}
|
public void | setRemoteBinding(org.jboss.annotation.ejb.RemoteBinding binding)
this.binding = binding;
|
public void | start()
String clientBindUrl = ProxyFactoryHelper.getClientBindUrl(binding);
locator = new InvokerLocator(clientBindUrl);
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 = ((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());
((StatefulContainer) container).getClusterFamilies().put(proxyFamilyName, hatarget);
if (clustered.loadBalancePolicy() == null || clustered.loadBalancePolicy().equals(LoadBalancePolicy.class))
{
lbPolicy = new FirstAvailable();
}
else
{
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));
try
{
Util.rebind(container.getInitialContext(), jndiName + PROXY_FACTORY_NAME, factoryProxy);
} catch (NamingException e)
{
NamingException namingException = new NamingException("Could not bind stateful cluster proxy with ejb name " + container.getEjbName() + " into JNDI under jndiName: " + container.getInitialContext().getNameInNamespace() + "/" + jndiName + PROXY_FACTORY_NAME);
namingException.setRootCause(e);
throw namingException;
}
assert !Dispatcher.singleton.isRegistered(targetId) : targetId + " is already registered";
Dispatcher.singleton.registerTarget(targetId, this);
|
public void | stop()
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();
|