Search in sources :

Example 36 with ServiceName

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

the class DefaultStatefulBeanAccessTimeoutWriteHandler method updateOrCreateDefaultStatefulBeanAccessTimeoutService.

void updateOrCreateDefaultStatefulBeanAccessTimeoutService(final OperationContext context, final ModelNode model) throws OperationFailedException {
    final long defaultAccessTimeout = EJB3SubsystemRootResourceDefinition.DEFAULT_STATEFUL_BEAN_ACCESS_TIMEOUT.resolveModelAttribute(context, model).asLong();
    final ServiceName serviceName = DefaultAccessTimeoutService.STATEFUL_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 37 with ServiceName

use of org.jboss.msc.service.ServiceName 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 38 with ServiceName

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

the class TransactionJndiBindingProcessor method deploy.

@Override
public void deploy(DeploymentPhaseContext phaseContext) throws DeploymentUnitProcessingException {
    final DeploymentUnit deploymentUnit = phaseContext.getDeploymentUnit();
    final EEModuleDescription moduleDescription = deploymentUnit.getAttachment(Attachments.EE_MODULE_DESCRIPTION);
    if (moduleDescription == null) {
        return;
    }
    final ServiceTarget serviceTarget = phaseContext.getServiceTarget();
    //if this is a war we need to bind to the modules comp namespace
    if (DeploymentTypeMarker.isType(DeploymentType.WAR, deploymentUnit)) {
        final ServiceName moduleContextServiceName = ContextNames.contextServiceNameOfModule(moduleDescription.getApplicationName(), moduleDescription.getModuleName());
        bindServices(deploymentUnit, serviceTarget, moduleContextServiceName);
    }
    for (ComponentDescription component : moduleDescription.getComponentDescriptions()) {
        if (component.getNamingMode() == ComponentNamingMode.CREATE) {
            final ServiceName compContextServiceName = ContextNames.contextServiceNameOfComponent(moduleDescription.getApplicationName(), moduleDescription.getModuleName(), component.getComponentName());
            bindServices(deploymentUnit, serviceTarget, compContextServiceName);
        }
    }
}
Also used : ComponentDescription(org.jboss.as.ee.component.ComponentDescription) EEModuleDescription(org.jboss.as.ee.component.EEModuleDescription) ServiceName(org.jboss.msc.service.ServiceName) ServiceTarget(org.jboss.msc.service.ServiceTarget) DeploymentUnit(org.jboss.as.server.deployment.DeploymentUnit)

Example 39 with ServiceName

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

the class TransactionLeakRollbackProcessor method deploy.

@Override
public void deploy(DeploymentPhaseContext phaseContext) throws DeploymentUnitProcessingException {
    final DeploymentUnit deploymentUnit = phaseContext.getDeploymentUnit();
    final ServiceName serviceName = deploymentUnit.getServiceName().append(SERVICE_NAME);
    final TransactionRollbackSetupAction service = new TransactionRollbackSetupAction(serviceName);
    phaseContext.getServiceTarget().addService(serviceName, service).addDependency(TransactionManagerService.SERVICE_NAME, TransactionManager.class, service.getTransactionManager()).install();
    deploymentUnit.addToAttachmentList(org.jboss.as.ee.component.Attachments.WEB_SETUP_ACTIONS, service);
}
Also used : ServiceName(org.jboss.msc.service.ServiceName) TransactionManager(javax.transaction.TransactionManager) DeploymentUnit(org.jboss.as.server.deployment.DeploymentUnit)

Example 40 with ServiceName

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

the class SharedSessionManagerDeploymentProcessor method deploy.

@Override
public void deploy(DeploymentPhaseContext phaseContext) throws DeploymentUnitProcessingException {
    DeploymentUnit deploymentUnit = phaseContext.getDeploymentUnit();
    SharedSessionManagerConfig sharedConfig = deploymentUnit.getAttachment(UndertowAttachments.SHARED_SESSION_MANAGER_CONFIG);
    if (sharedConfig == null) {
        return;
    }
    ServiceTarget target = phaseContext.getServiceTarget();
    ServiceName deploymentServiceName = deploymentUnit.getServiceName();
    ServiceName managerServiceName = deploymentServiceName.append(SharedSessionManagerConfig.SHARED_SESSION_MANAGER_SERVICE_NAME);
    DistributableSessionManagerFactoryBuilder builder = new DistributableSessionManagerFactoryBuilderValue().getValue();
    if (builder != null) {
        CapabilityServiceSupport support = deploymentUnit.getAttachment(Attachments.CAPABILITY_SERVICE_SUPPORT);
        Module module = deploymentUnit.getAttachment(Attachments.MODULE);
        builder.build(support, target, managerServiceName, new SimpleDistributableSessionManagerConfiguration(sharedConfig, deploymentUnit.getName(), module)).setInitialMode(Mode.ON_DEMAND).install();
    } else {
        InMemorySessionManager manager = new InMemorySessionManager(deploymentUnit.getName(), sharedConfig.getMaxActiveSessions());
        if (sharedConfig.getSessionConfig() != null) {
            if (sharedConfig.getSessionConfig().getSessionTimeoutSet()) {
                manager.setDefaultSessionTimeout(sharedConfig.getSessionConfig().getSessionTimeout());
            }
        }
        SessionManagerFactory factory = new ImmediateSessionManagerFactory(manager);
        target.addService(managerServiceName, new ValueService<>(new ImmediateValue<>(factory))).setInitialMode(Mode.ON_DEMAND).install();
    }
    ServiceName codecServiceName = deploymentServiceName.append(SharedSessionManagerConfig.SHARED_SESSION_IDENTIFIER_CODEC_SERVICE_NAME);
    DistributableSessionIdentifierCodecBuilder sessionIdentifierCodecBuilder = new DistributableSessionIdentifierCodecBuilderValue().getValue();
    if (sessionIdentifierCodecBuilder != null) {
        sessionIdentifierCodecBuilder.build(target, codecServiceName, deploymentUnit.getName()).setInitialMode(Mode.ON_DEMAND).install();
    } else {
        // Fallback to simple codec if server does not support clustering
        SimpleSessionIdentifierCodecService.build(target, codecServiceName).setInitialMode(Mode.ON_DEMAND).install();
    }
}
Also used : DistributableSessionIdentifierCodecBuilderValue(org.wildfly.extension.undertow.session.DistributableSessionIdentifierCodecBuilderValue) ServiceTarget(org.jboss.msc.service.ServiceTarget) DistributableSessionManagerFactoryBuilderValue(org.wildfly.extension.undertow.session.DistributableSessionManagerFactoryBuilderValue) CapabilityServiceSupport(org.jboss.as.controller.capability.CapabilityServiceSupport) ImmediateValue(org.jboss.msc.value.ImmediateValue) DistributableSessionIdentifierCodecBuilder(org.wildfly.extension.undertow.session.DistributableSessionIdentifierCodecBuilder) SharedSessionManagerConfig(org.wildfly.extension.undertow.session.SharedSessionManagerConfig) SimpleDistributableSessionManagerConfiguration(org.wildfly.extension.undertow.session.SimpleDistributableSessionManagerConfiguration) DistributableSessionManagerFactoryBuilder(org.wildfly.extension.undertow.session.DistributableSessionManagerFactoryBuilder) ServiceName(org.jboss.msc.service.ServiceName) SessionManagerFactory(io.undertow.servlet.api.SessionManagerFactory) Module(org.jboss.modules.Module) DeploymentUnit(org.jboss.as.server.deployment.DeploymentUnit) InMemorySessionManager(io.undertow.server.session.InMemorySessionManager)

Aggregations

ServiceName (org.jboss.msc.service.ServiceName)289 ServiceTarget (org.jboss.msc.service.ServiceTarget)56 PathAddress (org.jboss.as.controller.PathAddress)54 ModelNode (org.jboss.dmr.ModelNode)48 DeploymentUnit (org.jboss.as.server.deployment.DeploymentUnit)44 ServiceRegistry (org.jboss.msc.service.ServiceRegistry)40 OperationFailedException (org.jboss.as.controller.OperationFailedException)33 Module (org.jboss.modules.Module)23 ServiceController (org.jboss.msc.service.ServiceController)23 ActiveMQServer (org.apache.activemq.artemis.core.server.ActiveMQServer)22 EEModuleDescription (org.jboss.as.ee.component.EEModuleDescription)22 ComponentDescription (org.jboss.as.ee.component.ComponentDescription)19 BinderService (org.jboss.as.naming.service.BinderService)18 HashSet (java.util.HashSet)17 ContextNames (org.jboss.as.naming.deployment.ContextNames)17 ServiceBuilder (org.jboss.msc.service.ServiceBuilder)15 HashMap (java.util.HashMap)14 DeploymentUnitProcessingException (org.jboss.as.server.deployment.DeploymentUnitProcessingException)14 ArrayList (java.util.ArrayList)13 OperationContext (org.jboss.as.controller.OperationContext)12