use of org.jboss.msc.service.ServiceRegistry in project wildfly by wildfly.
the class DefaultSingletonBeanAccessTimeoutWriteHandler method updateOrCreateDefaultSingletonBeanAccessTimeoutService.
void updateOrCreateDefaultSingletonBeanAccessTimeoutService(final OperationContext context, final ModelNode model) throws OperationFailedException {
final long defaultAccessTimeout = EJB3SubsystemRootResourceDefinition.DEFAULT_SINGLETON_BEAN_ACCESS_TIMEOUT.resolveModelAttribute(context, model).asLong();
final ServiceName serviceName = DefaultAccessTimeoutService.SINGLETON_SERVICE_NAME;
final ServiceRegistry registry = context.getServiceRegistry(true);
final ServiceController<?> sc = registry.getService(serviceName);
if (sc != null) {
final DefaultAccessTimeoutService defaultAccessTimeoutService = DefaultAccessTimeoutService.class.cast(sc.getValue());
defaultAccessTimeoutService.setDefaultAccessTimeout(defaultAccessTimeout);
} else {
// create and install the service
final DefaultAccessTimeoutService defaultAccessTimeoutService = new DefaultAccessTimeoutService(defaultAccessTimeout);
final ServiceController<?> newService = context.getServiceTarget().addService(serviceName, defaultAccessTimeoutService).install();
}
}
use of org.jboss.msc.service.ServiceRegistry in project wildfly by wildfly.
the class EJBRemoteInvocationPassByValueWriteHandler method updateDefaultLocalEJBReceiverService.
void updateDefaultLocalEJBReceiverService(final OperationContext context, final ModelNode model) throws OperationFailedException {
final ModelNode passByValueModel = this.attributeDefinition.resolveModelAttribute(context, model);
final ServiceRegistry registry = context.getServiceRegistry(true);
final ServiceName localTransportProviderServiceName;
if (passByValueModel.isDefined()) {
final boolean passByValue = passByValueModel.asBoolean(true);
if (passByValue) {
localTransportProviderServiceName = LocalTransportProvider.BY_VALUE_SERVICE_NAME;
} else {
localTransportProviderServiceName = LocalTransportProvider.BY_REFERENCE_SERVICE_NAME;
}
} else {
localTransportProviderServiceName = LocalTransportProvider.BY_VALUE_SERVICE_NAME;
}
// uninstall the existing default local Jakarta Enterprise Beans receiver service
final ServiceController<?> existingDefaultLocalEJBReceiverServiceController = registry.getService(LocalTransportProvider.DEFAULT_LOCAL_TRANSPORT_PROVIDER_SERVICE_NAME);
if (existingDefaultLocalEJBReceiverServiceController != null) {
context.removeService(existingDefaultLocalEJBReceiverServiceController);
}
final ServiceTarget serviceTarget = context.getServiceTarget();
// now install the new default local Jakarta Enterprise Beans receiver service which points to an existing Local Jakarta Enterprise Beans receiver service
final ValueInjectionService<LocalTransportProvider> newDefaultLocalTransportProviderService = new ValueInjectionService<LocalTransportProvider>();
final ServiceBuilder<LocalTransportProvider> defaultLocalEJBReceiverServiceBuilder = serviceTarget.addService(LocalTransportProvider.DEFAULT_LOCAL_TRANSPORT_PROVIDER_SERVICE_NAME, newDefaultLocalTransportProviderService);
defaultLocalEJBReceiverServiceBuilder.addDependency(localTransportProviderServiceName, LocalTransportProvider.class, newDefaultLocalTransportProviderService.getInjector());
// install the service
defaultLocalEJBReceiverServiceBuilder.install();
}
use of org.jboss.msc.service.ServiceRegistry in project wildfly by wildfly.
the class AbstractEJBComponentRuntimeHandler method getComponent.
private T getComponent(final ServiceName serviceName, final PathAddress operationAddress, final OperationContext context, final boolean forWrite) throws OperationFailedException {
ServiceRegistry registry = context.getServiceRegistry(forWrite);
ServiceController<?> controller = registry.getService(serviceName);
if (controller == null) {
String exceptionMessage = EjbLogger.ROOT_LOGGER.noComponentAvailableForAddress(operationAddress);
throw new OperationFailedException(exceptionMessage);
}
ServiceController.State controllerState = controller.getState();
if (controllerState != ServiceController.State.UP) {
String exceptionMessage = EjbLogger.ROOT_LOGGER.invalidComponentState(operationAddress, controllerState, ServiceController.State.UP);
throw new OperationFailedException(exceptionMessage);
}
return componentClass.cast(controller.getValue());
}
use of org.jboss.msc.service.ServiceRegistry in project wildfly by wildfly.
the class JaxrsParamHandler method updateServerConfig.
/**
* Returns true if the update operation succeeds in modifying the runtime, false otherwise.
* @param context TODO
* @param attributeName
* @param value
*/
private void updateServerConfig(OperationContext context, String attributeName, ModelNode value, boolean isRevert) throws OperationFailedException {
ServiceRegistry registry = context.getServiceRegistry(true);
ServiceName name = JaxrsServerConfigService.CONFIG_SERVICE;
@SuppressWarnings("deprecation") JaxrsServerConfig config = (JaxrsServerConfig) registry.getRequiredService(name).getValue();
if (JaxrsConstants.JAXRS_2_0_REQUEST_MATCHING.equals(attributeName)) {
config.setJaxrs20RequestMatching(value);
} else if (JaxrsConstants.RESTEASY_ADD_CHARSET.equals(attributeName)) {
config.setResteasyAddCharset(value);
} else if (JaxrsConstants.RESTEASY_BUFFER_EXCEPTION_ENTITY.equals(attributeName)) {
config.setResteasyBufferExceptionEntity(value);
} else if (JaxrsConstants.RESTEASY_DISABLE_HTML_SANITIZER.equals(attributeName)) {
config.setResteasyDisableHtmlSanitizer(value);
} else if (JaxrsConstants.RESTEASY_DISABLE_PROVIDERS.equals(attributeName)) {
config.setResteasyDisableProviders(value);
} else if (JaxrsConstants.RESTEASY_DOCUMENT_EXPAND_ENTITY_REFERENCES.equals(attributeName)) {
config.setResteasyDocumentExpandEntityReferences(value);
} else if (JaxrsConstants.RESTEASY_DOCUMENT_SECURE_DISABLE_DTDS.equals(attributeName)) {
config.setResteasySecureDisableDTDs(value);
} else if (JaxrsConstants.RESTEASY_DOCUMENT_SECURE_PROCESSING_FEATURE.equals(attributeName)) {
config.setResteasyDocumentSecureProcessingFeature(value);
} else if (JaxrsConstants.RESTEASY_GZIP_MAX_INPUT.equals(attributeName)) {
config.setResteasyGzipMaxInput(value);
} else if (JaxrsConstants.RESTEASY_JNDI_RESOURCES.equals(attributeName)) {
config.setResteasyJndiResources(value);
} else if (JaxrsConstants.RESTEASY_LANGUAGE_MAPPINGS.equals(attributeName)) {
config.setResteasyLanguageMappings(value);
} else if (JaxrsConstants.RESTEASY_MEDIA_TYPE_MAPPINGS.equals(attributeName)) {
config.setResteasyMediaTypeMappings(value);
} else if (JaxrsConstants.RESTEASY_MEDIA_TYPE_PARAM_MAPPING.equals(attributeName)) {
config.setResteasyMediaTypeParamMapping(value);
} else if (JaxrsConstants.RESTEASY_PREFER_JACKSON_OVER_JSONB.equals(attributeName)) {
config.setResteasyPreferJacksonOverJsonB(value);
} else if (JaxrsConstants.RESTEASY_PROVIDERS.equals(attributeName)) {
config.setResteasyProviders(value);
} else if (JaxrsConstants.RESTEASY_RFC7232_PRECONDITIONS.equals(attributeName)) {
config.setResteasyRFC7232Preconditions(value);
} else if (JaxrsConstants.RESTEASY_ROLE_BASED_SECURITY.equals(attributeName)) {
config.setResteasyRoleBasedSecurity(value);
} else if (JaxrsConstants.RESTEASY_SECURE_RANDOM_MAX_USE.equals(attributeName)) {
config.setResteasySecureRandomMaxUse(value);
} else if (JaxrsConstants.RESTEASY_USE_BUILTIN_PROVIDERS.equals(attributeName)) {
config.setResteasyUseBuiltinProviders(value);
} else if (JaxrsConstants.RESTEASY_USE_CONTAINER_FORM_PARAMS.equals(attributeName)) {
config.setResteasyUseContainerFormParams(value);
} else if (JaxrsConstants.RESTEASY_WIDER_REQUEST_MATCHING.equals(attributeName)) {
config.setResteasyWiderRequestMatching(value);
}
}
use of org.jboss.msc.service.ServiceRegistry in project wildfly by wildfly.
the class JdrReportRequestHandler method execute.
@Override
public void execute(OperationContext context, ModelNode operation) throws OperationFailedException {
// In MODEL stage, just validate the request. Unnecessary if the request has no parameters
validator.validate(operation);
// Register a handler for the RUNTIME stage
context.addStep(new OperationStepHandler() {
@Override
public void execute(OperationContext context, ModelNode operation) throws OperationFailedException {
ServiceRegistry registry = context.getServiceRegistry(false);
JdrReportCollector jdrCollector = JdrReportCollector.class.cast(registry.getRequiredService(JdrReportService.SERVICE_NAME).getValue());
ModelNode response = context.getResult();
JdrReport report = jdrCollector.collect();
if (report.getStartTime() != null) {
response.get("start-time").set(report.getStartTime());
}
if (report.getEndTime() != null) {
response.get("end-time").set(report.getEndTime());
}
response.get("report-location").set(report.getLocation());
context.completeStep(OperationContext.RollbackHandler.NOOP_ROLLBACK_HANDLER);
}
}, OperationContext.Stage.RUNTIME);
}
Aggregations