//ee6 specified ejb bindings in module, app, and global contexts
private void bindJava(BeanContext cdi, Class intrface, Reference ref, Bindings bindings, EnterpriseBeanInfo beanInfo) throws NamingException {
final ModuleContext module = cdi.getModuleContext();
final AppContext application = module.getAppContext();
Context moduleContext = module.getModuleJndiContext();
Context appContext = application.getAppJndiContext();
Context globalContext = application.getGlobalJndiContext();
String appName = application.isStandaloneModule() ? "" : application.getId() + "/";
String moduleName = cdi.getModuleName() + "/";
String beanName = cdi.getEjbName();
if (intrface != null) {
beanName = beanName + "!" + intrface.getName();
}
try {
String globalName = "global/" + appName + moduleName + beanName;
if (embeddedEjbContainerApi
&& !globalName.endsWith(".Comp") && !globalName.endsWith(".Comp!org.apache.openejb.BeanContext$Comp")
&& !(beanInfo instanceof ManagedBeanInfo && ((ManagedBeanInfo) beanInfo).hidden)) {
logger.info(String.format("Jndi(name=\"java:%s\")", globalName));
}
globalContext.bind(globalName, ref);
application.getBindings().put(globalName, ref);
bind("openejb/global/" + globalName, ref, bindings, beanInfo, intrface);
} catch (NameAlreadyBoundException e) {
//one interface in more than one role (e.g. both Local and Remote
return;
}
appContext.bind("app/" + moduleName + beanName, ref);
application.getBindings().put("app/" + moduleName + beanName, ref);
moduleContext.bind("module/" + beanName, ref);
application.getBindings().put("module/" + beanName, ref);
}