|
|
@@ -21,7 +21,9 @@ |
|
|
*/ |
|
|
package org.jboss.as.weld.deployment.processors; |
|
|
|
|
|
import java.util.Collection; |
|
|
import java.util.HashSet; |
|
|
import java.util.Map; |
|
|
import java.util.Set; |
|
|
import java.util.function.Consumer; |
|
|
import java.util.function.Supplier; |
|
|
|
|
|
@@ -53,7 +55,6 @@ |
|
|
import org.jboss.as.weld.util.Utils; |
|
|
import org.jboss.msc.service.ServiceBuilder; |
|
|
import org.jboss.msc.service.ServiceName; |
|
|
import org.jboss.msc.service.ServiceRegistry; |
|
|
import org.jboss.msc.service.ServiceTarget; |
|
|
import org.jboss.msc.value.ImmediateValue; |
|
|
import org.jboss.msc.value.InjectedValue; |
|
|
@@ -76,9 +77,6 @@ public void deploy(DeploymentPhaseContext phaseContext) throws DeploymentUnitPro |
|
|
return; |
|
|
} |
|
|
|
|
|
final Collection<ServiceName> dependencies = deploymentUnit.getAttachment(Attachments.JNDI_DEPENDENCIES); |
|
|
|
|
|
|
|
|
BeanDeploymentArchiveImpl rootBda = deploymentUnit |
|
|
.getAttachment(WeldAttachments.DEPLOYMENT_ROOT_BEAN_DEPLOYMENT_ARCHIVE); |
|
|
if (rootBda == null) { |
|
|
@@ -111,30 +109,35 @@ public void deploy(DeploymentPhaseContext phaseContext) throws DeploymentUnitPro |
|
|
if (DeploymentTypeMarker.isType(DeploymentType.WAR, deploymentUnit) || deploymentUnit.getName().endsWith(".jar")) { |
|
|
// bind the bean manager to JNDI |
|
|
final ServiceName moduleContextServiceName = ContextNames.contextServiceNameOfModule(moduleDescription.getApplicationName(), moduleDescription.getModuleName()); |
|
|
bindBeanManager(serviceTarget, beanManagerServiceName, moduleContextServiceName, dependencies, phaseContext.getServiceRegistry()); |
|
|
bindBeanManager(deploymentUnit, serviceTarget, beanManagerServiceName, moduleContextServiceName); |
|
|
} |
|
|
|
|
|
|
|
|
//bind the bm into java:comp for all components that require it |
|
|
for (ComponentDescription component : moduleDescription.getComponentDescriptions()) { |
|
|
if (component.getNamingMode() == ComponentNamingMode.CREATE) { |
|
|
final ServiceName compContextServiceName = ContextNames.contextServiceNameOfComponent(moduleDescription.getApplicationName(), moduleDescription.getModuleName(), component.getComponentName()); |
|
|
bindBeanManager(serviceTarget, beanManagerServiceName, compContextServiceName, dependencies, phaseContext.getServiceRegistry()); |
|
|
bindBeanManager(deploymentUnit, serviceTarget, beanManagerServiceName, compContextServiceName); |
|
|
} |
|
|
} |
|
|
deploymentUnit.addToAttachmentList(Attachments.SETUP_ACTIONS, new WeldContextSetup()); |
|
|
} |
|
|
|
|
|
private void bindBeanManager(ServiceTarget serviceTarget, ServiceName beanManagerServiceName, ServiceName contextServiceName, final Collection<ServiceName> dependencies, final ServiceRegistry serviceRegistry) { |
|
|
private void bindBeanManager(DeploymentUnit deploymentUnit, ServiceTarget serviceTarget, ServiceName beanManagerServiceName, ServiceName contextServiceName) { |
|
|
final ServiceName beanManagerBindingServiceName = contextServiceName.append("BeanManager"); |
|
|
dependencies.add(beanManagerBindingServiceName); |
|
|
BinderService beanManagerBindingService = new BinderService("BeanManager"); |
|
|
final BeanManagerManagedReferenceFactory referenceFactory = new BeanManagerManagedReferenceFactory(); |
|
|
beanManagerBindingService.getManagedObjectInjector().inject(referenceFactory); |
|
|
serviceTarget.addService(beanManagerBindingServiceName, beanManagerBindingService) |
|
|
.addDependency(contextServiceName, ServiceBasedNamingStore.class, beanManagerBindingService.getNamingStoreInjector()) |
|
|
.addDependency(beanManagerServiceName, BeanManager.class, referenceFactory.beanManager) |
|
|
.install(); |
|
|
final Map<ServiceName, Set<ServiceName>> jndiComponentDependencies = deploymentUnit.getAttachment(Attachments.COMPONENT_JNDI_DEPENDENCIES); |
|
|
Set<ServiceName> jndiDependencies = jndiComponentDependencies.get(contextServiceName); |
|
|
if (jndiDependencies == null) { |
|
|
jndiComponentDependencies.put(contextServiceName, jndiDependencies = new HashSet<>()); |
|
|
} |
|
|
jndiDependencies.add(beanManagerBindingServiceName); |
|
|
} |
|
|
|
|
|
@Override |
|
|
|