StatefulClusteredProxypublic class StatefulClusteredProxy extends org.jboss.ejb3.remoting.BaseRemoteProxy InvocationHandler for a clustered SFSB proxy. |
Fields Summary |
---|
private static final long | serialVersionUID | private Object | id | protected org.jboss.aspects.remoting.FamilyWrapper | family | protected org.jboss.ha.framework.interfaces.LoadBalancePolicy | lbPolicy | org.jboss.aspects.asynch.AsynchProvider | provider | protected String | partitionName |
Constructors Summary |
---|
public StatefulClusteredProxy(Object containerId, org.jboss.aop.advice.Interceptor[] interceptors, org.jboss.aspects.remoting.FamilyWrapper family, org.jboss.ha.framework.interfaces.LoadBalancePolicy lb, String partitionName)
super(containerId, interceptors);
this.family = family;
this.lbPolicy = lb;
this.partitionName = partitionName;
| public StatefulClusteredProxy(org.jboss.aspects.asynch.AsynchProvider provider, Object containerId, org.jboss.aop.advice.Interceptor[] interceptors, org.jboss.aspects.remoting.FamilyWrapper family, org.jboss.ha.framework.interfaces.LoadBalancePolicy lb, String partitionName)
this(containerId, interceptors, family, lb, partitionName);
this.provider = provider;
| protected StatefulClusteredProxy()
|
Methods Summary |
---|
public java.lang.Object | getAsynchronousProxy(java.lang.Object proxy)
Class[] infs = proxy.getClass().getInterfaces();
if (!ProxyUtils.isAsynchronous(infs))
{
Class[] interfaces = ProxyUtils.addAsynchProviderInterface(infs);
AsynchMixin mixin = new AsynchMixin();
Interceptor[] newInterceptors = ProxyUtils.addAsynchProxyInterceptor(mixin, interceptors);
StatefulClusteredProxy handler = new StatefulClusteredProxy(mixin, containerId, newInterceptors, family, lbPolicy, partitionName);
return Proxy.newProxyInstance(Thread.currentThread().getContextClassLoader(), interfaces, handler);
}
//I was already asynchronous
return proxy;
| public java.lang.Object | invoke(java.lang.Object proxy, java.lang.reflect.Method method, java.lang.Object[] args)
if (method.getDeclaringClass() == AsynchProvider.class)
{
return provider.getFuture();
}
long hash = MethodHashing.calculateHash(method);
Object ret = ProxyUtils.handleCallLocally(hash, (JBossProxy) proxy, this, method, args);
if (ret != null)
{
return ret;
}
StatefulRemoteInvocation sri = new StatefulRemoteInvocation(interceptors, hash, method, method, null, id);
sri.setArguments(args);
sri.setInstanceResolver(metadata);
sri.getMetaData().addMetaData(Dispatcher.DISPATCHER, Dispatcher.OID, containerId, PayloadKey.AS_IS);
sri.getMetaData().addMetaData(ClusterConstants.CLUSTERED_REMOTING, ClusterConstants.CLUSTER_FAMILY_WRAPPER, family, PayloadKey.AS_IS);
sri.getMetaData().addMetaData(ClusterConstants.CLUSTERED_REMOTING, ClusterConstants.LOADBALANCE_POLICY, lbPolicy, PayloadKey.AS_IS);
sri.getMetaData().addMetaData(InvokeRemoteInterceptor.REMOTING, InvokeRemoteInterceptor.SUBSYSTEM, "AOP", PayloadKey.AS_IS);
sri.getMetaData().addMetaData(ClusteredIsLocalInterceptor.PARTITION_NAME, ClusteredIsLocalInterceptor.PARTITION_NAME, partitionName, PayloadKey.TRANSIENT);
if (provider != null)
{
sri.getMetaData().addMetaData(AsynchronousInterceptor.ASYNCH, AsynchronousInterceptor.INVOKE_ASYNCH, "YES", PayloadKey.AS_IS);
}
try
{
Object rtn = sri.invokeNext();
// if this is first invocation then container passes back actual ID
if (id == null)
{
id = sri.getResponseAttachment(StatefulConstants.NEW_ID);
}
return rtn;
}
catch (ForwardId forward)
{
// if this is first invocation then container passes back actual ID
// The ForwardId exception is needed if 1st operation throws an exception
id = forward.getId();
throw forward.getCause();
}
| public java.lang.String | toString()
if (id != null)
{
return containerId.toString() + ":" + id.toString();
}
else
{
//If the proxy has not been used yet, create a temporary id
GUID guid = new GUID();
return containerId.toString() + ":" + guid.toString();
}
|
|