Methods Summary |
---|
protected boolean | bindHomeAndBusinessTogether(StatefulContainer container)
return ProxyFactoryHelper.getHomeJndiName(container).equals(ProxyFactoryHelper.getRemoteJndiName(container));
|
public java.lang.Object | createHomeProxy(java.lang.Class homeInterface)
try
{
Object containerId = container.getObjectName().getCanonicalName();
String stackName = "StatefulSessionClientInterceptors";
if (binding.interceptorStack() != null && !binding.interceptorStack().equals(""))
{
stackName = binding.interceptorStack();
}
AdviceStack stack = AspectManager.instance().getAdviceStack(stackName);
if (stack == null) throw new RuntimeException("unable to find interceptor stack: " + stackName);
StatefulHomeRemoteProxy proxy = new StatefulHomeRemoteProxy(containerId, stack.createInterceptors((Advisor) container, null), locator);
setEjb21Objects(proxy);
Class[] intfs = {homeInterface};
return java.lang.reflect.Proxy.newProxyInstance(container.getBeanClass().getClassLoader(), intfs, proxy);
}
catch (IllegalArgumentException e)
{
throw new RuntimeException(e); //To change body of catch statement use Options | File Templates.
}
|
protected java.lang.Object | createPojiProxy(java.lang.Object oid, java.lang.Class[] interfaces, java.lang.String uri)
InvokerLocator locator = new InvokerLocator(uri);
Interceptor[] interceptors = {IsLocalProxyFactoryInterceptor.singleton, InvokeRemoteInterceptor.singleton};
PojiProxy proxy = new PojiProxy(oid, locator, interceptors);
return Proxy.newProxyInstance(interfaces[0].getClassLoader(), interfaces, proxy);
|
public java.lang.Object | createProxy(java.lang.Object id)
try
{
Object containerId = container.getObjectName().getCanonicalName();
String stackName = "StatefulSessionClientInterceptors";
if (binding.interceptorStack() != null && !binding.interceptorStack().equals(""))
{
stackName = binding.interceptorStack();
}
AdviceStack stack = AspectManager.instance().getAdviceStack(stackName);
StatefulRemoteProxy proxy = new StatefulRemoteProxy(containerId, stack.createInterceptors((Advisor) container, null), locator, id);
setEjb21Objects(proxy);
Object[] args = {proxy};
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()
try
{
Object containerId = container.getObjectName().getCanonicalName();
String stackName = "StatefulSessionClientInterceptors";
if (binding.interceptorStack() != null && !binding.interceptorStack().equals(""))
{
stackName = binding.interceptorStack();
}
AdviceStack stack = AspectManager.instance().getAdviceStack(stackName);
if (stack == null) throw new RuntimeException("unable to find interceptor stack: " + stackName);
StatefulRemoteProxy proxy = new StatefulRemoteProxy(containerId, stack.createInterceptors((Advisor) container, null), locator);
setEjb21Objects(proxy);
Object[] args = {proxy};
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.
}
|
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[] interfaces;
StatefulContainer statefulContainer = (StatefulContainer) container;
RemoteHome remoteHome = (RemoteHome) statefulContainer.resolveAnnotation(RemoteHome.class);
boolean bindTogether = false;
if (remoteHome != null && bindHomeAndBusinessTogether(statefulContainer))
bindTogether = true;
Class[] remoteInterfaces = ProxyFactoryHelper.getRemoteInterfaces(container);
if (bindTogether)
interfaces = new Class[remoteInterfaces.length + 3];
else
interfaces = new Class[remoteInterfaces.length + 2];
System.arraycopy(remoteInterfaces, 0, interfaces, 0, remoteInterfaces.length);
interfaces[remoteInterfaces.length] = JBossProxy.class;
interfaces[remoteInterfaces.length + 1] = javax.ejb.EJBObject.class;
if (bindTogether)
interfaces[remoteInterfaces.length + 2] = remoteHome.value();
return interfaces;
|
protected java.lang.String | getTargetId()
assert jndiName != null : "jndiName is null";
return jndiName + PROXY_FACTORY_NAME;
|
public void | init()
super.init();
String clientBindUrl = ProxyFactoryHelper.getClientBindUrl(binding);
locator = new InvokerLocator(clientBindUrl);
|
protected void | initializeJndiName()
jndiName = ProxyFactoryHelper.getRemoteJndiName(container, binding);
|
public void | setRemoteBinding(org.jboss.annotation.ejb.RemoteBinding binding)
this.binding = binding;
|
public void | start()
init();
super.start();
Class[] interfaces = {ProxyFactory.class};
String targetId = getTargetId();
Object factoryProxy = 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 remote 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);
StatefulContainer statefulContainer = (StatefulContainer) container;
RemoteHome remoteHome = (RemoteHome) statefulContainer.resolveAnnotation(RemoteHome.class);
if (remoteHome != null && !bindHomeAndBusinessTogether(statefulContainer))
{
Object homeProxy = createHomeProxy(remoteHome.value());
Util.rebind(container.getInitialContext(), ProxyFactoryHelper.getHomeJndiName(container), homeProxy);
}
|
public void | stop()
Util.unbind(container.getInitialContext(), jndiName + PROXY_FACTORY_NAME);
Dispatcher.singleton.unregisterTarget(getTargetId());
StatefulContainer statefulContainer = (StatefulContainer) container;
RemoteHome remoteHome = (RemoteHome) statefulContainer.resolveAnnotation(RemoteHome.class);
if (remoteHome != null && !bindHomeAndBusinessTogether(statefulContainer))
{
Util.unbind(container.getInitialContext(), ProxyFactoryHelper.getHomeJndiName(container));
}
super.stop();
|