// now create the bindings for each view under the java:global, java:app and java:module namespaces
for (String viewClassName : views) {
String globalJNDIName = globalJNDIBaseName + "!" + viewClassName;
final BindingDescription globalBinding = new BindingDescription(globalJNDIName);
globalBinding.setBindingType(viewClassName);
globalBinding.setReferenceSourceDescription(new ServiceBindingSourceDescription(baseServiceName.append("VIEW").append(viewClassName)));
// add the binding to the component description
sessionBean.addBinding(globalBinding);
logger.debug("Added java:global jndi binding at " + globalJNDIName + " for view: " + viewClassName + " of session bean: " + sessionBean.getEJBName());
// java:app bindings
String appJNDIName = appJNDIBaseName + "!" + viewClassName;
final BindingDescription appBinding = new BindingDescription(appJNDIName);
appBinding.setBindingType(viewClassName);
appBinding.setReferenceSourceDescription(new ServiceBindingSourceDescription(baseServiceName.append("VIEW").append(viewClassName)));
// add the binding to the component description
sessionBean.addBinding(appBinding);
logger.debug("Added java:app jndi binding at " + appJNDIName + " for view: " + viewClassName + " of session bean: " + sessionBean.getEJBName());
// java:module bindings
String moduleJNDIName = moduleJNDIBaseName + "!" + viewClassName;
final BindingDescription moduleBinding = new BindingDescription(moduleJNDIName);
moduleBinding.setBindingType(viewClassName);
moduleBinding.setReferenceSourceDescription(new ServiceBindingSourceDescription(baseServiceName.append("VIEW").append(viewClassName)));
// add the binding to the component description
sessionBean.addBinding(moduleBinding);
logger.debug("Added java:module jndi binding at " + moduleJNDIName + " for view: " + viewClassName + " of session bean: " + sessionBean.getEJBName());
}
// EJB3.1 spec, section 4.4.1 Global JNDI Access states:
// In addition to the previous requirements, if the bean exposes only one of the
// applicable client interfaces(or alternatively has only a no-interface view), the container
// registers an entry for that view with the following syntax :
//
// java:global[/<app-name>]/<module-name>/<bean-name>
//
// Note that this also applies to java:app and java:module bindings
// as can be seen by the examples in 4.4.2.1
if (views.size() == 1) {
final BindingDescription globalBinding = new BindingDescription(globalJNDIBaseName);
String viewClassName = views.iterator().next();
globalBinding.setBindingType(viewClassName);
globalBinding.setReferenceSourceDescription(new ServiceBindingSourceDescription(baseServiceName.append("VIEW").append(viewClassName)));
// add the binding to the component description
sessionBean.addBinding(globalBinding);
logger.debug("Added java:global jndi binding at " + globalJNDIBaseName + " for view: " + viewClassName + " of session bean: " + sessionBean.getEJBName());
// java:app bindings
final BindingDescription appBinding = new BindingDescription(appJNDIBaseName);
appBinding.setBindingType(viewClassName);
appBinding.setReferenceSourceDescription(new ServiceBindingSourceDescription(baseServiceName.append("VIEW").append(viewClassName)));
// add the binding to the component description
sessionBean.addBinding(appBinding);
logger.debug("Added java:app jndi binding at " + appJNDIBaseName + " for view: " + viewClassName + " of session bean: " + sessionBean.getEJBName());
// java:module bindings
final BindingDescription moduleBinding = new BindingDescription(moduleJNDIBaseName);
moduleBinding.setBindingType(viewClassName);
moduleBinding.setReferenceSourceDescription(new ServiceBindingSourceDescription(baseServiceName.append("VIEW").append(viewClassName)));
// add the binding to the component description
sessionBean.addBinding(moduleBinding);
logger.debug("Added java:module jndi binding at " + moduleJNDIBaseName + " for view: " + viewClassName + " of session bean: " + sessionBean.getEJBName());
}