protected void deployWebModule(DeploymentUnit unit, JBossWebMetaData metaData, AbstractWarDeployment deployment) throws Exception
{
log.debug("deployWebModule: " + unit.getName());
try
{
ServiceMetaData webModule = new ServiceMetaData();
String name = getObjectName(metaData);
ObjectName objectName = new ObjectName(name);
webModule.setObjectName(objectName);
webModule.setCode(WebModule.class.getName());
// WebModule(DeploymentUnit, AbstractWarDeployer, AbstractWarDeployment)
ServiceConstructorMetaData constructor = new ServiceConstructorMetaData();
constructor.setSignature(new String[] { DeploymentUnit.class.getName(), AbstractWarDeployer.class.getName(), AbstractWarDeployment.class.getName() });
constructor.setParameters(new Object[] { unit, this, deployment });
webModule.setConstructor(constructor);
List<ServiceAttributeMetaData> attrs = new ArrayList<ServiceAttributeMetaData>();
ServiceAttributeMetaData attr = new ServiceAttributeMetaData();
attr.setName("SecurityManagement");
ServiceInjectionValueMetaData injectionValue = new ServiceInjectionValueMetaData(deployment.getSecurityManagementName());
attr.setValue(injectionValue);
attrs.add(attr);
ServiceAttributeMetaData attrPR = new ServiceAttributeMetaData();
attrPR.setName("PolicyRegistration");
ServiceInjectionValueMetaData injectionValuePR = new ServiceInjectionValueMetaData(deployment.getPolicyRegistrationName());
attrPR.setValue(injectionValuePR);
attrs.add(attrPR);
ServiceAttributeMetaData attrKernel = new ServiceAttributeMetaData();
attrKernel.setName("Kernel");
ServiceInjectionValueMetaData injectionValueKernel = new ServiceInjectionValueMetaData(KernelConstants.KERNEL_NAME);
attrKernel.setValue(injectionValueKernel);
attrs.add(attrKernel);
webModule.setAttributes(attrs);
// Dependencies...Still have old jmx names here
Collection<String> depends = metaData.getDepends();
List<ServiceDependencyMetaData> dependencies = new ArrayList<ServiceDependencyMetaData>();
if (depends != null && depends.isEmpty() == false)
{
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);
// Here's where a bit of magic happens. By attaching the ServiceMetaData
// to the deployment, we now make the deployment "relevant" to
// deployers that use ServiceMetaData as an input (e.g. the
// org.jboss.system.deployers.ServiceDeployer). Those deployers