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();
}
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();
}
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);
}
Aggregations