if (log.isTraceEnabled())
log.trace(name + " has dependencies: " + depends);
for (String iDependOn : depends)
{
ServiceDependencyMetaData sdmd = new ServiceDependencyMetaData();
sdmd.setIDependOn(iDependOn);
dependencies.add(sdmd);
}
}
// SwitchBoard
Barrier switchBoard = unit.getAttachment(Barrier.class);
if (switchBoard != null)
{
// Setup switchboard dependency on the deployment
ServiceDependencyMetaData switchBoardDependency = new AnyStateServiceDependencyMetaData(switchBoard.getId(), ControllerState.START, ControllerState.INSTALLED);
dependencies.add(switchBoardDependency);
log.debug("Added switchboard dependency: " + switchBoard.getId() + " for web module: " + name);
}
// Injection Manager
InjectionManager injectionManager = unit.getAttachment(InjectionManager.class);
if (injectionManager != null)
{
// set the InjectionManager on the deployment
deployment.setInjectionManager(injectionManager);
// Setup the Injector
Environment webEnvironment = metaData.getJndiEnvironmentRefsGroup();
if (webEnvironment != null)
{
// convert JBMETA metadata to jboss-injection specific metadata
JndiEnvironmentRefsGroup jndiEnvironment = new JndiEnvironmentImpl(webEnvironment, unit.getClassLoader());
// For optimization, we'll create an Injector only if there's atleast one InjectionTarget
if (this.hasInjectionTargets(jndiEnvironment))
{
// create the injector
EEInjector eeInjector = new EEInjector(jndiEnvironment);
// add the injector the injection manager
injectionManager.addInjector(eeInjector);
// Deploy the Injector as a MC bean (so that the fully populated naming context (obtained via the SwitchBoard
// Barrier) gets injected.
String injectorMCBeanName = this.getInjectorMCBeanName(unit);
BeanMetaData injectorBMD = this.createInjectorBMD(injectorMCBeanName, eeInjector, switchBoard);
unit.addAttachment(BeanMetaData.class + ":" + injectorMCBeanName, injectorBMD);
// Add the Injector dependency on the deployment (so that the DU doesn't
// get started till the Injector is available)
ServiceDependencyMetaData injectorDepdendency = new ServiceDependencyMetaData();
injectorDepdendency.setIDependOn(injectorMCBeanName);
dependencies.add(injectorDepdendency);
log.debug("Added Injector dependency: " + injectorMCBeanName + " for web module: " + name);
}
}
}
// TODO: We haven't yet integrated PC and EJB reference providers in SwitchBoard.
// The following sections will be removed after the RPs are made available
// JBAS-6795 Add dependency on PersistenceContext references
PersistenceContextReferencesMetaData pcRefs = metaData.getPersistenceContextRefs();
if (pcRefs != null)
{
for (PersistenceContextReferenceMetaData pcRef : metaData.getPersistenceContextRefs())
{
// TODO: this is a duplication of the logic in PersistenceContextHandler
String persistenceUnitName = pcRef.getPersistenceUnitName();
String beanName = persistenceUnitDependencyResolver.resolvePersistenceUnitSupplier(unit, persistenceUnitName);
ServiceDependencyMetaData sdmd = new ServiceDependencyMetaData();
sdmd.setIDependOn(beanName);
dependencies.add(sdmd);
}
}
webModule.setDependencies(dependencies);