// corresponding jndi binder binds this jndi name to JNDI tree, the dependency will be marked as resolved
containerDependencyPolicy.addDependency(JNDIKernelRegistryPlugin.JNDI_DEPENDENCY_PREFIX + jndiName);
}
String dependencyBeanContainerName = dependencyBean.getContainerName();
// create a @Inject
AbstractInjectionValueMetaData containerDependencyInjection = new AbstractInjectionValueMetaData(dependencyBeanContainerName);
// add the @Inject to a list which will then be set on the container
containerDependencies.add(containerDependencyInjection);
}
// add the list of @Inject(s)
containerBMDBuilder.addPropertyMetaData("singletonDependsOn", containerDependencies);
}
logger.info("Installing container for EJB " + container.getEJBName());
if (containerDependencyPolicy instanceof MCDependencyPolicy)
{
MCDependencyPolicy policy = (MCDependencyPolicy) containerDependencyPolicy;
// depends
logger.info("with dependencies: ");
Set<DependencyMetaData> dependencies = policy.getDependencies();
if (dependencies != null && dependencies.isEmpty() == false)
{
for (DependencyMetaData dependency : dependencies)
{
logger.info(dependency.getDependency());
containerBMDBuilder.addDependency(dependency.getDependency());
}
}
// demands
logger.info("with demands: ");
Set<DemandMetaData> demands = policy.getDemands();
if (demands != null && demands.isEmpty() == false)
{
for (DemandMetaData demand : demands)
{
logger.info(demand.getDemand());
containerBMDBuilder.addDemand(demand.getDemand());
}
}
// supplies
logger.info("with supplies: ");
Set<SupplyMetaData> supplies = policy.getSupplies();
if (supplies != null && supplies.isEmpty() == false)
{
for (SupplyMetaData supply : supplies)
{
logger.info(supply.getSupply());
containerBMDBuilder.addSupply(supply.getSupply());
}
}
}
// Add inject metadata on container
String javaCompMCBeanName = this.getJavaEEComponentMCBeanName(unit);
AbstractInjectionValueMetaData javaCompInjectMetaData = new AbstractInjectionValueMetaData(javaCompMCBeanName);
// Too bad we have to know the field name. Need to do more research on MC to see if we can
// add property metadata based on type instead of field name.
containerBMDBuilder.addPropertyMetaData("javaComp", javaCompInjectMetaData);
// Inject the bean instantiator
final String appName = javaeeComponentInformer.getApplicationName(unit);
final String moduleName = javaeeComponentInformer.getModuleName(unit);
String javaeeSpecAppName = appName;
if (javaeeSpecAppName == null)
{
javaeeSpecAppName = moduleName;
}
final String beanInstantiatorMcName = BeanInstantiatorRegistration.getInstantiatorRegistrationName(
javaeeSpecAppName, moduleName, container.getEjbName());
containerBMDBuilder.addPropertyMetaData("beanInstantiator", new AbstractInjectionValueMetaData(beanInstantiatorMcName));
// TODO: This is an undocumented nonsense of MC
DeploymentUnit parentUnit = unit.getParent();
parentUnit.addAttachment(BeanMetaData.class + ":" + containerMCBeanName, containerBMDBuilder.getBeanMetaData());
unit.addAttachment(org.jboss.ejb3.EJBContainer.class + ":" + containerMCBeanName, container);