{
// 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();
// home
if(sbean.getHome() != null && sbean.getHome().length() > 0)
{
cdmd.addJndiName(sbean.determineResolvedJndiName(KnownInterfaces.HOME));
// 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 = sbean.determineJndiName();
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)
{
cdmd.addJndiName(sbean.determineResolvedJndiName(KnownInterfaces.LOCAL_HOME));
// 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 = sbean.determineLocalJndiName();
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 localBaseJndiName = sbean.determineResolvedJndiName(KnownInterfaces.LOCAL);
cdmd.addJndiName(localBaseJndiName);
for(String local : locals)
{
// Add a targeted jndi name
String localJndiName = sbean.determineResolvedJndiName(local);
cdmd.addJndiName(localJndiName);
// 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 remoteBaseJndiName = sbean.determineResolvedJndiName(KnownInterfaces.REMOTE);
cdmd.addJndiName(remoteBaseJndiName);
for(String remote : remotes)
{
// Add a targeted jndi name
String remoteJndiName = sbean.determineResolvedJndiName(remote);
cdmd.addJndiName(remoteJndiName);
// 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);
}
}
}
if(trace)
log.trace("mapEjbs: "+ejbCompID+", mappings: "+mappings);
}
else if(bean instanceof JBossEntityBeanMetaData)
{
JBossEntityBeanMetaData ebean = (JBossEntityBeanMetaData) bean;
String ejbName = ebean.getEjbName();
// home
if(ebean.getHome() != null && ebean.getHome().length() > 0)
{
cdmd.addJndiName(ebean.determineResolvedJndiName(KnownInterfaces.HOME));
// 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)
{
cdmd.addJndiName(ebean.determineResolvedJndiName(KnownInterfaces.LOCAL_HOME));
// 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));