{
// The unique id for this ejb in the deployment
String ejbCompID = prefix + "#" + bean.getEjbName();
//LegacyEjb3JndiPolicy policy = new LegacyEjb3JndiPolicy();
String jndiName = bean.determineJndiName();
ContainerDependencyMetaData cdmd = new ContainerDependencyMetaData(jndiName, bean.getEjbName(), vfsPath);
cdmd.setEjb3X(ejbMetaData.isEJB3x());
// TODO, this is a mess that should be simply from the metadata
//ClassLoader loader = unit.getClassLoader();
EjbDeploymentSummary unitSummary = getEjbDeploymentSummary(unit, bean);
cdmd.setUnitSummary(unitSummary);
endpointMap.put(ejbCompID, cdmd);
// debug info for the mappings each ejb has
ArrayList<String> mappings = new ArrayList<String>();
// Alternate mappings
String ejbNameKey = "ejb/" + bean.getEjbName();
if(endpointAlternateMap.containsKey(ejbNameKey) == false)
{
endpointAlternateMap.put(ejbNameKey, ejbCompID);
mappings.add(ejbNameKey);
if(trace)
log.trace("mapEjbs, added alternate root ejb-name: "+ejbNameKey);
}
else
{
log.debug("Duplicate root ejb-name: "+ejbNameKey+" from: "+ejbCompID);
}
// Create mappings based on the bean business interfaces
if(bean instanceof JBossSessionBeanMetaData)
{
JBossSessionBeanMetaData sbean = (JBossSessionBeanMetaData) bean;
String ejbName = sbean.getEjbName();
SessionBeanJNDINameResolver sessionbeanJNDINameResolver = JNDIPolicyBasedJNDINameResolverFactory.getJNDINameResolver(sbean, this.defaultJNDIBindingPolicy);
// home
if(sbean.getHome() != null && sbean.getHome().length() > 0)
{
String remoteHomeJNDIName = sessionbeanJNDINameResolver.resolveRemoteHomeJNDIName(sbean);
cdmd.addJndiName(remoteHomeJNDIName);
// Add ejb/vfsPath@iface
String home = sbean.getHome();
String ifacePath = prefix + "@" + home;
if(endpointAlternateMap.containsKey(ifacePath))
log.debug(ejbName+" duplicates home: "+home+", existing: "+endpointAlternateMap.get(ifacePath));
else
{
endpointAlternateMap.put(ifacePath, ejbCompID);
mappings.add(ifacePath);
if(trace)
log.trace("mapEjbs, local-home: "+ifacePath+", ejbName: "+ejbName);
}
// Add ejb/iface
ifacePath = "ejb@" + home;
if(endpointMap.containsKey(ifacePath))
{
// TODO: may need to track the duplicates to create an error
log.debug(ejbName+" duplicates home: "+home+", existing: "+endpointMap.get(ifacePath));
}
else
{
endpointAlternateMap.put(ifacePath, ejbCompID);
mappings.add(ifacePath);
if(trace)
log.trace("mapEjbs, home: "+ifacePath+", ejbName: "+ejbName);
}
}
// remote
if(sbean.getRemote() != null && sbean.getRemote().length() > 0)
{
// Add ejb/vfsPath@iface
String remote = sbean.getRemote();
String remoteJndiName = sessionbeanJNDINameResolver.resolveJNDIName(sbean, remote);
cdmd.addJndiName(remoteJndiName);
String ifacePath = prefix + "@" + remote;
if(endpointAlternateMap.containsKey(ifacePath))
log.debug(ejbName+" duplicates remote: "+remote+", existing: "+endpointAlternateMap.get(ifacePath));
else
{
endpointAlternateMap.put(ifacePath, ejbCompID);
mappings.add(ifacePath);
if(trace)
log.trace("mapEjbs, remote: "+ifacePath+", ejbName: "+ejbName);
}
// Add ejb/iface
ifacePath = "ejb@" + remote;
if(endpointMap.containsKey(ifacePath))
{
// TODO: may need to track the duplicates to create an error
log.debug(ejbName+" duplicates remote: "+remote+", existing: "+endpointMap.get(ifacePath));
}
else
{
endpointAlternateMap.put(ifacePath, ejbCompID);
mappings.add(ifacePath);
if(trace)
log.trace("mapEjbs, local: "+ifacePath+", ejbName: "+ejbName);
}
}
// local-home
if(sbean.getLocalHome() != null && sbean.getLocalHome().length() > 0)
{
String localHomeJNDIName = sessionbeanJNDINameResolver.resolveLocalHomeJNDIName(sbean);
cdmd.addJndiName(localHomeJNDIName);
// Add ejb/vfsPath@iface
String local = sbean.getLocalHome();
String ifacePath = prefix + "@" + local;
if(endpointAlternateMap.containsKey(ifacePath))
log.debug(ejbName+" duplicates local-home: "+local+", existing: "+endpointAlternateMap.get(ifacePath));
else
{
endpointAlternateMap.put(ifacePath, ejbCompID);
mappings.add(ifacePath);
if(trace)
log.trace("mapEjbs, local-home: "+ifacePath+", ejbName: "+ejbName);
}
// Add ejb/iface
ifacePath = "ejb@" + local;
if(endpointMap.containsKey(ifacePath))
{
// TODO: may need to track the duplicates to create an error
log.debug(ejbName+" duplicates local-home: "+local+", existing: "+endpointMap.get(ifacePath));
}
else
{
endpointAlternateMap.put(ifacePath, ejbCompID);
mappings.add(ifacePath);
if(trace)
log.trace("mapEjbs, local-home: "+ifacePath+", ejbName: "+ejbName);
}
}
// local
if(sbean.getLocal() != null && sbean.getLocal().length() > 0)
{
// Add ejb/vfsPath@iface
String local = sbean.getLocal();
String localJndiName = sessionbeanJNDINameResolver.resolveJNDIName(sbean, local);
cdmd.addJndiName(localJndiName);
String ifacePath = prefix + "@" + local;
if(endpointAlternateMap.containsKey(ifacePath))
log.debug(ejbName+" duplicates local: "+local+", existing: "+endpointAlternateMap.get(ifacePath));
else
{
endpointAlternateMap.put(ifacePath, ejbCompID);
mappings.add(ifacePath);
if(trace)
log.trace("mapEjbs, local: "+ifacePath+", ejbName: "+ejbName);
}
// Add ejb/iface
ifacePath = "ejb@" + local;
if(endpointMap.containsKey(ifacePath))
{
// TODO: may need to track the duplicates to create an error
log.debug(ejbName+" duplicates local: "+local+", existing: "+endpointMap.get(ifacePath));
}
else
{
endpointAlternateMap.put(ifacePath, ejbCompID);
mappings.add(ifacePath);
if(trace)
log.trace("mapEjbs, local: "+ifacePath+", ejbName: "+ejbName);
}
}
BusinessLocalsMetaData locals = sbean.getBusinessLocals();
if(locals != null && locals.size() > 0)
{
String defaultLocalBusinessJNDIName = sessionbeanJNDINameResolver.resolveLocalBusinessDefaultJNDIName(sbean);
cdmd.addJndiName(defaultLocalBusinessJNDIName);
for(String local : locals)
{
// Add a targeted jndi name
String localBusinessJNDIName = sessionbeanJNDINameResolver.resolveJNDIName(sbean, local);
cdmd.addJndiName(localBusinessJNDIName);
// Add ejb/vfsPath@iface
String ifacePath = prefix + "@" + local;
if(endpointAlternateMap.containsKey(ifacePath))
log.debug(ejbName+" duplicates business local: "+local+", existing: "+endpointAlternateMap.get(ifacePath));
else
{
endpointAlternateMap.put(ifacePath, ejbCompID);
mappings.add(ifacePath);
if(trace)
log.trace("mapEjbs, business-local: "+ifacePath+", ejbName: "+ejbName);
}
// Add ejb/iface
ifacePath = "ejb@" + local;
if(endpointMap.containsKey(ifacePath))
{
// TODO: may need to track the duplicates to create an error
log.debug(ejbName+" duplicates business-local: "+local+", existing: "+endpointMap.get(ifacePath));
}
else
{
endpointAlternateMap.put(ifacePath, ejbCompID);
mappings.add(ifacePath);
if(trace)
log.trace("mapEjbs, business-local: "+ifacePath+", ejbName: "+ejbName);
}
}
}
BusinessRemotesMetaData remotes = sbean.getBusinessRemotes();
if(remotes != null && remotes.size() > 0)
{
String defaultRemoteBusinessJNDIName = sessionbeanJNDINameResolver.resolveRemoteBusinessDefaultJNDIName(sbean);
cdmd.addJndiName(defaultRemoteBusinessJNDIName);
for(String remote : remotes)
{
// Add a targeted jndi name
String remoteBusinessJNDIName = sessionbeanJNDINameResolver.resolveJNDIName(sbean, remote);
cdmd.addJndiName(remoteBusinessJNDIName);
// Add ejb/vfsPath/iface
String ifacePath = prefix + "@" + remote;
if(endpointAlternateMap.containsKey(ifacePath))
log.debug(ejbName+" duplicates business remote: "+remote+", existing: "+endpointAlternateMap.get(ifacePath));
else
{
endpointAlternateMap.put(ifacePath, ejbCompID);
mappings.add(ifacePath);
if(trace)
log.trace("mapEjbs, business-remote: "+ifacePath+", ejbName: "+ejbName);
}
// Add ejb/iface
ifacePath = "ejb@" + remote;
if(endpointMap.containsKey(ifacePath))
log.debug(ejbName+" duplicates business-remote: "+remote+", existing: "+endpointMap.get(ifacePath));
else
{
endpointAlternateMap.put(ifacePath, ejbCompID);
mappings.add(ifacePath);
if(trace)
log.trace("mapEjbs, business-remote: "+ifacePath+", ejbName: "+ejbName);
}
}
}
// Map no-interface view of EJB3.1 bean
if (sbean.getJBossMetaData().isEJB31() && sbean instanceof JBossSessionBean31MetaData)
{
JBossSessionBean31MetaData sessionBean31 = (JBossSessionBean31MetaData) sbean;
if (sessionBean31.isNoInterfaceBean())
{
// TODO: The rest of the stuff is way too ugly, but that's what is being
// done for maintaining per business interface endpoint mappings. So let's
// for the time being, do the same for no-interface view endpoint mappings.
String ejbClassName = sessionBean31.getEjbClass();
// add to end point mappings
String ifacePath = prefix + "@" + ejbClassName;
if(endpointAlternateMap.containsKey(ifacePath))
{
log.debug(ejbName + " duplicates nointerface bean: " + ejbClassName
+ ", existing: " + endpointAlternateMap.get(ifacePath));
}
else
{
endpointAlternateMap.put(ifacePath, ejbCompID);
mappings.add(ifacePath);
if(trace)
{
log.trace("mapEjbs, nointerface bean: " + ifacePath + ", ejbName: " + ejbName);
}
}
// Add ejb/iface
ifacePath = "ejb@" + ejbClassName;
if(endpointMap.containsKey(ifacePath))
{
// TODO: may need to track the duplicates to create an error
log.debug(ejbName + " duplicates nointerface bean : " + ejbClassName + ", existing: "
+ endpointMap.get(ifacePath));
}
else
{
endpointAlternateMap.put(ifacePath, ejbCompID);
mappings.add(ifacePath);
if(trace)
log.trace("mapEjbs, nointerface bean : " + ifacePath + ", ejbName: " + ejbName);
}
}
}
if(trace)
log.trace("mapEjbs: "+ejbCompID+", mappings: "+mappings);
}
else if(bean instanceof JBossEntityBeanMetaData)
{
JBossEntityBeanMetaData ebean = (JBossEntityBeanMetaData) bean;
EntityBeanJNDINameResolver entityBeanJNDINameResolver = JNDIPolicyBasedJNDINameResolverFactory.getJNDINameResolver(ebean, this.defaultJNDIBindingPolicy);
String ejbName = ebean.getEjbName();
// home
if(ebean.getHome() != null && ebean.getHome().length() > 0)
{
String homeJNDIName = entityBeanJNDINameResolver.resolveRemoteHomeJNDIName(ebean);
cdmd.addJndiName(homeJNDIName);
// Add ejb/vfsPath@iface
String home = ebean.getHome();
String ifacePath = prefix + "@" + home;
if(endpointAlternateMap.containsKey(ifacePath))
log.debug(ejbName+" duplicates home: "+home+", existing: "+endpointAlternateMap.get(ifacePath));
else
{
endpointAlternateMap.put(ifacePath, ejbCompID);
mappings.add(ifacePath);
if(trace)
log.trace("mapEjbs, local-home: "+ifacePath+", ejbName: "+ejbName);
}
// Add ejb/iface
ifacePath = "ejb@" + home;
if(endpointMap.containsKey(ifacePath))
{
// TODO: may need to track the duplicates to create an error
log.debug(ejbName+" duplicates home: "+home+", existing: "+endpointMap.get(ifacePath));
}
else
{
endpointAlternateMap.put(ifacePath, ejbCompID);
mappings.add(ifacePath);
if(trace)
log.trace("mapEjbs, home: "+ifacePath+", ejbName: "+ejbName);
}
}
// remote
if(ebean.getRemote() != null && ebean.getRemote().length() > 0)
{
// Add ejb/vfsPath@iface
String remote = ebean.getRemote();
String ifacePath = prefix + "@" + remote;
if(endpointAlternateMap.containsKey(ifacePath))
log.debug(ejbName+" duplicates remote: "+remote+", existing: "+endpointAlternateMap.get(ifacePath));
else
{
endpointAlternateMap.put(ifacePath, ejbCompID);
mappings.add(ifacePath);
if(trace)
log.trace("mapEjbs, remote: "+ifacePath+", ejbName: "+ejbName);
}
// Add ejb/iface
ifacePath = "ejb@" + remote;
if(endpointMap.containsKey(ifacePath))
{
// TODO: may need to track the duplicates to create an error
log.debug(ejbName+" duplicates remote: "+remote+", existing: "+endpointMap.get(ifacePath));
}
else
{
endpointAlternateMap.put(ifacePath, ejbCompID);
mappings.add(ifacePath);
if(trace)
log.trace("mapEjbs, local: "+ifacePath+", ejbName: "+ejbName);
}
}
// local-home
if(ebean.getLocalHome() != null && ebean.getLocalHome().length() > 0)
{
String localHomeJNDIName = entityBeanJNDINameResolver.resolveLocalHomeJNDIName(ebean);
cdmd.addJndiName(localHomeJNDIName);
// Add ejb/vfsPath@iface
String local = ebean.getLocalHome();
String ifacePath = prefix + "@" + local;
if(endpointAlternateMap.containsKey(ifacePath))
log.debug(ejbName+" duplicates local-home: "+local+", existing: "+endpointAlternateMap.get(ifacePath));