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