Search in sources :

Example 51 with CapabilityServiceSupport

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

the class JcaSubsystemAdd method performBoottime.

protected void performBoottime(OperationContext context, ModelNode operation, ModelNode model) {
    final boolean appclient = context.getProcessType() == ProcessType.APPLICATION_CLIENT;
    final boolean legacySecurityAvailable = context.hasOptionalCapability("org.wildfly.legacy-security", null, null);
    final RaDeploymentActivator raDeploymentActivator = new RaDeploymentActivator(appclient, legacySecurityAvailable);
    context.addStep(new AbstractDeploymentChainStep() {

        protected void execute(DeploymentProcessorTarget processorTarget) {
            raDeploymentActivator.activateProcessors(processorTarget);
        }
    }, OperationContext.Stage.RUNTIME);
    CapabilityServiceTarget serviceTarget = context.getCapabilityServiceTarget();
    TransactionIntegrationService tiService = new TransactionIntegrationService();
    serviceTarget.addCapability(TRANSACTION_INTEGRATION_CAPABILITY).setInstance(tiService).addCapabilityRequirement(LOCAL_TRANSACTION_PROVIDER_CAPABILITY, Void.class).addCapabilityRequirement(TRANSACTION_XA_RESOURCE_RECOVERY_REGISTRY_CAPABILITY, XAResourceRecoveryRegistry.class, tiService.getRrInjector()).addCapabilityRequirement(TRANSACTION_SYNCHRONIZATION_REGISTRY_CAPABILITY, TransactionSynchronizationRegistry.class, tiService.getTsrInjector()).addDependency(TxnServices.JBOSS_TXN_USER_TRANSACTION_REGISTRY, org.jboss.tm.usertx.UserTransactionRegistry.class, tiService.getUtrInjector()).addDependency(TxnServices.JBOSS_TXN_CONTEXT_XA_TERMINATOR, JBossContextXATerminator.class, tiService.getTerminatorInjector()).setInitialMode(ServiceController.Mode.ACTIVE).addAliases(ConnectorServices.TRANSACTION_INTEGRATION_SERVICE).install();
    // Cache the some capability service names for use by our runtime services
    final CapabilityServiceSupport support = context.getCapabilityServiceSupport();
    ConnectorServices.registerCapabilityServiceName(LOCAL_TRANSACTION_PROVIDER_CAPABILITY, support.getCapabilityServiceName(LOCAL_TRANSACTION_PROVIDER_CAPABILITY));
    ConnectorServices.registerCapabilityServiceName(NamingService.CAPABILITY_NAME, support.getCapabilityServiceName(NamingService.CAPABILITY_NAME));
    ConnectorServices.registerCapabilityServiceName(TRANSACTION_INTEGRATION_CAPABILITY_NAME, support.getCapabilityServiceName(TRANSACTION_INTEGRATION_CAPABILITY_NAME));
    final JcaSubsystemConfiguration config = new JcaSubsystemConfiguration();
    final JcaConfigService connectorConfigService = new JcaConfigService(config);
    serviceTarget.addService(ConnectorServices.CONNECTOR_CONFIG_SERVICE, connectorConfigService).setInitialMode(Mode.ACTIVE).install();
    final IdleRemoverService idleRemoverService = new IdleRemoverService();
    serviceTarget.addService(ConnectorServices.IDLE_REMOVER_SERVICE, idleRemoverService).setInitialMode(Mode.ACTIVE).install();
    final ConnectionValidatorService connectionValidatorService = new ConnectionValidatorService();
    serviceTarget.addService(ConnectorServices.CONNECTION_VALIDATOR_SERVICE, connectionValidatorService).setInitialMode(Mode.ACTIVE).install();
    // TODO does the install of this and the DriverProcessor
    // belong in DataSourcesSubsystemAdd?
    final DriverRegistryService driverRegistryService = new DriverRegistryService();
    serviceTarget.addService(ConnectorServices.JDBC_DRIVER_REGISTRY_SERVICE, driverRegistryService).install();
    raDeploymentActivator.activateServices(serviceTarget);
}
Also used : JBossContextXATerminator(org.jboss.as.txn.integration.JBossContextXATerminator) DriverRegistryService(org.jboss.as.connector.services.driver.registry.DriverRegistryService) RaDeploymentActivator(org.jboss.as.connector.deployers.ra.RaDeploymentActivator) CapabilityServiceSupport(org.jboss.as.controller.capability.CapabilityServiceSupport) DeploymentProcessorTarget(org.jboss.as.server.DeploymentProcessorTarget) TransactionSynchronizationRegistry(javax.transaction.TransactionSynchronizationRegistry) AbstractDeploymentChainStep(org.jboss.as.server.AbstractDeploymentChainStep) TransactionIntegrationService(org.jboss.as.connector.services.transactionintegration.TransactionIntegrationService) CapabilityServiceTarget(org.jboss.as.controller.CapabilityServiceTarget)

Example 52 with CapabilityServiceSupport

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

the class GlobalDirectoryDependencyProcessor method deploy.

@Override
public void deploy(DeploymentPhaseContext phaseContext) throws DeploymentUnitProcessingException {
    final DeploymentUnit deploymentUnit = phaseContext.getDeploymentUnit();
    final ServiceName depUnitServiceName = deploymentUnit.getServiceName();
    final DeploymentUnit parent = deploymentUnit.getParent();
    final DeploymentUnit topLevelDeployment = parent == null ? deploymentUnit : parent;
    final ExternalModule externalModuleService = topLevelDeployment.getAttachment(Attachments.EXTERNAL_MODULE_SERVICE);
    final ModuleLoader moduleLoader = deploymentUnit.getAttachment(Attachments.SERVICE_MODULE_LOADER);
    final ModuleSpecification moduleSpecification = deploymentUnit.getAttachment(Attachments.MODULE_SPECIFICATION);
    final CapabilityServiceSupport capabilitySupport = deploymentUnit.getAttachment(Attachments.CAPABILITY_SERVICE_SUPPORT);
    final ServiceRegistry serviceRegistry = phaseContext.getServiceRegistry();
    final ServiceTarget target = phaseContext.getServiceTarget();
    final ServiceTarget externalServiceTarget = deploymentUnit.getAttachment(Attachments.EXTERNAL_SERVICE_TARGET);
    final ServiceName allDirReadyServiceName = depUnitServiceName.append("directory-services-ready");
    final ServiceBuilder<?> allDirReadyServiceBuilder = target.addService(allDirReadyServiceName);
    final List<Supplier<GlobalDirectoryResourceDefinition.GlobalDirectory>> allDirReadySuppliers = new ArrayList<>();
    final ServiceName csName = capabilitySupport.getCapabilityServiceName(EE_GLOBAL_DIRECTORY_CAPABILITY_NAME);
    List<ServiceName> serviceNames = serviceRegistry.getServiceNames();
    for (ServiceName serviceName : serviceNames) {
        if (csName.isParentOf(serviceName)) {
            Supplier<GlobalDirectoryResourceDefinition.GlobalDirectory> pathRequirement = allDirReadyServiceBuilder.requires(serviceName);
            allDirReadySuppliers.add(pathRequirement);
        }
    }
    if (!allDirReadySuppliers.isEmpty()) {
        GlobalDirectoryDeploymentService globalDirDepService = new GlobalDirectoryDeploymentService(allDirReadySuppliers, externalModuleService, moduleSpecification, moduleLoader, serviceRegistry, externalServiceTarget);
        allDirReadyServiceBuilder.requires(phaseContext.getPhaseServiceName());
        allDirReadyServiceBuilder.setInstance(globalDirDepService).install();
        phaseContext.requires(allDirReadyServiceName, new DelegatingSupplier());
    }
}
Also used : ModuleLoader(org.jboss.modules.ModuleLoader) ServiceTarget(org.jboss.msc.service.ServiceTarget) ArrayList(java.util.ArrayList) GlobalDirectoryDeploymentService(org.jboss.as.ee.subsystem.GlobalDirectoryDeploymentService) CapabilityServiceSupport(org.jboss.as.controller.capability.CapabilityServiceSupport) DelegatingSupplier(org.jboss.as.server.deployment.DelegatingSupplier) ServiceName(org.jboss.msc.service.ServiceName) ModuleSpecification(org.jboss.as.server.deployment.module.ModuleSpecification) GlobalDirectoryResourceDefinition(org.jboss.as.ee.subsystem.GlobalDirectoryResourceDefinition) DelegatingSupplier(org.jboss.as.server.deployment.DelegatingSupplier) Supplier(java.util.function.Supplier) ServiceRegistry(org.jboss.msc.service.ServiceRegistry) ExternalModule(org.jboss.as.server.moduleservice.ExternalModule) DeploymentUnit(org.jboss.as.server.deployment.DeploymentUnit)

Example 53 with CapabilityServiceSupport

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

the class JaccEarDeploymentProcessor method deploy.

/**
 * {@inheritDoc}
 */
@Override
public void deploy(DeploymentPhaseContext phaseContext) throws DeploymentUnitProcessingException {
    final DeploymentUnit deploymentUnit = phaseContext.getDeploymentUnit();
    AbstractSecurityDeployer<?> deployer = null;
    if (DeploymentTypeMarker.isType(DeploymentType.EAR, deploymentUnit)) {
        deployer = new EarSecurityDeployer();
        JaccService<?> service = deployer.deploy(deploymentUnit);
        if (service != null) {
            final ServiceName jaccServiceName = deploymentUnit.getServiceName().append(JaccService.SERVICE_NAME);
            final ServiceTarget serviceTarget = phaseContext.getServiceTarget();
            ServiceBuilder<?> builder = serviceTarget.addService(jaccServiceName, service);
            if (deploymentUnit.getParent() != null) {
                // add dependency to parent policy
                final DeploymentUnit parentDU = deploymentUnit.getParent();
                builder.addDependency(parentDU.getServiceName().append(JaccService.SERVICE_NAME), PolicyConfiguration.class, service.getParentPolicyInjector());
            }
            CapabilityServiceSupport capabilitySupport = deploymentUnit.getAttachment(Attachments.CAPABILITY_SERVICE_SUPPORT);
            builder.addDependencies(capabilitySupport.getCapabilityServiceName(jaccCapabilityName));
            builder.setInitialMode(Mode.ACTIVE).install();
        }
    }
}
Also used : ServiceName(org.jboss.msc.service.ServiceName) ServiceTarget(org.jboss.msc.service.ServiceTarget) DeploymentUnit(org.jboss.as.server.deployment.DeploymentUnit) CapabilityServiceSupport(org.jboss.as.controller.capability.CapabilityServiceSupport)

Example 54 with CapabilityServiceSupport

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

the class MessageDrivenComponentDescription method createConfiguration.

@Override
public ComponentConfiguration createConfiguration(final ClassReflectionIndex classIndex, final ClassLoader moduleClassLoader, final ModuleLoader moduleLoader) {
    final ComponentConfiguration mdbComponentConfiguration = new ComponentConfiguration(this, classIndex, moduleClassLoader, moduleLoader);
    // setup the component create service
    final Class<?> messageListenerInterface;
    try {
        messageListenerInterface = Class.forName(getMessageListenerInterfaceName(), true, moduleClassLoader);
    } catch (ClassNotFoundException e) {
        throw new RuntimeException(e);
    }
    mdbComponentConfiguration.setComponentCreateServiceFactory(new MessageDrivenComponentCreateServiceFactory(messageListenerInterface));
    final MessageDrivenComponentDescription mdbComponentDescription = (MessageDrivenComponentDescription) mdbComponentConfiguration.getComponentDescription();
    // setup a configurator to inject the PoolConfig in the MessageDrivenComponentCreateService
    getConfigurators().add(new ComponentConfigurator() {

        @Override
        public void configure(DeploymentPhaseContext context, ComponentDescription description, ComponentConfiguration configuration) throws DeploymentUnitProcessingException {
            // get CapabilitySupport to resolve service names
            final CapabilityServiceSupport support = context.getDeploymentUnit().getAttachment(CAPABILITY_SERVICE_SUPPORT);
            MessageDrivenComponentDescription mdbDescription = (MessageDrivenComponentDescription) description;
            configuration.getCreateDependencies().add(new DependencyConfigurator<Service<Component>>() {

                @Override
                public void configureDependency(ServiceBuilder<?> serviceBuilder, Service<Component> service) throws DeploymentUnitProcessingException {
                    // add any dependencies here
                    final MessageDrivenComponentCreateService mdbComponentCreateService = (MessageDrivenComponentCreateService) service;
                    final String poolName = mdbComponentDescription.getPoolConfigName();
                    // If the default mdb pool config itself is not configured, then pooling is disabled for the bean
                    if (poolName == null) {
                        if (mdbComponentDescription.isDefaultMdbPoolAvailable()) {
                            ServiceName defaultPoolConfigServiceName = support.getCapabilityServiceName(DEFAULT_MDB_POOL_CONFIG_CAPABILITY_NAME);
                            serviceBuilder.addDependency(defaultPoolConfigServiceName, PoolConfig.class, mdbComponentCreateService.getPoolConfigInjector());
                        }
                    } else {
                        // pool name has been explicitly set so the pool config is a required dependency
                        ServiceName poolConfigServiceName = support.getCapabilityServiceName(STRICT_MAX_POOL_CONFIG_CAPABILITY_NAME, poolName);
                        serviceBuilder.addDependency(poolConfigServiceName, PoolConfig.class, mdbComponentCreateService.getPoolConfigInjector());
                    }
                }
            });
        }
    });
    // set up a configurator to inject ResourceAdapterService dependencies into the MessageDrivenComponentCreateService
    getConfigurators().add(new ComponentConfigurator() {

        @Override
        public void configure(DeploymentPhaseContext context, ComponentDescription description, ComponentConfiguration configuration) throws DeploymentUnitProcessingException {
            // get CapabilitySupport to resolve service names
            final CapabilityServiceSupport support = context.getDeploymentUnit().getAttachment(CAPABILITY_SERVICE_SUPPORT);
            configuration.getCreateDependencies().add(new DependencyConfigurator<MessageDrivenComponentCreateService>() {

                @Override
                public void configureDependency(ServiceBuilder<?> serviceBuilder, MessageDrivenComponentCreateService service) throws DeploymentUnitProcessingException {
                    final ServiceName raServiceName = ConnectorServices.getResourceAdapterServiceName(MessageDrivenComponentDescription.this.resourceAdapterName);
                    // add the dependency on the RA service
                    serviceBuilder.addDependency(ConnectorServices.RA_REPOSITORY_SERVICE, ResourceAdapterRepository.class, service.getResourceAdapterRepositoryInjector());
                    serviceBuilder.addDependency(raServiceName, ResourceAdapter.class, service.getResourceAdapterInjector());
                }
            });
        }
    });
    getConfigurators().add(new ComponentConfigurator() {

        @Override
        public void configure(DeploymentPhaseContext context, ComponentDescription description, ComponentConfiguration configuration) throws DeploymentUnitProcessingException {
            final ServiceName suspendControllerName = context.getDeploymentUnit().getAttachment(CAPABILITY_SERVICE_SUPPORT).getCapabilityServiceName("org.wildfly.server.suspend-controller");
            configuration.getCreateDependencies().add(new DependencyConfigurator<MessageDrivenComponentCreateService>() {

                @Override
                public void configureDependency(final ServiceBuilder<?> serviceBuilder, final MessageDrivenComponentCreateService mdbComponentCreateService) throws DeploymentUnitProcessingException {
                    serviceBuilder.addDependency(suspendControllerName, SuspendController.class, mdbComponentCreateService.getSuspendControllerInjectedValue());
                }
            });
        }
    });
    // add the BMT interceptor
    if (TransactionManagementType.BEAN.equals(this.getTransactionManagementType())) {
        getConfigurators().add(new ComponentConfigurator() {

            @Override
            public void configure(final DeploymentPhaseContext context, final ComponentDescription description, final ComponentConfiguration configuration) throws DeploymentUnitProcessingException {
                // add the bmt interceptor factory
                configuration.addComponentInterceptor(EjbBMTInterceptor.FACTORY, InterceptorOrder.Component.BMT_TRANSACTION_INTERCEPTOR, false);
            }
        });
    } else {
        getConfigurators().add(new ComponentConfigurator() {

            @Override
            public void configure(final DeploymentPhaseContext context, final ComponentDescription description, final ComponentConfiguration configuration) throws DeploymentUnitProcessingException {
                final EEApplicationClasses applicationClasses = context.getDeploymentUnit().getAttachment(Attachments.EE_APPLICATION_CLASSES_DESCRIPTION);
                InterceptorClassDescription interceptorConfig = ComponentDescription.mergeInterceptorConfig(configuration.getComponentClass(), applicationClasses.getClassByName(description.getComponentClassName()), description, MetadataCompleteMarker.isMetadataComplete(context.getDeploymentUnit()));
                configuration.addPostConstructInterceptor(new LifecycleCMTTxInterceptor.Factory(interceptorConfig.getPostConstruct(), true), InterceptorOrder.ComponentPostConstruct.TRANSACTION_INTERCEPTOR);
                configuration.addPreDestroyInterceptor(new LifecycleCMTTxInterceptor.Factory(interceptorConfig.getPreDestroy(), true), InterceptorOrder.ComponentPreDestroy.TRANSACTION_INTERCEPTOR);
                configuration.addTimeoutViewInterceptor(TimerCMTTxInterceptor.FACTORY, InterceptorOrder.View.CMT_TRANSACTION_INTERCEPTOR);
            }
        });
    }
    return mdbComponentConfiguration;
}
Also used : DeploymentUnitProcessingException(org.jboss.as.server.deployment.DeploymentUnitProcessingException) EJBComponentDescription(org.jboss.as.ejb3.component.EJBComponentDescription) ComponentDescription(org.jboss.as.ee.component.ComponentDescription) ComponentConfigurator(org.jboss.as.ee.component.ComponentConfigurator) DependencyConfigurator(org.jboss.as.ee.component.DependencyConfigurator) Service(org.jboss.msc.service.Service) ImmediateInterceptorFactory(org.jboss.invocation.ImmediateInterceptorFactory) DeploymentPhaseContext(org.jboss.as.server.deployment.DeploymentPhaseContext) CapabilityServiceSupport(org.jboss.as.controller.capability.CapabilityServiceSupport) ServiceBuilder(org.jboss.msc.service.ServiceBuilder) ComponentConfiguration(org.jboss.as.ee.component.ComponentConfiguration) InterceptorClassDescription(org.jboss.as.ee.component.interceptors.InterceptorClassDescription) ServiceName(org.jboss.msc.service.ServiceName) EEApplicationClasses(org.jboss.as.ee.component.EEApplicationClasses) Component(org.jboss.as.ee.component.Component)

Example 55 with CapabilityServiceSupport

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

the class BatchEnvironmentProcessor method deploy.

@Override
public void deploy(final DeploymentPhaseContext phaseContext) throws DeploymentUnitProcessingException {
    final DeploymentUnit deploymentUnit = phaseContext.getDeploymentUnit();
    if (deploymentUnit.hasAttachment(Attachments.MODULE)) {
        BatchLogger.LOGGER.tracef("Processing deployment '%s' for the batch environment.", deploymentUnit.getName());
        // Configure and attach the job resolver for all deployments
        final WildFlyJobXmlResolver jobXmlResolver = WildFlyJobXmlResolver.forDeployment(deploymentUnit);
        // Skip the rest of the processing for EAR's, only sub-deployments need an environment configured
        if (DeploymentTypeMarker.isType(DeploymentType.EAR, deploymentUnit))
            return;
        // Get the class loader
        final Module module = deploymentUnit.getAttachment(Attachments.MODULE);
        final ClassLoader moduleClassLoader = module.getClassLoader();
        final ServiceTarget serviceTarget = phaseContext.getServiceTarget();
        JobRepository jobRepository = null;
        String jobRepositoryName = null;
        String dataSourceName = null;
        String jobExecutorName = null;
        Boolean restartJobsOnResume = null;
        // Check for a deployment descriptor
        BatchEnvironmentMetaData metaData = deploymentUnit.getAttachment(BatchAttachments.BATCH_ENVIRONMENT_META_DATA);
        if (metaData == null) {
            // Check the parent
            final DeploymentUnit parent = deploymentUnit.getParent();
            if (parent != null) {
                metaData = parent.getAttachment(BatchAttachments.BATCH_ENVIRONMENT_META_DATA);
            }
        }
        if (metaData != null) {
            jobRepository = metaData.getJobRepository();
            jobRepositoryName = metaData.getJobRepositoryName();
            dataSourceName = metaData.getDataSourceName();
            jobExecutorName = metaData.getExecutorName();
            restartJobsOnResume = metaData.getRestartJobsOnResume();
        }
        final CapabilityServiceSupport support = deploymentUnit.getAttachment(Attachments.CAPABILITY_SERVICE_SUPPORT);
        final String deploymentName = deploymentUnit.getName();
        // Create the job operator service used interact with a deployments batch job
        final JobOperatorService jobOperatorService = new JobOperatorService(restartJobsOnResume, deploymentName, jobXmlResolver);
        // Create the batch environment
        final EEModuleDescription eeModuleDescription = deploymentUnit.getAttachment(org.jboss.as.ee.component.Attachments.EE_MODULE_DESCRIPTION);
        final NamespaceContextSelector namespaceContextSelector = eeModuleDescription == null ? null : eeModuleDescription.getNamespaceContextSelector();
        final BatchEnvironmentService service = new BatchEnvironmentService(moduleClassLoader, jobXmlResolver, deploymentName, namespaceContextSelector);
        final ServiceBuilder<SecurityAwareBatchEnvironment> serviceBuilder = serviceTarget.addService(BatchServiceNames.batchEnvironmentServiceName(deploymentUnit), service);
        // Add a dependency to the thread-pool
        if (jobExecutorName != null) {
            // Register the named thread-pool capability
            serviceBuilder.addDependency(Capabilities.THREAD_POOL_CAPABILITY.getCapabilityServiceName(jobExecutorName), JobExecutor.class, service.getJobExecutorInjector());
        }
        // Register the required services
        serviceBuilder.addDependency(Capabilities.BATCH_CONFIGURATION_CAPABILITY.getCapabilityServiceName(), BatchConfiguration.class, service.getBatchConfigurationInjector());
        // Ensure local transaction support is started
        serviceBuilder.requires(support.getCapabilityServiceName(Capabilities.LOCAL_TRANSACTION_PROVIDER_CAPABILITY));
        final ServiceName artifactFactoryServiceName = BatchServiceNames.batchArtifactFactoryServiceName(deploymentUnit);
        final ArtifactFactoryService artifactFactoryService = new ArtifactFactoryService();
        final ServiceBuilder<ArtifactFactory> artifactFactoryServiceBuilder = serviceTarget.addService(artifactFactoryServiceName, artifactFactoryService);
        // Register the bean manager if this is a Jakarta Contexts and Dependency Injection deployment
        if (support.hasCapability(WELD_CAPABILITY_NAME)) {
            final WeldCapability api = support.getOptionalCapabilityRuntimeAPI(WELD_CAPABILITY_NAME, WeldCapability.class).get();
            if (api.isPartOfWeldDeployment(deploymentUnit)) {
                BatchLogger.LOGGER.tracef("Adding BeanManager service dependency for deployment %s", deploymentUnit.getName());
                api.addBeanManagerService(deploymentUnit, artifactFactoryServiceBuilder, artifactFactoryService.getBeanManagerInjector());
            }
        }
        artifactFactoryServiceBuilder.install();
        serviceBuilder.addDependency(artifactFactoryServiceName, WildFlyArtifactFactory.class, service.getArtifactFactoryInjector());
        if (jobRepositoryName != null) {
            // Register a named job repository
            serviceBuilder.addDependency(support.getCapabilityServiceName(Capabilities.JOB_REPOSITORY_CAPABILITY.getName(), jobRepositoryName), JobRepository.class, service.getJobRepositoryInjector());
        } else if (dataSourceName != null) {
            // Register a jdbc job repository with data-source
            final JdbcJobRepositoryService jdbcJobRepositoryService = new JdbcJobRepositoryService();
            final ServiceName jobRepositoryServiceName = support.getCapabilityServiceName(Capabilities.JOB_REPOSITORY_CAPABILITY.getName(), deploymentName);
            final ServiceBuilder<JobRepository> jobRepositoryServiceBuilder = Services.addServerExecutorDependency(serviceTarget.addService(jobRepositoryServiceName, jdbcJobRepositoryService), jdbcJobRepositoryService.getExecutorServiceInjector()).addDependency(support.getCapabilityServiceName(Capabilities.DATA_SOURCE_CAPABILITY, dataSourceName), DataSource.class, jdbcJobRepositoryService.getDataSourceInjector());
            jobRepositoryServiceBuilder.install();
            serviceBuilder.addDependency(jobRepositoryServiceName, JobRepository.class, service.getJobRepositoryInjector());
        } else if (jobRepository != null) {
            // Use the job repository as defined in the deployment descriptor
            service.getJobRepositoryInjector().setValue(new ImmediateValue<>(jobRepository));
        }
        if (rcPresent) {
            serviceBuilder.addDependency(RequestController.SERVICE_NAME, RequestController.class, service.getRequestControllerInjector());
        }
        // Install the batch environment service
        serviceBuilder.install();
        // Install the JobOperatorService
        ServiceName jobOperatorServiceName = BatchServiceNames.jobOperatorServiceName(deploymentUnit);
        Services.addServerExecutorDependency(serviceTarget.addService(jobOperatorServiceName, jobOperatorService).addDependency(support.getCapabilityServiceName(Capabilities.BATCH_CONFIGURATION_CAPABILITY.getName()), BatchConfiguration.class, jobOperatorService.getBatchConfigurationInjector()).addDependency(support.getCapabilityServiceName(Capabilities.SUSPEND_CONTROLLER_CAPABILITY), SuspendController.class, jobOperatorService.getSuspendControllerInjector()).addDependency(support.getCapabilityServiceName(Capabilities.PROCESS_STATE_NOTIFIER_CAPABILITY), ProcessStateNotifier.class, jobOperatorService.getProcessStateInjector()).addDependency(BatchServiceNames.batchEnvironmentServiceName(deploymentUnit), SecurityAwareBatchEnvironment.class, jobOperatorService.getBatchEnvironmentInjector()), jobOperatorService.getExecutorServiceInjector()).install();
        // Add the JobOperatorService to the deployment unit
        deploymentUnit.putAttachment(BatchAttachments.JOB_OPERATOR, jobOperatorService);
        deploymentUnit.addToAttachmentList(DEPLOYMENT_COMPLETE_SERVICES, jobOperatorServiceName);
        // Add the JobOperator to the context selector
        selector.registerContext(moduleClassLoader, JobOperatorContext.create(jobOperatorService));
    }
}
Also used : JobRepository(org.jberet.repository.JobRepository) NamespaceContextSelector(org.jboss.as.naming.context.NamespaceContextSelector) CapabilityServiceSupport(org.jboss.as.controller.capability.CapabilityServiceSupport) ServiceBuilder(org.jboss.msc.service.ServiceBuilder) EEModuleDescription(org.jboss.as.ee.component.EEModuleDescription) BatchConfiguration(org.wildfly.extension.batch.jberet.BatchConfiguration) ServiceTarget(org.jboss.msc.service.ServiceTarget) JdbcJobRepositoryService(org.wildfly.extension.batch.jberet.job.repository.JdbcJobRepositoryService) WeldCapability(org.jboss.as.weld.WeldCapability) ProcessStateNotifier(org.jboss.as.controller.ProcessStateNotifier) DataSource(javax.sql.DataSource) ArtifactFactory(org.jberet.spi.ArtifactFactory) ServiceName(org.jboss.msc.service.ServiceName) Module(org.jboss.modules.Module) 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