*
* @param phaseContext the deployment unit context
* @throws org.jboss.as.server.deployment.DeploymentUnitProcessingException
*/
public void deploy(DeploymentPhaseContext phaseContext) throws DeploymentUnitProcessingException {
final DeploymentUnit deploymentUnit = phaseContext.getDeploymentUnit();
if (DeploymentTypeMarker.isType(DeploymentType.EAR, deploymentUnit)) {
return;
}
EEModuleDescription moduleDescription = deploymentUnit.getAttachment(EE_MODULE_DESCRIPTION);
final ServiceTarget serviceTarget = phaseContext.getServiceTarget();
final ServiceName appContextServiceName = ContextNames.contextServiceNameOfApplication(moduleDescription.getApplicationName());
final ServiceName moduleContextServiceName = ContextNames.contextServiceNameOfModule(moduleDescription.getApplicationName(), moduleDescription.getModuleName());
final NamingStoreService contextService = new NamingStoreService();
serviceTarget.addService(moduleContextServiceName, contextService).install();
final BinderService moduleNameBinder = new BinderService("ModuleName");
serviceTarget.addService(moduleContextServiceName.append("ModuleName"), moduleNameBinder)
.addInjection(moduleNameBinder.getManagedObjectInjector(), new ValueManagedReferenceFactory(Values.immediateValue(moduleDescription.getModuleName())))
.addDependency(moduleContextServiceName, ServiceBasedNamingStore.class, moduleNameBinder.getNamingStoreInjector())
.install();
deploymentUnit.putAttachment(MODULE_CONTEXT_CONFIG, moduleContextServiceName);
final InjectedEENamespaceContextSelector selector = new InjectedEENamespaceContextSelector();
phaseContext.addDependency(appContextServiceName, NamingStore.class, selector.getAppContextInjector());
phaseContext.addDependency(moduleContextServiceName, NamingStore.class, selector.getModuleContextInjector());
phaseContext.addDependency(moduleContextServiceName, NamingStore.class, selector.getCompContextInjector());
phaseContext.addDependency(ContextNames.JBOSS_CONTEXT_SERVICE_NAME, NamingStore.class, selector.getJbossContextInjector());
phaseContext.addDependency(ContextNames.GLOBAL_CONTEXT_SERVICE_NAME, NamingStore.class, selector.getGlobalContextInjector());
moduleDescription.setNamespaceContextSelector(selector);
final Set<ServiceName> serviceNames = new HashSet<ServiceName>();
serviceNames.add(appContextServiceName);
serviceNames.add(moduleContextServiceName);
serviceNames.add(ContextNames.JBOSS_CONTEXT_SERVICE_NAME);
serviceNames.add(ContextNames.GLOBAL_CONTEXT_SERVICE_NAME);
// add the arquillian setup action, so the module namespace is available in arquillian tests
final JavaNamespaceSetup setupAction = new JavaNamespaceSetup(selector, serviceTarget);
deploymentUnit.addToAttachmentList(SETUP_ACTIONS, setupAction);
deploymentUnit.addToAttachmentList(org.jboss.as.ee.component.Attachments.WEB_SETUP_ACTIONS, setupAction);
}