Search in sources :

Example 1 with StrictMaxPoolConfig

use of org.jboss.as.ejb3.component.pool.StrictMaxPoolConfig 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)

Aggregations

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