Search in sources :

Example 46 with CapabilityServiceSupport

use of org.jboss.as.controller.capability.CapabilityServiceSupport 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)

Example 47 with CapabilityServiceSupport

use of org.jboss.as.controller.capability.CapabilityServiceSupport in project wildfly by wildfly.

the class MicroProfileFaultToleranceDependenciesProcessor method deploy.

@Override
public void deploy(DeploymentPhaseContext phaseContext) {
    DeploymentUnit deploymentUnit = phaseContext.getDeploymentUnit();
    CapabilityServiceSupport support = deploymentUnit.getAttachment(Attachments.CAPABILITY_SERVICE_SUPPORT);
    Optional<WeldCapability> weldCapability = support.getOptionalCapabilityRuntimeAPI(WELD_CAPABILITY_NAME, WeldCapability.class);
    if (weldCapability.isPresent() && weldCapability.get().isPartOfWeldDeployment(deploymentUnit) && MicroProfileFaultToleranceMarker.hasMicroProfileFaultToleranceAnnotations(deploymentUnit)) {
        MicroProfileFaultToleranceMarker.mark(deploymentUnit);
        ModuleSpecification moduleSpecification = deploymentUnit.getAttachment(Attachments.MODULE_SPECIFICATION);
        ModuleLoader moduleLoader = Module.getBootModuleLoader();
        moduleSpecification.addSystemDependency(new ModuleDependency(moduleLoader, "org.eclipse.microprofile.fault-tolerance.api", false, false, false, false));
        moduleSpecification.addSystemDependency(new ModuleDependency(moduleLoader, "org.wildfly.microprofile.fault-tolerance-smallrye.executor", false, false, true, false));
    }
}
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 48 with CapabilityServiceSupport

use of org.jboss.as.controller.capability.CapabilityServiceSupport in project wildfly by wildfly.

the class MicroProfileFaultToleranceDeploymentProcessor method deploy.

@Override
public void deploy(DeploymentPhaseContext phaseContext) throws DeploymentUnitProcessingException {
    DeploymentUnit deploymentUnit = phaseContext.getDeploymentUnit();
    if (!MicroProfileFaultToleranceMarker.isMarked(deploymentUnit)) {
        return;
    }
    // Weld Extension
    CapabilityServiceSupport support = deploymentUnit.getAttachment(Attachments.CAPABILITY_SERVICE_SUPPORT);
    WeldCapability weldCapability;
    try {
        weldCapability = support.getCapabilityRuntimeAPI(Capabilities.WELD_CAPABILITY_NAME, WeldCapability.class);
    } catch (CapabilityServiceSupport.NoSuchCapabilityException e) {
        throw new IllegalStateException();
    }
    weldCapability.registerExtensionInstance(new FaultToleranceExtension(), deploymentUnit);
}
Also used : FaultToleranceExtension(io.smallrye.faulttolerance.FaultToleranceExtension) WeldCapability(org.jboss.as.weld.WeldCapability) DeploymentUnit(org.jboss.as.server.deployment.DeploymentUnit) CapabilityServiceSupport(org.jboss.as.controller.capability.CapabilityServiceSupport)

Example 49 with CapabilityServiceSupport

use of org.jboss.as.controller.capability.CapabilityServiceSupport in project wildfly by wildfly.

the class BeanValidationFactoryDeployer method undeploy.

@Override
public void undeploy(DeploymentUnit context) {
    ValidatorFactory validatorFactory = context.getAttachment(BeanValidationAttachments.VALIDATOR_FACTORY);
    final CapabilityServiceSupport support = context.getAttachment(Attachments.CAPABILITY_SERVICE_SUPPORT);
    boolean partOfWeldDeployment = false;
    if (support.hasCapability(WELD_CAPABILITY_NAME)) {
        partOfWeldDeployment = support.getOptionalCapabilityRuntimeAPI(WELD_CAPABILITY_NAME, WeldCapability.class).get().isPartOfWeldDeployment(context);
    }
    if (validatorFactory != null && !partOfWeldDeployment) {
        // If the ValidatorFactory is not Jakarta Contexts and Dependency Injection enabled, close it here. Otherwise, it's
        // closed via CdiValidatorFactoryService before the Weld service is stopped.
        validatorFactory.close();
    }
    context.removeAttachment(BeanValidationAttachments.VALIDATOR_FACTORY);
}
Also used : ValidatorFactory(javax.validation.ValidatorFactory) WeldCapability(org.jboss.as.weld.WeldCapability) CapabilityServiceSupport(org.jboss.as.controller.capability.CapabilityServiceSupport)

Example 50 with CapabilityServiceSupport

use of org.jboss.as.controller.capability.CapabilityServiceSupport in project wildfly by wildfly.

the class DsXmlDeploymentInstallProcessor method deploy.

/**
 * Process a deployment for standard ra deployment files. Will parse the xml
 * file and attach a configuration discovered during processing.
 *
 * @param phaseContext the deployment unit context
 * @throws DeploymentUnitProcessingException
 */
@Override
public void deploy(DeploymentPhaseContext phaseContext) throws DeploymentUnitProcessingException {
    final DeploymentUnit deploymentUnit = phaseContext.getDeploymentUnit();
    final CapabilityServiceSupport support = deploymentUnit.getAttachment(Attachments.CAPABILITY_SERVICE_SUPPORT);
    final List<DataSources> dataSourcesList = deploymentUnit.getAttachmentList(DsXmlDeploymentParsingProcessor.DATA_SOURCES_ATTACHMENT_KEY);
    final boolean legacySecurityPresent = support.hasCapability("org.wildfly.legacy-security");
    for (DataSources dataSources : dataSourcesList) {
        if (dataSources.getDrivers() != null && !dataSources.getDrivers().isEmpty()) {
            ConnectorLogger.DS_DEPLOYER_LOGGER.driversElementNotSupported(deploymentUnit.getName());
        }
        ServiceTarget serviceTarget = phaseContext.getServiceTarget();
        if (dataSources.getDataSource() != null && !dataSources.getDataSource().isEmpty()) {
            for (int i = 0; i < dataSources.getDataSource().size(); i++) {
                DataSource ds = (DataSource) dataSources.getDataSource().get(i);
                if (ds.isEnabled() && ds.getDriver() != null) {
                    try {
                        final String jndiName = Util.cleanJndiName(ds.getJndiName(), ds.isUseJavaContext());
                        LocalDataSourceService lds = new LocalDataSourceService(jndiName, ContextNames.bindInfoFor(jndiName));
                        lds.getDataSourceConfigInjector().inject(buildDataSource(ds));
                        final String dsName = ds.getJndiName();
                        final PathAddress addr = getDataSourceAddress(dsName, deploymentUnit, false);
                        installManagementModel(ds, deploymentUnit, addr);
                        // TODO why have we been ignoring a configured legacy security domain but no legacy security present?
                        boolean useLegacySecurity = legacySecurityPresent && isLegacySecurityRequired(ds.getSecurity());
                        startDataSource(lds, jndiName, ds.getDriver(), serviceTarget, getRegistration(false, deploymentUnit), getResource(dsName, false, deploymentUnit), dsName, useLegacySecurity, ds.isJTA(), support);
                    } catch (DeploymentUnitProcessingException dupe) {
                        throw dupe;
                    } catch (Exception e) {
                        throw ConnectorLogger.ROOT_LOGGER.exceptionDeployingDatasource(e, ds.getJndiName());
                    }
                } else {
                    ConnectorLogger.DS_DEPLOYER_LOGGER.debugf("Ignoring: %s", ds.getJndiName());
                }
            }
        }
        if (dataSources.getXaDataSource() != null && !dataSources.getXaDataSource().isEmpty()) {
            for (int i = 0; i < dataSources.getXaDataSource().size(); i++) {
                XaDataSource xads = (XaDataSource) dataSources.getXaDataSource().get(i);
                if (xads.isEnabled() && xads.getDriver() != null) {
                    try {
                        String jndiName = Util.cleanJndiName(xads.getJndiName(), xads.isUseJavaContext());
                        XaDataSourceService xds = new XaDataSourceService(jndiName, ContextNames.bindInfoFor(jndiName));
                        xds.getDataSourceConfigInjector().inject(buildXaDataSource(xads));
                        final String dsName = xads.getJndiName();
                        final PathAddress addr = getDataSourceAddress(dsName, deploymentUnit, true);
                        installManagementModel(xads, deploymentUnit, addr);
                        final Credential credential = xads.getRecovery() == null ? null : xads.getRecovery().getCredential();
                        // TODO why have we been ignoring a configured legacy security domain but no legacy security present?
                        boolean useLegacySecurity = legacySecurityPresent && (isLegacySecurityRequired(xads.getSecurity()) || isLegacySecurityRequired(credential));
                        startDataSource(xds, jndiName, xads.getDriver(), serviceTarget, getRegistration(true, deploymentUnit), getResource(dsName, true, deploymentUnit), dsName, useLegacySecurity, true, support);
                    } catch (Exception e) {
                        throw ConnectorLogger.ROOT_LOGGER.exceptionDeployingDatasource(e, xads.getJndiName());
                    }
                } else {
                    ConnectorLogger.DS_DEPLOYER_LOGGER.debugf("Ignoring %s", xads.getJndiName());
                }
            }
        }
    }
}
Also used : DeploymentUnitProcessingException(org.jboss.as.server.deployment.DeploymentUnitProcessingException) Credential(org.jboss.jca.common.api.metadata.common.Credential) ServiceTarget(org.jboss.msc.service.ServiceTarget) ModifiableXaDataSource(org.jboss.as.connector.subsystems.datasources.ModifiableXaDataSource) XaDataSource(org.jboss.jca.common.api.metadata.ds.XaDataSource) DeploymentUnitProcessingException(org.jboss.as.server.deployment.DeploymentUnitProcessingException) CapabilityServiceSupport(org.jboss.as.controller.capability.CapabilityServiceSupport) ModifiableXaDataSource(org.jboss.as.connector.subsystems.datasources.ModifiableXaDataSource) XaDataSource(org.jboss.jca.common.api.metadata.ds.XaDataSource) ModifiableDataSource(org.jboss.as.connector.subsystems.datasources.ModifiableDataSource) DataSource(org.jboss.jca.common.api.metadata.ds.DataSource) LocalDataSourceService(org.jboss.as.connector.subsystems.datasources.LocalDataSourceService) XaDataSourceService(org.jboss.as.connector.subsystems.datasources.XaDataSourceService) DataSources(org.jboss.jca.common.api.metadata.ds.DataSources) PathAddress(org.jboss.as.controller.PathAddress) DeploymentUnit(org.jboss.as.server.deployment.DeploymentUnit)

Aggregations

CapabilityServiceSupport (org.jboss.as.controller.capability.CapabilityServiceSupport)74 DeploymentUnit (org.jboss.as.server.deployment.DeploymentUnit)39 ServiceName (org.jboss.msc.service.ServiceName)36 ServiceTarget (org.jboss.msc.service.ServiceTarget)23 WeldCapability (org.jboss.as.weld.WeldCapability)19 DeploymentUnitProcessingException (org.jboss.as.server.deployment.DeploymentUnitProcessingException)18 Module (org.jboss.modules.Module)16 ServiceBuilder (org.jboss.msc.service.ServiceBuilder)14 ComponentDescription (org.jboss.as.ee.component.ComponentDescription)10 HashMap (java.util.HashMap)9 DeploymentPhaseContext (org.jboss.as.server.deployment.DeploymentPhaseContext)9 ComponentConfiguration (org.jboss.as.ee.component.ComponentConfiguration)8 EEModuleDescription (org.jboss.as.ee.component.EEModuleDescription)8 ValidatorFactory (javax.validation.ValidatorFactory)7 ModuleSpecification (org.jboss.as.server.deployment.module.ModuleSpecification)7 HashSet (java.util.HashSet)6 TransactionSynchronizationRegistry (javax.transaction.TransactionSynchronizationRegistry)6 ComponentConfigurator (org.jboss.as.ee.component.ComponentConfigurator)6 ModelNode (org.jboss.dmr.ModelNode)6 ModuleLoader (org.jboss.modules.ModuleLoader)6