String secDomain = container.getSecurityManager().getSecurityDomain();
context.setValue(InvocationKey.SECURITY_DOMAIN, secDomain);
}
ClientContainer client = null;
EJBProxyFactoryContainer pfc = (EJBProxyFactoryContainer) container;
Class[] ifaces = {pfc.getHomeClass(), Class.forName("javax.ejb.Handle")};
if( includeIClientIface )
{
ifaces = new Class[] {IClientContainer.class, pfc.getHomeClass(),
Class.forName("javax.ejb.Handle")};
client = new ClientContainerEx(context);
}
else
{
client = new ClientContainer(context);
}
loadInterceptorChain(homeInterceptorClasses, client);
// Create the EJBHome
this.home = (EJBHome) Proxy.newProxyInstance(
// Class loader pointing to the right classes from deployment
pfc.getHomeClass().getClassLoader(),
// The classes we want to implement home and handle
ifaces,
// The home proxy as invocation handler
client);
// Create stateless session object
// Same instance is used for all objects
if(ejbMetaData.isStatelessSession() == true)
{
// Create a stack from the description (in the future) for now we hardcode it
context = new InvocationContext();
context.setObjectName(jmxNameHashInteger);
context.setValue(InvocationKey.JNDI_NAME, jndiBinding);
// The behavior for home proxying should be isolated in an interceptor FIXME
context.setInvoker(beanInvoker);
context.setInvokerProxyBinding(invokerMetaData.getName());
context.setValue(InvocationKey.EJB_HOME, home);
if(container.getSecurityManager() != null)
{
String secDomain = container.getSecurityManager().getSecurityDomain();
context.setValue(InvocationKey.SECURITY_DOMAIN, secDomain);
}
Class[] ssifaces = {pfc.getRemoteClass()};
if( includeIClientIface )
{
ssifaces = new Class[] {IClientContainer.class, pfc.getRemoteClass()};
client = new ClientContainerEx(context);
}
else
{
client = new ClientContainer(context);
}
loadInterceptorChain(beanInterceptorClasses, client);
this.statelessObject =
(EJBObject)Proxy.newProxyInstance(
// Correct CL
pfc.getRemoteClass().getClassLoader(),
// Interfaces
ssifaces,
// SLSB proxy as invocation handler
client
);
}
else
{
// this is faster than newProxyInstance
Class[] intfs = {pfc.getRemoteClass()};
if( this.includeIClientIface )
{
intfs = new Class[]{IClientContainer.class, pfc.getRemoteClass()};
}
Class proxyClass = Proxy.getProxyClass(pfc.getRemoteClass().getClassLoader(), intfs);
final Class[] constructorParams = {InvocationHandler.class};
proxyClassConstructor = proxyClass.getConstructor(constructorParams);
}