return container;
}
public EJBContainer getEjbContainer(Class businessIntf) throws NameNotFoundException
{
EJBContainer rtnContainer = null;
// search in deployment first
rtnContainer = searchForEjbContainerInternally(businessIntf);
if (rtnContainer != null) return rtnContainer;
// search in EAR
String jarName = null;
if (deploymentScope != null)
{
for (Ejb3Deployment deployment : deploymentScope.getEjbDeployments())
{
EJBContainer newContainer = getEjbContainer(deployment, businessIntf);
if (rtnContainer == newContainer) continue; // don't check self
if (rtnContainer != null && newContainer != null)
{
throw new NameNotFoundException("duplicated in .ear within " + jarName +
" and " + deployment.getDeploymentUnit().getShortName());
}
if (newContainer != null)
{
rtnContainer = newContainer;
jarName = deployment.getDeploymentUnit().getShortName();
}
}
}
if (rtnContainer != null)
{
return rtnContainer;
}
// search everywhere
Iterator containers = Ejb3Registry.getContainers().iterator();
while (containers.hasNext())
{
Container container = (Container)containers.next();
EJBContainer ejbContainer = (EJBContainer) container;
if (ejbContainer == rtnContainer) continue;
if (ProxyFactoryHelper.publishesInterface(container, businessIntf))
{
if (rtnContainer != null)
{
throw new NameNotFoundException("duplicated in " + ejbContainer.getDeployment().getDeploymentUnit().getShortName()
+ " and " + jarName);
}
rtnContainer = ejbContainer;
jarName = ejbContainer.getDeployment().getDeploymentUnit().getShortName();
}
}
if (rtnContainer != null) return rtnContainer;
throw new NameNotFoundException("not used by any EJBs");
}