use of org.jboss.as.weld.WeldCapability in project wildfly by wildfly.
the class WeldBeanValidationDependencyProcessor method deploy.
@Override
public void deploy(DeploymentPhaseContext phaseContext) throws DeploymentUnitProcessingException {
final DeploymentUnit deploymentUnit = phaseContext.getDeploymentUnit();
final ModuleSpecification moduleSpecification = deploymentUnit.getAttachment(Attachments.MODULE_SPECIFICATION);
final ModuleLoader moduleLoader = Module.getBootModuleLoader();
final CapabilityServiceSupport support = deploymentUnit.getAttachment(Attachments.CAPABILITY_SERVICE_SUPPORT);
final WeldCapability weldCapability;
try {
weldCapability = support.getCapabilityRuntimeAPI(WELD_CAPABILITY_NAME, WeldCapability.class);
} catch (CapabilityServiceSupport.NoSuchCapabilityException ignored) {
return;
}
if (!weldCapability.isPartOfWeldDeployment(deploymentUnit)) {
// Skip if there are no beans.xml files in the deployment
return;
}
ModuleDependency cdiBeanValidationDep = new ModuleDependency(moduleLoader, CDI_BEAN_VALIDATION_ID, false, false, true, false);
moduleSpecification.addSystemDependency(cdiBeanValidationDep);
}
use of org.jboss.as.weld.WeldCapability in project wildfly by wildfly.
the class EarApplicationScopedObserverMethodProcessor method deploy.
@Override
public void deploy(DeploymentPhaseContext phaseContext) throws DeploymentUnitProcessingException {
final DeploymentUnit deploymentUnit = phaseContext.getDeploymentUnit();
if (!DeploymentTypeMarker.isType(DeploymentType.EAR, deploymentUnit)) {
// ear deployment only processor
return;
}
final CapabilityServiceSupport support = deploymentUnit.getAttachment(Attachments.CAPABILITY_SERVICE_SUPPORT);
if (support.hasCapability(WELD_CAPABILITY_NAME)) {
final WeldCapability api = support.getOptionalCapabilityRuntimeAPI(WELD_CAPABILITY_NAME, WeldCapability.class).get();
if (api.isPartOfWeldDeployment(deploymentUnit)) {
api.registerExtensionInstance(new PortableExtension(deploymentUnit), deploymentUnit);
}
}
}
use of org.jboss.as.weld.WeldCapability in project wildfly by wildfly.
the class CdiBeanValidationFactoryProcessor method deploy.
@Override
public void deploy(DeploymentPhaseContext phaseContext) {
final DeploymentUnit deploymentUnit = phaseContext.getDeploymentUnit();
final DeploymentUnit topLevelDeployment = deploymentUnit.getParent() == null ? deploymentUnit : deploymentUnit.getParent();
final ServiceName weldStartService = topLevelDeployment.getServiceName().append(ServiceNames.WELD_START_SERVICE_NAME);
final CapabilityServiceSupport support = deploymentUnit.getAttachment(Attachments.CAPABILITY_SERVICE_SUPPORT);
final WeldCapability weldCapability;
try {
weldCapability = support.getCapabilityRuntimeAPI(WELD_CAPABILITY_NAME, WeldCapability.class);
} catch (CapabilityServiceSupport.NoSuchCapabilityException ignored) {
return;
}
if (!weldCapability.isPartOfWeldDeployment(deploymentUnit)) {
return;
}
if (!deploymentUnit.hasAttachment(BeanValidationAttachments.VALIDATOR_FACTORY)) {
return;
}
final ServiceTarget serviceTarget = phaseContext.getServiceTarget();
final ServiceName serviceName = deploymentUnit.getServiceName().append(CdiValidatorFactoryService.SERVICE_NAME);
final ServiceBuilder<?> sb = serviceTarget.addService(serviceName);
final Supplier<BeanManager> beanManagerSupplier = weldCapability.addBeanManagerService(deploymentUnit, sb);
sb.requires(weldStartService);
sb.setInstance(new CdiValidatorFactoryService(deploymentUnit, beanManagerSupplier));
sb.install();
}
use of org.jboss.as.weld.WeldCapability in project wildfly by wildfly.
the class PersistenceUnitServiceHandler method registerJPAEntityListenerRegister.
private static BeanManagerAfterDeploymentValidation registerJPAEntityListenerRegister(DeploymentUnit deploymentUnit, CapabilityServiceSupport support) {
deploymentUnit = DeploymentUtils.getTopDeploymentUnit(deploymentUnit);
if (support.hasCapability(WELD_CAPABILITY_NAME)) {
Optional<WeldCapability> weldCapability = support.getOptionalCapabilityRuntimeAPI(WELD_CAPABILITY_NAME, WeldCapability.class);
if (weldCapability.get().isPartOfWeldDeployment(deploymentUnit)) {
synchronized (deploymentUnit) {
BeanManagerAfterDeploymentValidation beanManagerAfterDeploymentValidation = deploymentUnit.getAttachment(JpaAttachments.BEAN_MANAGER_AFTER_DEPLOYMENT_VALIDATION_ATTACHMENT_KEY);
if (null == beanManagerAfterDeploymentValidation) {
beanManagerAfterDeploymentValidation = new BeanManagerAfterDeploymentValidation();
deploymentUnit.putAttachment(JpaAttachments.BEAN_MANAGER_AFTER_DEPLOYMENT_VALIDATION_ATTACHMENT_KEY, beanManagerAfterDeploymentValidation);
weldCapability.get().registerExtensionInstance(beanManagerAfterDeploymentValidation, deploymentUnit);
}
return beanManagerAfterDeploymentValidation;
}
}
}
return new BeanManagerAfterDeploymentValidation(true);
}
use of org.jboss.as.weld.WeldCapability in project wildfly by wildfly.
the class MessagingDependencyProcessor method deploy.
public void deploy(DeploymentPhaseContext phaseContext) throws DeploymentUnitProcessingException {
final DeploymentUnit deploymentUnit = phaseContext.getDeploymentUnit();
final ModuleSpecification moduleSpecification = deploymentUnit.getAttachment(Attachments.MODULE_SPECIFICATION);
final ModuleLoader moduleLoader = Module.getBootModuleLoader();
addDependency(moduleSpecification, moduleLoader, JMS_API);
final CapabilityServiceSupport support = deploymentUnit.getAttachment(Attachments.CAPABILITY_SERVICE_SUPPORT);
if (support.hasCapability(WELD_CAPABILITY_NAME)) {
final WeldCapability api = support.getOptionalCapabilityRuntimeAPI(WELD_CAPABILITY_NAME, WeldCapability.class).get();
if (api.isPartOfWeldDeployment(deploymentUnit)) {
addDependency(moduleSpecification, moduleLoader, AS_MESSAGING);
// The messaging-activemq subsystem provides support for injected JMSContext.
// one of the beans has a @TransactionScoped scope which requires the CDI context
// provided by Narayana in the org.jboss.jts module.
// @see CDIDeploymentProcessor
addDependency(moduleSpecification, moduleLoader, JTS);
}
}
}
Aggregations