Search in sources :

Example 6 with CapabilityServiceTarget

use of org.jboss.as.controller.CapabilityServiceTarget in project wildfly by wildfly.

the class StrictMaxPoolAdd method performRuntime.

@Override
protected void performRuntime(OperationContext context, ModelNode operation, ModelNode strictMaxPoolModel) throws OperationFailedException {
    final String poolName = PathAddress.pathAddress(operation.get(ModelDescriptionConstants.ADDRESS)).getLastElement().getValue();
    final int maxPoolSize = StrictMaxPoolResourceDefinition.MAX_POOL_SIZE.resolveModelAttribute(context, strictMaxPoolModel).asInt();
    final Derive derive = StrictMaxPoolResourceDefinition.parseDeriveSize(context, strictMaxPoolModel);
    final long timeout = StrictMaxPoolResourceDefinition.INSTANCE_ACQUISITION_TIMEOUT.resolveModelAttribute(context, strictMaxPoolModel).asLong();
    final String unit = StrictMaxPoolResourceDefinition.INSTANCE_ACQUISITION_TIMEOUT_UNIT.resolveModelAttribute(context, strictMaxPoolModel).asString();
    // create and install the service
    final StrictMaxPoolConfigService poolConfigService = new StrictMaxPoolConfigService(poolName, maxPoolSize, derive, timeout, TimeUnit.valueOf(unit));
    CapabilityServiceTarget capabilityServiceTarget = context.getCapabilityServiceTarget();
    CapabilityServiceBuilder<StrictMaxPoolConfig> capabilityServiceBuilder = capabilityServiceTarget.addCapability(StrictMaxPoolResourceDefinition.STRICT_MAX_POOL_CONFIG_CAPABILITY, poolConfigService);
    if (context.hasOptionalCapability(IO_MAX_THREADS_RUNTIME_CAPABILITY_NAME, null, null)) {
        capabilityServiceBuilder.addCapabilityRequirement(IO_MAX_THREADS_RUNTIME_CAPABILITY_NAME, Integer.class, poolConfigService.getMaxThreadsInjector());
    }
    capabilityServiceBuilder.install();
}
Also used : StrictMaxPoolConfig(org.jboss.as.ejb3.component.pool.StrictMaxPoolConfig) Derive(org.jboss.as.ejb3.component.pool.StrictMaxPoolConfigService.Derive) StrictMaxPoolConfigService(org.jboss.as.ejb3.component.pool.StrictMaxPoolConfigService) CapabilityServiceTarget(org.jboss.as.controller.CapabilityServiceTarget)

Example 7 with CapabilityServiceTarget

use of org.jboss.as.controller.CapabilityServiceTarget in project wildfly by wildfly.

the class MailSessionAdd method installRuntimeServices.

static void installRuntimeServices(OperationContext context, PathAddress address, ModelNode fullModel) throws OperationFailedException {
    final String jndiName = getJndiName(fullModel, context);
    final CapabilityServiceTarget serviceTarget = context.getCapabilityServiceTarget();
    final MailSessionConfig config = from(context, fullModel);
    final MailSessionService service = new MailSessionService(config);
    final CapabilityServiceBuilder mailSessionBuilder = serviceTarget.addCapability(SESSION_CAPABILITY.fromBaseCapability(address.getLastElement().getValue())).setInstance(service);
    addOutboundSocketDependency(service, mailSessionBuilder, config.getImapServer());
    addCredentialStoreReference(config.getImapServer(), context, fullModel, mailSessionBuilder, MailSubsystemModel.IMAP_SERVER_PATH);
    addOutboundSocketDependency(service, mailSessionBuilder, config.getPop3Server());
    addCredentialStoreReference(config.getPop3Server(), context, fullModel, mailSessionBuilder, MailSubsystemModel.POP3_SERVER_PATH);
    addOutboundSocketDependency(service, mailSessionBuilder, config.getSmtpServer());
    addCredentialStoreReference(config.getSmtpServer(), context, fullModel, mailSessionBuilder, MailSubsystemModel.SMTP_SERVER_PATH);
    for (CustomServerConfig server : config.getCustomServers()) {
        if (server.getOutgoingSocketBinding() != null) {
            addOutboundSocketDependency(service, mailSessionBuilder, server);
        }
        addCredentialStoreReference(server, context, fullModel, mailSessionBuilder, PathElement.pathElement(MailSubsystemModel.CUSTOM_SERVER_PATH.getKey(), server.getProtocol()));
    }
    mailSessionBuilder.addAliases(MAIL_SESSION_SERVICE_NAME.append(address.getLastElement().getValue()));
    final ManagedReferenceFactory valueManagedReferenceFactory = new MailSessionManagedReferenceFactory(service);
    final ContextNames.BindInfo bindInfo = ContextNames.bindInfoFor(jndiName);
    final BinderService binderService = new BinderService(bindInfo.getBindName());
    binderService.getManagedObjectInjector().inject(valueManagedReferenceFactory);
    final ServiceBuilder<?> binderBuilder = serviceTarget.addService(bindInfo.getBinderServiceName(), binderService).addDependency(bindInfo.getParentContextServiceName(), ServiceBasedNamingStore.class, binderService.getNamingStoreInjector()).addListener(new LifecycleListener() {

        private volatile boolean bound;

        @Override
        public void handleEvent(final ServiceController<?> controller, final LifecycleEvent event) {
            switch(event) {
                case UP:
                    {
                        MailLogger.ROOT_LOGGER.boundMailSession(jndiName);
                        bound = true;
                        break;
                    }
                case DOWN:
                    {
                        if (bound) {
                            MailLogger.ROOT_LOGGER.unboundMailSession(jndiName);
                        }
                        break;
                    }
                case REMOVED:
                    {
                        MailLogger.ROOT_LOGGER.removedMailSession(jndiName);
                        break;
                    }
            }
        }
    });
    mailSessionBuilder.setInitialMode(ServiceController.Mode.ACTIVE).install();
    binderBuilder.setInitialMode(ServiceController.Mode.ACTIVE).install();
}
Also used : LifecycleListener(org.jboss.msc.service.LifecycleListener) BinderService(org.jboss.as.naming.service.BinderService) CapabilityServiceBuilder(org.jboss.as.controller.CapabilityServiceBuilder) ServiceBasedNamingStore(org.jboss.as.naming.ServiceBasedNamingStore) ManagedReferenceFactory(org.jboss.as.naming.ManagedReferenceFactory) LifecycleEvent(org.jboss.msc.service.LifecycleEvent) CapabilityServiceTarget(org.jboss.as.controller.CapabilityServiceTarget) ContextNames(org.jboss.as.naming.deployment.ContextNames)

Example 8 with CapabilityServiceTarget

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

Aggregations

CapabilityServiceTarget (org.jboss.as.controller.CapabilityServiceTarget)8 ContextNames (org.jboss.as.naming.deployment.ContextNames)2 ModelNode (org.jboss.dmr.ModelNode)2 PathHandler (io.undertow.server.handlers.PathHandler)1 TransactionSynchronizationRegistry (javax.transaction.TransactionSynchronizationRegistry)1 RaDeploymentActivator (org.jboss.as.connector.deployers.ra.RaDeploymentActivator)1 DriverRegistryService (org.jboss.as.connector.services.driver.registry.DriverRegistryService)1 TransactionIntegrationService (org.jboss.as.connector.services.transactionintegration.TransactionIntegrationService)1 CapabilityServiceBuilder (org.jboss.as.controller.CapabilityServiceBuilder)1 CapabilityServiceSupport (org.jboss.as.controller.capability.CapabilityServiceSupport)1 StrictMaxPoolConfig (org.jboss.as.ejb3.component.pool.StrictMaxPoolConfig)1 StrictMaxPoolConfigService (org.jboss.as.ejb3.component.pool.StrictMaxPoolConfigService)1 Derive (org.jboss.as.ejb3.component.pool.StrictMaxPoolConfigService.Derive)1 DatabaseTimerPersistence (org.jboss.as.ejb3.timerservice.persistence.database.DatabaseTimerPersistence)1 FileTimerPersistence (org.jboss.as.ejb3.timerservice.persistence.filestore.FileTimerPersistence)1 ManagedReferenceFactory (org.jboss.as.naming.ManagedReferenceFactory)1 ServiceBasedNamingStore (org.jboss.as.naming.ServiceBasedNamingStore)1 BinderService (org.jboss.as.naming.service.BinderService)1 SocketBinding (org.jboss.as.network.SocketBinding)1 AbstractDeploymentChainStep (org.jboss.as.server.AbstractDeploymentChainStep)1