Search in sources :

Example 21 with ServiceRegistry

use of org.jboss.msc.service.ServiceRegistry in project wildfly by wildfly.

the class StrictMaxPoolWriteHandler method applyModelToRuntime.

private void applyModelToRuntime(OperationContext context, ModelNode operation, String attributeName, ModelNode model) throws OperationFailedException {
    final String poolName = PathAddress.pathAddress(operation.get(ModelDescriptionConstants.OP_ADDR)).getLastElement().getValue();
    ServiceName serviceName = context.getCapabilityServiceName(StrictMaxPoolResourceDefinition.STRICT_MAX_POOL_CONFIG_CAPABILITY_NAME, poolName, StrictMaxPoolConfigService.class);
    final ServiceRegistry registry = context.getServiceRegistry(true);
    ServiceController<?> sc = registry.getService(serviceName);
    if (sc != null) {
        StrictMaxPoolConfigService smpc = (StrictMaxPoolConfigService) sc.getService();
        if (smpc != null) {
            if (StrictMaxPoolResourceDefinition.MAX_POOL_SIZE.getName().equals(attributeName)) {
                int maxPoolSize = StrictMaxPoolResourceDefinition.MAX_POOL_SIZE.resolveModelAttribute(context, model).asInt(-1);
                smpc.setMaxPoolSize(maxPoolSize);
            } else if (StrictMaxPoolResourceDefinition.DERIVE_SIZE.getName().equals(attributeName)) {
                StrictMaxPoolConfigService.Derive derive = StrictMaxPoolResourceDefinition.parseDeriveSize(context, model);
                smpc.setDerive(derive);
            } else if (StrictMaxPoolResourceDefinition.INSTANCE_ACQUISITION_TIMEOUT.getName().equals(attributeName)) {
                long timeout = StrictMaxPoolResourceDefinition.INSTANCE_ACQUISITION_TIMEOUT.resolveModelAttribute(context, model).asLong();
                smpc.setTimeout(timeout);
            } else if (StrictMaxPoolResourceDefinition.INSTANCE_ACQUISITION_TIMEOUT_UNIT.getName().equals(attributeName)) {
                String timeoutUnit = StrictMaxPoolResourceDefinition.INSTANCE_ACQUISITION_TIMEOUT_UNIT.resolveModelAttribute(context, model).asString();
                smpc.setTimeoutUnit(TimeUnit.valueOf(timeoutUnit));
            }
        }
    }
}
Also used : ServiceName(org.jboss.msc.service.ServiceName) ServiceRegistry(org.jboss.msc.service.ServiceRegistry) StrictMaxPoolConfigService(org.jboss.as.ejb3.component.pool.StrictMaxPoolConfigService)

Example 22 with ServiceRegistry

use of org.jboss.msc.service.ServiceRegistry in project wildfly by wildfly.

the class EJBNameRegexWriteHandler method updateRegexAllowed.

void updateRegexAllowed(final OperationContext context, final ModelNode model) throws OperationFailedException {
    final ModelNode allowRegex = this.attributeDefinition.resolveModelAttribute(context, model);
    final ServiceRegistry registry = context.getServiceRegistry(true);
    final ServiceController<?> ejbNameServiceController = registry.getService(EjbNameRegexService.SERVICE_NAME);
    EjbNameRegexService service = (EjbNameRegexService) ejbNameServiceController.getValue();
    if (!allowRegex.isDefined()) {
        service.setEjbNameRegexAllowed(false);
    } else {
        service.setEjbNameRegexAllowed(allowRegex.asBoolean());
    }
}
Also used : ServiceRegistry(org.jboss.msc.service.ServiceRegistry) ModelNode(org.jboss.dmr.ModelNode)

Example 23 with ServiceRegistry

use of org.jboss.msc.service.ServiceRegistry in project wildfly by wildfly.

the class ExceptionLoggingWriteHandler method updateOrCreateDefaultExceptionLoggingEnabledService.

void updateOrCreateDefaultExceptionLoggingEnabledService(final OperationContext context, final ModelNode model) throws OperationFailedException {
    final boolean enabled = EJB3SubsystemRootResourceDefinition.LOG_EJB_EXCEPTIONS.resolveModelAttribute(context, model).asBoolean();
    final ServiceName serviceName = LoggingInterceptor.LOGGING_ENABLED_SERVICE_NAME;
    final ServiceRegistry registry = context.getServiceRegistry(true);
    final ServiceController sc = registry.getService(serviceName);
    if (sc != null) {
        final AtomicBoolean value = (AtomicBoolean) sc.getValue();
        value.set(enabled);
    } else {
        // create and install the service
        final ValueService<AtomicBoolean> service = new ValueService<>(new ImmediateValue<>(new AtomicBoolean(enabled)));
        context.getServiceTarget().addService(serviceName, service).install();
    }
}
Also used : AtomicBoolean(java.util.concurrent.atomic.AtomicBoolean) ServiceName(org.jboss.msc.service.ServiceName) ServiceController(org.jboss.msc.service.ServiceController) ServiceRegistry(org.jboss.msc.service.ServiceRegistry) ValueService(org.jboss.msc.service.ValueService)

Example 24 with ServiceRegistry

use of org.jboss.msc.service.ServiceRegistry in project wildfly by wildfly.

the class LegacyDistributedSingletonService method start.

@SuppressWarnings("unchecked")
@Override
public void start(StartContext context) throws StartException {
    super.start(context);
    ServiceRegistry registry = context.getController().getServiceContainer();
    this.primaryController = (ServiceController<T>) registry.getService(this.getServiceName().append("primary"));
    this.backupController = (ServiceController<T>) registry.getService(this.getServiceName().append("backup"));
    this.started = true;
}
Also used : ServiceRegistry(org.jboss.msc.service.ServiceRegistry)

Example 25 with ServiceRegistry

use of org.jboss.msc.service.ServiceRegistry in project wildfly by wildfly.

the class DefaultSessionBeanAccessTimeoutWriteHandler method applyModelToRuntime.

private void applyModelToRuntime(OperationContext context, final ModelNode model) throws OperationFailedException {
    long timeout = attribute.resolveModelAttribute(context, model).asLong();
    final ServiceRegistry serviceRegistry = context.getServiceRegistry(true);
    ServiceController<DefaultAccessTimeoutService> controller = (ServiceController<DefaultAccessTimeoutService>) serviceRegistry.getService(serviceName);
    if (controller != null) {
        DefaultAccessTimeoutService service = controller.getValue();
        if (service != null) {
            service.setDefaultAccessTimeout(timeout);
        }
    }
}
Also used : ServiceController(org.jboss.msc.service.ServiceController) ServiceRegistry(org.jboss.msc.service.ServiceRegistry) DefaultAccessTimeoutService(org.jboss.as.ejb3.component.DefaultAccessTimeoutService)

Aggregations

ServiceRegistry (org.jboss.msc.service.ServiceRegistry)75 ServiceName (org.jboss.msc.service.ServiceName)52 ModelNode (org.jboss.dmr.ModelNode)22 PathAddress (org.jboss.as.controller.PathAddress)15 ServiceTarget (org.jboss.msc.service.ServiceTarget)15 OperationFailedException (org.jboss.as.controller.OperationFailedException)13 ServiceController (org.jboss.msc.service.ServiceController)12 ActiveMQServer (org.apache.activemq.artemis.core.server.ActiveMQServer)8 ServiceBuilder (org.jboss.msc.service.ServiceBuilder)8 OperationContext (org.jboss.as.controller.OperationContext)6 Resource (org.jboss.as.controller.registry.Resource)6 AttributeDefinition (org.jboss.as.controller.AttributeDefinition)5 Activation (org.jboss.jca.common.api.metadata.resourceadapter.Activation)5 OperationStepHandler (org.jboss.as.controller.OperationStepHandler)4 PathElement (org.jboss.as.controller.PathElement)4 EmbeddedCacheManager (org.infinispan.manager.EmbeddedCacheManager)3 DefaultAccessTimeoutService (org.jboss.as.ejb3.component.DefaultAccessTimeoutService)3 DeploymentUnit (org.jboss.as.server.deployment.DeploymentUnit)3 ArrayList (java.util.ArrayList)2 BridgeConfiguration (org.apache.activemq.artemis.core.config.BridgeConfiguration)2