return id;
}
}
public void bind(EjbJarInfo ejbJarInfo, DeploymentInfo deploymentInfo, EnterpriseBeanInfo beanInfo, JndiNameStrategy strategy) {
CoreDeploymentInfo deployment = (CoreDeploymentInfo) deploymentInfo;
Bindings bindings = new Bindings();
deployment.set(Bindings.class, bindings);
Object id = deployment.getDeploymentID();
try {
Class homeInterface = deployment.getHomeInterface();
if (homeInterface != null) {
ObjectReference ref = new ObjectReference(deployment.getEJBHome());
String name = strategy.getName(homeInterface, JndiNameStrategy.Interface.REMOTE_HOME);
bind("openejb/local/" + name, ref, bindings, beanInfo, homeInterface);
bind("openejb/remote/" + name, ref, bindings, beanInfo, homeInterface);
name = "openejb/Deployment/" + format(deployment.getDeploymentID(), deployment.getRemoteInterface().getName());
bind(name, ref, bindings, beanInfo, homeInterface);
name = "openejb/Deployment/" + format(deployment.getDeploymentID(), deployment.getRemoteInterface().getName(), InterfaceType.EJB_OBJECT);
bind(name, ref, bindings, beanInfo, homeInterface);
}
} catch (NamingException e) {
throw new RuntimeException("Unable to bind remote home interface for deployment " + id, e);
}
try {
Class localHomeInterface = deployment.getLocalHomeInterface();
if (localHomeInterface != null) {
ObjectReference ref = new ObjectReference(deployment.getEJBLocalHome());
String name = strategy.getName(deploymentInfo.getLocalHomeInterface(), JndiNameStrategy.Interface.LOCAL_HOME);
bind("openejb/local/" + name, ref, bindings, beanInfo, localHomeInterface);
name = "openejb/Deployment/" + format(deployment.getDeploymentID(), deployment.getLocalInterface().getName());
bind(name, ref, bindings, beanInfo, localHomeInterface);
name = "openejb/Deployment/" + format(deployment.getDeploymentID(), deployment.getLocalInterface().getName(), InterfaceType.EJB_LOCAL);
bind(name, ref, bindings, beanInfo, localHomeInterface);
}
} catch (NamingException e) {
throw new RuntimeException("Unable to bind local home interface for deployment " + id, e);
}
try {
List<Class> localInterfaces = deployment.getBusinessLocalInterfaces();
Class beanClass = deployment.getBeanClass();
for (Class interfce : deployment.getBusinessLocalInterfaces()) {
List<Class> interfaces = ProxyInterfaceResolver.getInterfaces(beanClass, interfce, localInterfaces);
DeploymentInfo.BusinessLocalHome home = deployment.getBusinessLocalHome(interfaces);
BusinessLocalReference ref = new BusinessLocalReference(home);
optionalBind(bindings, ref, "openejb/Deployment/" + format(deployment.getDeploymentID(), interfce.getName()));
String internalName = "openejb/Deployment/" + format(deployment.getDeploymentID(), interfce.getName(), InterfaceType.BUSINESS_LOCAL);
bind(internalName, ref, bindings, beanInfo, interfce);
String externalName = "openejb/local/" + strategy.getName(interfce, JndiNameStrategy.Interface.BUSINESS_LOCAL);
bind(externalName, ref, bindings, beanInfo, interfce);
}
} catch (NamingException e) {
throw new RuntimeException("Unable to bind business local interface for deployment " + id, e);
}
try {
List<Class> remoteInterfaces = deployment.getBusinessRemoteInterfaces();
Class beanClass = deployment.getBeanClass();
for (Class interfce : deployment.getBusinessRemoteInterfaces()) {
List<Class> interfaces = ProxyInterfaceResolver.getInterfaces(beanClass, interfce, remoteInterfaces);
DeploymentInfo.BusinessRemoteHome home = deployment.getBusinessRemoteHome(interfaces);
BusinessRemoteReference ref = new BusinessRemoteReference(home);
optionalBind(bindings, ref, "openejb/Deployment/" + format(deployment.getDeploymentID(), interfce.getName(), null));
String internalName = "openejb/Deployment/" + format(deployment.getDeploymentID(), interfce.getName(), InterfaceType.BUSINESS_REMOTE);
bind(internalName, ref, bindings, beanInfo, interfce);
String name = strategy.getName(interfce, JndiNameStrategy.Interface.BUSINESS_REMOTE);
bind("openejb/local/" + name, ref, bindings, beanInfo, interfce);
bind("openejb/remote/" + name, ref, bindings, beanInfo, interfce);
}
} catch (NamingException e) {
throw new RuntimeException("Unable to bind business remote deployment in jndi.", e);
}
try {
if (MessageListener.class.equals(deployment.getMdbInterface())) {
String destinationId = deployment.getDestinationId();
String jndiName = "openejb/Resource/" + destinationId;
Reference reference = new IntraVmJndiReference(jndiName);
String deploymentId = deployment.getDeploymentID().toString();
bind("openejb/local/" + deploymentId, reference, bindings, beanInfo, MessageListener.class);
bind("openejb/remote/" + deploymentId, reference, bindings, beanInfo, MessageListener.class);
}
} catch (NamingException e) {
throw new RuntimeException("Unable to bind mdb destination in jndi.", e);