Search in sources :

Example 56 with ServiceRegistry

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();
    }
}
Also used : ServiceName(org.jboss.msc.service.ServiceName) ServiceRegistry(org.jboss.msc.service.ServiceRegistry) DefaultAccessTimeoutService(org.jboss.as.ejb3.component.DefaultAccessTimeoutService)

Example 57 with ServiceRegistry

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();
}
Also used : ServiceName(org.jboss.msc.service.ServiceName) LocalTransportProvider(org.jboss.as.ejb3.remote.LocalTransportProvider) ValueInjectionService(org.jboss.msc.service.ValueInjectionService) ServiceTarget(org.jboss.msc.service.ServiceTarget) ServiceRegistry(org.jboss.msc.service.ServiceRegistry) ModelNode(org.jboss.dmr.ModelNode)

Example 58 with ServiceRegistry

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());
}
Also used : OperationFailedException(org.jboss.as.controller.OperationFailedException) ServiceController(org.jboss.msc.service.ServiceController) ServiceRegistry(org.jboss.msc.service.ServiceRegistry)

Example 59 with ServiceRegistry

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);
    }
}
Also used : ServiceName(org.jboss.msc.service.ServiceName) ServiceRegistry(org.jboss.msc.service.ServiceRegistry)

Example 60 with ServiceRegistry

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);
}
Also used : OperationContext(org.jboss.as.controller.OperationContext) OperationStepHandler(org.jboss.as.controller.OperationStepHandler) OperationFailedException(org.jboss.as.controller.OperationFailedException) ServiceRegistry(org.jboss.msc.service.ServiceRegistry) ModelNode(org.jboss.dmr.ModelNode)

Aggregations

ServiceRegistry (org.jboss.msc.service.ServiceRegistry)74 ServiceName (org.jboss.msc.service.ServiceName)51 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 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 DivertConfiguration (org.apache.activemq.artemis.core.config.DivertConfiguration)2