Search in sources :

Example 6 with WeldCapability

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);
}
Also used : ModuleLoader(org.jboss.modules.ModuleLoader) ModuleDependency(org.jboss.as.server.deployment.module.ModuleDependency) ModuleSpecification(org.jboss.as.server.deployment.module.ModuleSpecification) WeldCapability(org.jboss.as.weld.WeldCapability) DeploymentUnit(org.jboss.as.server.deployment.DeploymentUnit) CapabilityServiceSupport(org.jboss.as.controller.capability.CapabilityServiceSupport)

Example 7 with WeldCapability

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);
        }
    }
}
Also used : WeldCapability(org.jboss.as.weld.WeldCapability) DeploymentUnit(org.jboss.as.server.deployment.DeploymentUnit) CapabilityServiceSupport(org.jboss.as.controller.capability.CapabilityServiceSupport)

Example 8 with WeldCapability

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();
}
Also used : ServiceName(org.jboss.msc.service.ServiceName) ServiceTarget(org.jboss.msc.service.ServiceTarget) CdiValidatorFactoryService(org.jboss.as.weld.CdiValidatorFactoryService) WeldCapability(org.jboss.as.weld.WeldCapability) DeploymentUnit(org.jboss.as.server.deployment.DeploymentUnit) BeanManager(javax.enterprise.inject.spi.BeanManager) CapabilityServiceSupport(org.jboss.as.controller.capability.CapabilityServiceSupport)

Example 9 with WeldCapability

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);
}
Also used : BeanManagerAfterDeploymentValidation(org.jboss.as.jpa.beanmanager.BeanManagerAfterDeploymentValidation) WeldCapability(org.jboss.as.weld.WeldCapability)

Example 10 with WeldCapability

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);
        }
    }
}
Also used : ModuleLoader(org.jboss.modules.ModuleLoader) ModuleSpecification(org.jboss.as.server.deployment.module.ModuleSpecification) WeldCapability(org.jboss.as.weld.WeldCapability) DeploymentUnit(org.jboss.as.server.deployment.DeploymentUnit) CapabilityServiceSupport(org.jboss.as.controller.capability.CapabilityServiceSupport)

Aggregations

WeldCapability (org.jboss.as.weld.WeldCapability)16 CapabilityServiceSupport (org.jboss.as.controller.capability.CapabilityServiceSupport)15 DeploymentUnit (org.jboss.as.server.deployment.DeploymentUnit)13 ModuleSpecification (org.jboss.as.server.deployment.module.ModuleSpecification)5 ModuleLoader (org.jboss.modules.ModuleLoader)5 ModuleDependency (org.jboss.as.server.deployment.module.ModuleDependency)3 Module (org.jboss.modules.Module)3 ServiceName (org.jboss.msc.service.ServiceName)2 ServiceTarget (org.jboss.msc.service.ServiceTarget)2 FaultToleranceExtension (io.smallrye.faulttolerance.FaultToleranceExtension)1 BeanManager (javax.enterprise.inject.spi.BeanManager)1 DataSource (javax.sql.DataSource)1 JobRepository (org.jberet.repository.JobRepository)1 ArtifactFactory (org.jberet.spi.ArtifactFactory)1 ProcessStateNotifier (org.jboss.as.controller.ProcessStateNotifier)1 EEModuleDescription (org.jboss.as.ee.component.EEModuleDescription)1 EjbProxyNormalizerCdiExtension (org.jboss.as.ejb3.validator.EjbProxyNormalizerCdiExtension)1 BeanManagerAfterDeploymentValidation (org.jboss.as.jpa.beanmanager.BeanManagerAfterDeploymentValidation)1 NamespaceContextSelector (org.jboss.as.naming.context.NamespaceContextSelector)1 DeploymentUnitProcessingException (org.jboss.as.server.deployment.DeploymentUnitProcessingException)1