}
Map<String, EjbDeployment> deployments = openejbJar.getDeploymentsByEjbName();
for (EnterpriseBean bean : ejbModule.getEjbJar().getEnterpriseBeans()) {
EjbDeployment ejbDeployment = deployments.get(bean.getEjbName());
if (ejbDeployment == null) {
throw new OpenEJBException("No ejb deployment found for ejb " + bean.getEjbName());
}
Class<? extends ContainerInfo> containerInfoType = ConfigurationFactory.getContainerInfoType(getType(bean));
if (ejbDeployment.getContainerId() == null && !skipMdb(bean)) {
String containerId = getUsableContainer(containerInfoType, bean, appResources);
if (containerId == null){
containerId = createContainer(containerInfoType, ejbDeployment, bean);
}
ejbDeployment.setContainerId(containerId);
}
// create the container if it doesn't exist
List<String> containerIds = configFactory.getContainerIds();
containerIds.addAll(appResources.getContainerIds());
if (!containerIds.contains(ejbDeployment.getContainerId()) && !skipMdb(bean)) {
createContainer(containerInfoType, ejbDeployment, bean);
}
// Resource reference
for (ResourceRef ref : bean.getResourceRef()) {
processResourceRef(ref, ejbDeployment, appResources);
}
// Resource env reference
for (JndiReference ref : bean.getResourceEnvRef()) {
processResourceEnvRef(ref, ejbDeployment, appResources);
}
// Message destination reference
for (MessageDestinationRef ref : bean.getMessageDestinationRef()) {
processResourceEnvRef(ref, ejbDeployment, appResources);
}
// mdb message destination id
if (autoCreateResources && bean instanceof MessageDrivenBean) {
MessageDrivenBean mdb = (MessageDrivenBean) bean;
ResourceLink resourceLink = ejbDeployment.getResourceLink("openejb/destination");
if (resourceLink != null) {
try {
String destinationId = getResourceEnvId(bean.getEjbName(), resourceLink.getResId(), mdb.getMessageDestinationType(), appResources);
resourceLink.setResId(destinationId);
} catch (OpenEJBException e) {
// The MDB doesn't need the auto configured "openejb/destination" env entry
ejbDeployment.removeResourceLink("openejb/destination");
}
}
}
}