Search in sources :

Example 31 with ServiceName

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

the class SingletonComponent method instantiateComponentInstance.

@Override
protected BasicComponentInstance instantiateComponentInstance(Interceptor preDestroyInterceptor, Map<Method, Interceptor> methodInterceptors, Map<Object, Object> context) {
    // synchronized from getComponentInstance
    assert Thread.holdsLock(creationLock);
    if (dependsOn != null) {
        for (ServiceName serviceName : dependsOn) {
            final ServiceController<Component> service = (ServiceController<Component>) currentServiceContainer().getRequiredService(serviceName);
            final Component component = service.getValue();
            if (component instanceof SingletonComponent) {
                ((SingletonComponent) component).getComponentInstance();
            }
        }
    }
    return new SingletonComponentInstance(this, preDestroyInterceptor, methodInterceptors);
}
Also used : ServiceName(org.jboss.msc.service.ServiceName) ServiceController(org.jboss.msc.service.ServiceController) SessionBeanComponent(org.jboss.as.ejb3.component.session.SessionBeanComponent) LockableComponent(org.jboss.as.ejb3.concurrency.LockableComponent) Component(org.jboss.as.ee.component.Component)

Example 32 with ServiceName

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

the class PassivationStoreWriteHandler method applyModelToRuntime.

private void applyModelToRuntime(OperationContext context, ModelNode operation, String attributeName, ModelNode model) throws OperationFailedException {
    String name = PathAddress.pathAddress(operation.get(ModelDescriptionConstants.OP_ADDR)).getLastElement().getValue();
    ServiceName serviceName = DistributableCacheFactoryBuilderService.getServiceName(name);
    ServiceRegistry registry = context.getServiceRegistry(true);
    ServiceController<?> service = registry.getService(serviceName);
    if (service != null) {
        DistributableCacheFactoryBuilder<?, ?> builder = (DistributableCacheFactoryBuilder<?, ?>) service.getValue();
        if (builder != null) {
            if (this.maxSizeAttribute.getName().equals(attributeName)) {
                int maxSize = this.maxSizeAttribute.resolveModelAttribute(context, model).asInt();
                builder.getConfiguration().setMaxSize(maxSize);
            }
        }
    }
}
Also used : ServiceName(org.jboss.msc.service.ServiceName) ServiceRegistry(org.jboss.msc.service.ServiceRegistry) DistributableCacheFactoryBuilder(org.jboss.as.ejb3.cache.distributable.DistributableCacheFactoryBuilder)

Example 33 with ServiceName

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

the class StrictMaxPoolAdd method installRuntimeService.

ServiceController<PoolConfig> installRuntimeService(OperationContext context, ModelNode operation, ModelNode strictMaxPoolModel, ServiceVerificationHandler verificationHandler) throws OperationFailedException {
    final String poolName = PathAddress.pathAddress(operation.get(ModelDescriptionConstants.ADDRESS)).getLastElement().getValue();
    final int maxPoolSize = StrictMaxPoolResourceDefinition.MAX_POOL_SIZE.resolveModelAttribute(context, strictMaxPoolModel).asInt();
    final Derive derive = StrictMaxPoolResourceDefinition.parseDeriveSize(context, strictMaxPoolModel);
    final long timeout = StrictMaxPoolResourceDefinition.INSTANCE_ACQUISITION_TIMEOUT.resolveModelAttribute(context, strictMaxPoolModel).asLong();
    final String unit = StrictMaxPoolResourceDefinition.INSTANCE_ACQUISITION_TIMEOUT_UNIT.resolveModelAttribute(context, strictMaxPoolModel).asString();
    // create and install the service
    final StrictMaxPoolConfigService poolConfigService = new StrictMaxPoolConfigService(poolName, maxPoolSize, derive, timeout, TimeUnit.valueOf(unit));
    final ServiceName serviceName = StrictMaxPoolConfigService.EJB_POOL_CONFIG_BASE_SERVICE_NAME.append(poolName);
    ServiceBuilder<PoolConfig> svcBuilder = context.getServiceTarget().addService(serviceName, poolConfigService);
    if (verificationHandler != null) {
        svcBuilder.addListener(verificationHandler);
    }
    if (context.hasOptionalCapability(IO_MAX_THREADS_RUNTIME_CAPABILITY_NAME, null, null)) {
        ServiceName name = context.getCapabilityServiceName(IO_MAX_THREADS_RUNTIME_CAPABILITY_NAME, Integer.class);
        svcBuilder.addDependency(name, Integer.class, poolConfigService.getMaxThreadsInjector());
    }
    return svcBuilder.install();
}
Also used : ServiceName(org.jboss.msc.service.ServiceName) Derive(org.jboss.as.ejb3.component.pool.StrictMaxPoolConfigService.Derive) PoolConfig(org.jboss.as.ejb3.component.pool.PoolConfig) StrictMaxPoolConfigService(org.jboss.as.ejb3.component.pool.StrictMaxPoolConfigService)

Example 34 with ServiceName

use of org.jboss.msc.service.ServiceName 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();
    final ServiceName serviceName = StrictMaxPoolConfigService.EJB_POOL_CONFIG_BASE_SERVICE_NAME.append(poolName);
    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 35 with ServiceName

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

the class TimerServiceAdd method performBoottime.

protected void performBoottime(final OperationContext context, ModelNode operation, final ModelNode model, final ServiceVerificationHandler verificationHandler, final List<ServiceController<?>> newControllers) throws OperationFailedException {
    final String defaultDataStore = TimerServiceResourceDefinition.DEFAULT_DATA_STORE.resolveModelAttribute(context, model).asString();
    final String threadPoolName = TimerServiceResourceDefinition.THREAD_POOL_NAME.resolveModelAttribute(context, model).asString();
    final ServiceName threadPoolServiceName = EJB3SubsystemModel.BASE_THREAD_POOL_SERVICE_NAME.append(threadPoolName);
    context.addStep(new AbstractDeploymentChainStep() {

        protected void execute(DeploymentProcessorTarget processorTarget) {
            ROOT_LOGGER.debug("Configuring timers");
            //we only add the timer service DUP's when the timer service in enabled in XML
            processorTarget.addDeploymentProcessor(EJB3Extension.SUBSYSTEM_NAME, Phase.PARSE, Phase.PARSE_TIMEOUT_ANNOTATION, new TimerServiceAnnotationProcessor());
            processorTarget.addDeploymentProcessor(EJB3Extension.SUBSYSTEM_NAME, Phase.PARSE, Phase.PARSE_AROUNDTIMEOUT_ANNOTATION, new AroundTimeoutAnnotationParsingProcessor());
            processorTarget.addDeploymentProcessor(EJB3Extension.SUBSYSTEM_NAME, Phase.POST_MODULE, Phase.POST_MODULE_EJB_TIMER_METADATA_MERGE, new TimerMethodMergingProcessor());
            processorTarget.addDeploymentProcessor(EJB3Extension.SUBSYSTEM_NAME, Phase.POST_MODULE, Phase.POST_MODULE_EJB_TIMER_SERVICE, new TimerServiceDeploymentProcessor(threadPoolServiceName, defaultDataStore));
        }
    }, OperationContext.Stage.RUNTIME);
    newControllers.add(context.getServiceTarget().addService(TimerServiceDeploymentProcessor.TIMER_SERVICE_NAME, new TimerValueService()).install());
}
Also used : DeploymentProcessorTarget(org.jboss.as.server.DeploymentProcessorTarget) TimerMethodMergingProcessor(org.jboss.as.ejb3.deployment.processors.merging.TimerMethodMergingProcessor) ServiceName(org.jboss.msc.service.ServiceName) AroundTimeoutAnnotationParsingProcessor(org.jboss.as.ejb3.deployment.processors.AroundTimeoutAnnotationParsingProcessor) AbstractDeploymentChainStep(org.jboss.as.server.AbstractDeploymentChainStep) TimerServiceDeploymentProcessor(org.jboss.as.ejb3.deployment.processors.TimerServiceDeploymentProcessor) TimerServiceAnnotationProcessor(org.jboss.as.ejb3.deployment.processors.annotation.TimerServiceAnnotationProcessor)

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