Search in sources :

Example 1 with WeldCapability

use of org.jboss.as.weld.WeldCapability in project wildfly by wildfly.

the class TracingDeploymentProcessor method deploy.

@Override
public void deploy(DeploymentPhaseContext deploymentPhaseContext) throws DeploymentUnitProcessingException {
    ROOT_LOGGER.processingDeployment();
    final DeploymentUnit deploymentUnit = deploymentPhaseContext.getDeploymentUnit();
    if (DeploymentTypeMarker.isType(DeploymentType.EAR, deploymentUnit)) {
        return;
    }
    final CapabilityServiceSupport support = deploymentUnit.getAttachment(Attachments.CAPABILITY_SERVICE_SUPPORT);
    try {
        final WeldCapability weldCapability = support.getCapabilityRuntimeAPI(WELD_CAPABILITY_NAME, WeldCapability.class);
        if (!weldCapability.isPartOfWeldDeployment(deploymentUnit)) {
            // SmallRye Jakarta RESTful Web Services require Jakarta Contexts and Dependency Injection. Without Jakarta Contexts and Dependency Injection, there's no integration needed
            ROOT_LOGGER.noCdiDeployment();
            return;
        }
    } catch (CapabilityServiceSupport.NoSuchCapabilityException e) {
        // We should not be here since the subsystem depends on weld capability. Just in case ...
        throw new DeploymentUnitProcessingException(ROOT_LOGGER.deploymentRequiresCapability(deploymentPhaseContext.getDeploymentUnit().getName(), WELD_CAPABILITY_NAME));
    }
    injectTracer(deploymentPhaseContext, support);
}
Also used : DeploymentUnitProcessingException(org.jboss.as.server.deployment.DeploymentUnitProcessingException) WeldCapability(org.jboss.as.weld.WeldCapability) DeploymentUnit(org.jboss.as.server.deployment.DeploymentUnit) CapabilityServiceSupport(org.jboss.as.controller.capability.CapabilityServiceSupport)

Example 2 with WeldCapability

use of org.jboss.as.weld.WeldCapability in project wildfly by wildfly.

the class JaxrsCdiIntegrationProcessor method deploy.

@Override
public void deploy(final DeploymentPhaseContext phaseContext) throws DeploymentUnitProcessingException {
    final DeploymentUnit deploymentUnit = phaseContext.getDeploymentUnit();
    final Module module = deploymentUnit.getAttachment(Attachments.MODULE);
    if (!JaxrsDeploymentMarker.isJaxrsDeployment(deploymentUnit)) {
        return;
    }
    if (!DeploymentTypeMarker.isType(DeploymentType.WAR, deploymentUnit)) {
        return;
    }
    final WarMetaData warMetaData = deploymentUnit.getAttachment(WarMetaData.ATTACHMENT_KEY);
    final JBossWebMetaData webdata = warMetaData.getMergedJBossWebMetaData();
    try {
        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.isWeldDeployment(deploymentUnit)) {
                // don't set this param if Jakarta Contexts and Dependency Injection is not in classpath
                module.getClassLoader().loadClass(CDI_INJECTOR_FACTORY_CLASS);
                JAXRS_LOGGER.debug("Found Jakarta Contexts and Dependency Injection, adding injector factory class");
                setContextParameter(webdata, "resteasy.injector.factory", CDI_INJECTOR_FACTORY_CLASS);
            }
        }
    } catch (ClassNotFoundException ignored) {
    }
}
Also used : JBossWebMetaData(org.jboss.metadata.web.jboss.JBossWebMetaData) WarMetaData(org.jboss.as.web.common.WarMetaData) WeldCapability(org.jboss.as.weld.WeldCapability) Module(org.jboss.modules.Module) DeploymentUnit(org.jboss.as.server.deployment.DeploymentUnit) CapabilityServiceSupport(org.jboss.as.controller.capability.CapabilityServiceSupport)

Example 3 with WeldCapability

use of org.jboss.as.weld.WeldCapability in project wildfly by wildfly.

the class JaxrsDependencyProcessor method deploy.

public void deploy(DeploymentPhaseContext phaseContext) throws DeploymentUnitProcessingException {
    final DeploymentUnit deploymentUnit = phaseContext.getDeploymentUnit();
    final ModuleSpecification moduleSpecification = deploymentUnit.getAttachment(Attachments.MODULE_SPECIFICATION);
    boolean deploymentBundlesClientBuilder = isClientBuilderInDeployment(deploymentUnit);
    final ModuleLoader moduleLoader = Module.getBootModuleLoader();
    addDependency(moduleSpecification, moduleLoader, JAXRS_API, false, false);
    addDependency(moduleSpecification, moduleLoader, JAXB_API, false, false);
    addDependency(moduleSpecification, moduleLoader, JSON_API, false, false);
    // we need to add these from all deployments, as they could be using the Jakarta RESTful Web Services client
    addDependency(moduleSpecification, moduleLoader, RESTEASY_ATOM, true, false);
    addDependency(moduleSpecification, moduleLoader, RESTEASY_VALIDATOR, true, false);
    addDependency(moduleSpecification, moduleLoader, RESTEASY_CLIENT, true, deploymentBundlesClientBuilder);
    addDependency(moduleSpecification, moduleLoader, RESTEASY_CLIENT_API, true, deploymentBundlesClientBuilder);
    addDependency(moduleSpecification, moduleLoader, RESTEASY_CORE, true, deploymentBundlesClientBuilder);
    addDependency(moduleSpecification, moduleLoader, RESTEASY_CORE_SPI, true, deploymentBundlesClientBuilder);
    addDependency(moduleSpecification, moduleLoader, RESTEASY_CLIENT_MICROPROFILE, true, false);
    addDependency(moduleSpecification, moduleLoader, RESTEASY_JAXB, true, false);
    addDependency(moduleSpecification, moduleLoader, RESTEASY_JACKSON2, true, false);
    addDependency(moduleSpecification, moduleLoader, RESTEASY_JSON_P_PROVIDER, true, false);
    addDependency(moduleSpecification, moduleLoader, RESTEASY_JSON_B_PROVIDER, true, false);
    addDependency(moduleSpecification, moduleLoader, RESTEASY_JSAPI, true, false);
    addDependency(moduleSpecification, moduleLoader, RESTEASY_MULTIPART, true, false);
    addDependency(moduleSpecification, moduleLoader, RESTEASY_CRYPTO, true, false);
    addDependency(moduleSpecification, moduleLoader, JACKSON_DATATYPE_JDK8, true, false);
    addDependency(moduleSpecification, moduleLoader, JACKSON_DATATYPE_JSR310, true, false);
    addDependency(moduleSpecification, moduleLoader, MP_REST_CLIENT, true, false);
    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, RESTEASY_CDI, true, false);
        }
    }
}
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)

Example 4 with WeldCapability

use of org.jboss.as.weld.WeldCapability in project wildfly by wildfly.

the class DeploymentProcessor method deploy.

@Override
public void deploy(DeploymentPhaseContext phaseContext) throws DeploymentUnitProcessingException {
    DeploymentUnit deploymentUnit = phaseContext.getDeploymentUnit();
    Module module = deploymentUnit.getAttachment(Attachments.MODULE);
    final CapabilityServiceSupport support = deploymentUnit.getAttachment(Attachments.CAPABILITY_SERVICE_SUPPORT);
    final WeldCapability weldCapability;
    try {
        weldCapability = support.getCapabilityRuntimeAPI(WELD_CAPABILITY_NAME, WeldCapability.class);
    } catch (CapabilityServiceSupport.NoSuchCapabilityException e) {
        // We should not be here since the subsystem depends on weld capability. Just in case ...
        throw MicroProfileHealthLogger.LOGGER.deploymentRequiresCapability(deploymentUnit.getName(), WELD_CAPABILITY_NAME);
    }
    if (weldCapability.isPartOfWeldDeployment(deploymentUnit)) {
        final MicroProfileHealthReporter healthReporter = (MicroProfileHealthReporter) phaseContext.getServiceRegistry().getService(MicroProfileHealthSubsystemDefinition.HEALTH_REPORTER_SERVICE).getValue();
        weldCapability.registerExtensionInstance(new CDIExtension(healthReporter, module), deploymentUnit);
    }
}
Also used : MicroProfileHealthReporter(org.wildfly.extension.microprofile.health.MicroProfileHealthReporter) WeldCapability(org.jboss.as.weld.WeldCapability) Module(org.jboss.modules.Module) DeploymentUnit(org.jboss.as.server.deployment.DeploymentUnit) CapabilityServiceSupport(org.jboss.as.controller.capability.CapabilityServiceSupport)

Example 5 with WeldCapability

use of org.jboss.as.weld.WeldCapability in project wildfly by wildfly.

the class OpenTelemetryDependencyProcessor method addDependencies.

private void addDependencies(DeploymentUnit deploymentUnit) {
    final ModuleSpecification moduleSpecification = deploymentUnit.getAttachment(Attachments.MODULE_SPECIFICATION);
    final ModuleLoader moduleLoader = Module.getBootModuleLoader();
    try {
        CapabilityServiceSupport support = deploymentUnit.getAttachment(Attachments.CAPABILITY_SERVICE_SUPPORT);
        WeldCapability weldCapability = support.getCapabilityRuntimeAPI(Capabilities.WELD_CAPABILITY_NAME, WeldCapability.class);
        if (weldCapability.isPartOfWeldDeployment(deploymentUnit)) {
            weldCapability.registerExtensionInstance(new OpenTelemetryCdiExtension(), deploymentUnit);
            // Export the -api module only if CDI is available
            moduleSpecification.addSystemDependency(new ModuleDependency(moduleLoader, API_MODULE, false, true, true, false));
        }
        // Export all other modules regardless of CDI availability
        for (String module : EXPORTED_MODULES) {
            moduleSpecification.addSystemDependency(new ModuleDependency(moduleLoader, module, false, true, true, false));
        }
    } catch (CapabilityServiceSupport.NoSuchCapabilityException e) {
        throw new IllegalStateException();
    }
}
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) OpenTelemetryCdiExtension(org.wildfly.extension.opentelemetry.api.OpenTelemetryCdiExtension) 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