catch (NamingException ne)
{
throw new RuntimeException("Could not create jndi context for jndi binders", ne);
}
ProxyFactory proxyFactory = new ReflectProxyFactory();
Interceptor[] clientInterceptors = this.getClientInterceptors(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,
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 = "<JNDIBinder><BusinessRemote:" + businessRemote + "><Bean:"
+ sessionBean.getEjbName() + "><Unit:" + unit.getName() + ">";
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,
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 = "<DefaultRemoteJNDIBinder><Bean:" + sessionBean.getEjbName() + "><Unit:"
+ unit.getName() + ">";
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,
invokerLocatorURL, clientInterceptors);
Object proxy = proxyFactory.createProxy(allRemoteinterfaces
.toArray(new Class<?>[allRemoteinterfaces.size()]), invocationHandler);
JNDIBinderImpl jndiBinder = new JNDIBinderImpl(jndiCtx, jndiName, proxy);
String binderMCBeanName = "<DefaultRemoteJNDIBinder><InvokerLocatorURL:" + invokerLocatorURL + "><Bean:"
+ sessionBean.getEjbName() + "><Unit:" + unit.getName() + ">";
BeanMetaData jndiBinderBMD = createBeanMetaData(binderMCBeanName, jndiBinder, container);