catch (NamingException ne)
{
throw new RuntimeException("Could not create jndi context for jndi binders", ne);
}
ProxyFactory proxyFactory = new ReflectProxyFactory();
Interceptor[] clientInterceptors = this.getRemoteClientInterceptors(container);
Set<Class<?>> allRemoteinterfaces = new HashSet<Class<?>>();
for (String businessRemote : businessRemotes)
{
try
{
Class<?> businessRemoteIntf = unit.getClassLoader().loadClass(businessRemote);
allRemoteinterfaces.add(businessRemoteIntf);
InvocationHandler invocationHandler = new SingletonBeanRemoteInvocationHandler(containerRegistryKey, containerGUID,
defaultInvokerLocatorURL, clientInterceptors, businessRemote);
// time to create a proxy
Object proxy = proxyFactory.createProxy(new Class<?>[]
{businessRemoteIntf}, invocationHandler);
// bind to jndi
String jndiName = jndiNameResolver.resolveJNDIName(sessionBean, businessRemote);
JNDIBinderImpl jndiBinder = new JNDIBinderImpl(jndiCtx, jndiName, proxy);
String binderMCBeanName = JNDI_BINDER_MC_BEAN_PREFIX + jndiName;
BeanMetaData jndiBinderBMD = createBeanMetaData(binderMCBeanName, jndiBinder, container);
DeploymentUnit parentUnit = unit.getParent();
parentUnit.addAttachment(BeanMetaData.class + ":" + binderMCBeanName, jndiBinderBMD);
}
catch (ClassNotFoundException cnfe)
{
throw new RuntimeException("Could not load business remote interface " + businessRemote, cnfe);
}
}
// time to create a proxy
List<RemoteBindingMetaData> remoteBindings = sessionBean.getRemoteBindings();
if (remoteBindings == null || remoteBindings.isEmpty())
{
InvocationHandler invocationHandler = new SingletonBeanRemoteInvocationHandler(containerRegistryKey, containerGUID,
defaultInvokerLocatorURL, clientInterceptors);
String defaultRemoteJNDIName = jndiNameResolver.resolveRemoteBusinessDefaultJNDIName(sessionBean);
Object proxy = proxyFactory.createProxy(allRemoteinterfaces.toArray(new Class<?>[allRemoteinterfaces.size()]),
invocationHandler);
JNDIBinderImpl jndiBinder = new JNDIBinderImpl(jndiCtx, defaultRemoteJNDIName, proxy);
String binderMCBeanName = JNDI_BINDER_MC_BEAN_PREFIX + defaultRemoteJNDIName;
BeanMetaData jndiBinderBMD = createBeanMetaData(binderMCBeanName, jndiBinder, container);
DeploymentUnit parentUnit = unit.getParent();
parentUnit.addAttachment(BeanMetaData.class + ":" + binderMCBeanName, jndiBinderBMD);
}
else
{
for (RemoteBindingMetaData remoteBinding : remoteBindings)
{
String jndiName = remoteBinding.getJndiName();
// if not explicitly specified, then use the default jndi name
if (jndiName == null)
{
jndiName = jndiNameResolver.resolveRemoteBusinessDefaultJNDIName(sessionBean);
}
String invokerLocatorURL = getClientBindURL(remoteBinding);
InvocationHandler invocationHandler = new SingletonBeanRemoteInvocationHandler(containerRegistryKey, containerGUID,
invokerLocatorURL, clientInterceptors);
Object proxy = proxyFactory.createProxy(allRemoteinterfaces
.toArray(new Class<?>[allRemoteinterfaces.size()]), invocationHandler);
JNDIBinderImpl jndiBinder = new JNDIBinderImpl(jndiCtx, jndiName, proxy);
String binderMCBeanName = JNDI_BINDER_MC_BEAN_PREFIX + jndiName;
BeanMetaData jndiBinderBMD = createBeanMetaData(binderMCBeanName, jndiBinder, container);
DeploymentUnit parentUnit = unit.getParent();