Search in sources :

Example 1 with PoolConfig

use of org.jboss.as.ejb3.component.pool.PoolConfig 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 2 with PoolConfig

use of org.jboss.as.ejb3.component.pool.PoolConfig in project wildfly by wildfly.

the class StatelessComponentDescription method createConfiguration.

@Override
public ComponentConfiguration createConfiguration(final ClassReflectionIndex classIndex, final ClassLoader moduleClassLoader, final ModuleLoader moduleLoader) {
    final ComponentConfiguration statelessComponentConfiguration = new ComponentConfiguration(this, classIndex, moduleClassLoader, moduleLoader);
    // setup the component create service
    statelessComponentConfiguration.setComponentCreateServiceFactory(new StatelessComponentCreateServiceFactory());
    // setup the configurator to inject the PoolConfig in the StatelessSessionComponentCreateService
    final StatelessComponentDescription statelessComponentDescription = (StatelessComponentDescription) statelessComponentConfiguration.getComponentDescription();
    // setup a configurator to inject the PoolConfig in the StatelessSessionComponentCreateService
    getConfigurators().add(new ComponentConfigurator() {

        @Override
        public void configure(DeploymentPhaseContext context, ComponentDescription description, ComponentConfiguration configuration) throws DeploymentUnitProcessingException {
            // get CapabilitySupport to resolve service names
            final CapabilityServiceSupport support = context.getDeploymentUnit().getAttachment(CAPABILITY_SERVICE_SUPPORT);
            configuration.getCreateDependencies().add(new DependencyConfigurator<Service<Component>>() {

                @Override
                public void configureDependency(ServiceBuilder<?> serviceBuilder, Service<Component> service) throws DeploymentUnitProcessingException {
                    final StatelessSessionComponentCreateService statelessSessionComponentCreateService = (StatelessSessionComponentCreateService) service;
                    final String poolName = statelessComponentDescription.getPoolConfigName();
                    // If the default slsb pool config itself is not configured, then the pooling is disabled for the bean
                    if (poolName == null) {
                        if (statelessComponentDescription.isDefaultSlsbPoolAvailable()) {
                            ServiceName defaultPoolConfigServiceName = support.getCapabilityServiceName(DEFAULT_SLSB_POOL_CONFIG_CAPABILITY_NAME);
                            serviceBuilder.addDependency(defaultPoolConfigServiceName, PoolConfig.class, statelessSessionComponentCreateService.getPoolConfigInjector());
                        }
                    } else {
                        // pool name has been explicitly set so the pool config is a required dependency
                        ServiceName poolConfigServiceName = support.getCapabilityServiceName(STRICT_MAX_POOL_CONFIG_CAPABILITY_NAME, poolName);
                        serviceBuilder.addDependency(poolConfigServiceName, PoolConfig.class, statelessSessionComponentCreateService.getPoolConfigInjector());
                    }
                }
            });
        }
    });
    // add the bmt interceptor
    if (TransactionManagementType.BEAN.equals(this.getTransactionManagementType())) {
        getConfigurators().add(new ComponentConfigurator() {

            @Override
            public void configure(final DeploymentPhaseContext context, final ComponentDescription description, final ComponentConfiguration configuration) throws DeploymentUnitProcessingException {
                // add the bmt interceptor factory
                configuration.addComponentInterceptor(EjbBMTInterceptor.FACTORY, InterceptorOrder.Component.BMT_TRANSACTION_INTERCEPTOR, false);
            }
        });
    }
    getConfigurators().add(new ComponentConfigurator() {

        @Override
        public void configure(final DeploymentPhaseContext context, final ComponentDescription description, final ComponentConfiguration configuration) throws DeploymentUnitProcessingException {
            if (TransactionManagementType.CONTAINER.equals(getTransactionManagementType())) {
                final EEApplicationClasses applicationClasses = context.getDeploymentUnit().getAttachment(Attachments.EE_APPLICATION_CLASSES_DESCRIPTION);
                InterceptorClassDescription interceptorConfig = ComponentDescription.mergeInterceptorConfig(configuration.getComponentClass(), applicationClasses.getClassByName(description.getComponentClassName()), description, MetadataCompleteMarker.isMetadataComplete(context.getDeploymentUnit()));
                configuration.addPostConstructInterceptor(new LifecycleCMTTxInterceptor.Factory(interceptorConfig.getPostConstruct(), true), InterceptorOrder.ComponentPostConstruct.TRANSACTION_INTERCEPTOR);
                configuration.addPreDestroyInterceptor(new LifecycleCMTTxInterceptor.Factory(interceptorConfig.getPreDestroy(), true), InterceptorOrder.ComponentPreDestroy.TRANSACTION_INTERCEPTOR);
                configuration.addTimeoutViewInterceptor(TimerCMTTxInterceptor.FACTORY, InterceptorOrder.View.CMT_TRANSACTION_INTERCEPTOR);
            }
            configuration.addTimeoutViewInterceptor(StatelessComponentInstanceAssociatingFactory.instance(), InterceptorOrder.View.ASSOCIATING_INTERCEPTOR);
        }
    });
    return statelessComponentConfiguration;
}
Also used : DeploymentUnitProcessingException(org.jboss.as.server.deployment.DeploymentUnitProcessingException) SessionBeanComponentDescription(org.jboss.as.ejb3.component.session.SessionBeanComponentDescription) ComponentDescription(org.jboss.as.ee.component.ComponentDescription) ComponentConfigurator(org.jboss.as.ee.component.ComponentConfigurator) DependencyConfigurator(org.jboss.as.ee.component.DependencyConfigurator) Service(org.jboss.msc.service.Service) ComponentTypeIdentityInterceptorFactory(org.jboss.as.ejb3.component.interceptors.ComponentTypeIdentityInterceptorFactory) StatelessRemoteViewInstanceFactory(org.jboss.as.ejb3.component.session.StatelessRemoteViewInstanceFactory) DeploymentPhaseContext(org.jboss.as.server.deployment.DeploymentPhaseContext) CapabilityServiceSupport(org.jboss.as.controller.capability.CapabilityServiceSupport) ServiceBuilder(org.jboss.msc.service.ServiceBuilder) ComponentConfiguration(org.jboss.as.ee.component.ComponentConfiguration) InterceptorClassDescription(org.jboss.as.ee.component.interceptors.InterceptorClassDescription) ServiceName(org.jboss.msc.service.ServiceName) EEApplicationClasses(org.jboss.as.ee.component.EEApplicationClasses) Component(org.jboss.as.ee.component.Component)

Example 3 with PoolConfig

use of org.jboss.as.ejb3.component.pool.PoolConfig in project wildfly by wildfly.

the class EJB3SubsystemDefaultPoolWriteHandler method updatePoolService.

void updatePoolService(final OperationContext context, final ModelNode model) throws OperationFailedException {
    final ModelNode poolName = poolAttribute.resolveModelAttribute(context, model);
    ServiceName poolConfigServiceName = context.getCapabilityServiceName(this.poolConfigCapabilityName, PoolConfig.class);
    final ServiceRegistry serviceRegistry = context.getServiceRegistry(true);
    ServiceController<?> existingDefaultPoolConfigService = serviceRegistry.getService(poolConfigServiceName);
    // if a default MDB pool is already installed, then remove it first
    if (existingDefaultPoolConfigService != null) {
        context.removeService(existingDefaultPoolConfigService);
    }
    if (poolName.isDefined()) {
        // now install default pool config service which points to an existing pool config service
        final ValueInjectionService<PoolConfig> newDefaultPoolConfigService = new ValueInjectionService<PoolConfig>();
        ServiceName poolConfigDependencyServiceName = context.getCapabilityServiceName(STRICT_MAX_POOL_CONFIG_CAPABILITY_NAME, PoolConfig.class, poolName.asString());
        ServiceController<?> newController = context.getServiceTarget().addService(poolConfigServiceName, newDefaultPoolConfigService).addDependency(poolConfigDependencyServiceName, PoolConfig.class, newDefaultPoolConfigService.getInjector()).install();
    }
}
Also used : ServiceName(org.jboss.msc.service.ServiceName) ValueInjectionService(org.jboss.msc.service.ValueInjectionService) PoolConfig(org.jboss.as.ejb3.component.pool.PoolConfig) ServiceRegistry(org.jboss.msc.service.ServiceRegistry) ModelNode(org.jboss.dmr.ModelNode)

Example 4 with PoolConfig

use of org.jboss.as.ejb3.component.pool.PoolConfig in project wildfly by wildfly.

the class MessageDrivenComponentDescription method createConfiguration.

@Override
public ComponentConfiguration createConfiguration(final ClassReflectionIndex classIndex, final ClassLoader moduleClassLoader, final ModuleLoader moduleLoader) {
    final ComponentConfiguration mdbComponentConfiguration = new ComponentConfiguration(this, classIndex, moduleClassLoader, moduleLoader);
    // setup the component create service
    final Class<?> messageListenerInterface;
    try {
        messageListenerInterface = Class.forName(getMessageListenerInterfaceName(), true, moduleClassLoader);
    } catch (ClassNotFoundException e) {
        throw new RuntimeException(e);
    }
    mdbComponentConfiguration.setComponentCreateServiceFactory(new MessageDrivenComponentCreateServiceFactory(messageListenerInterface));
    final MessageDrivenComponentDescription mdbComponentDescription = (MessageDrivenComponentDescription) mdbComponentConfiguration.getComponentDescription();
    // setup a configurator to inject the PoolConfig in the MessageDrivenComponentCreateService
    getConfigurators().add(new ComponentConfigurator() {

        @Override
        public void configure(DeploymentPhaseContext context, ComponentDescription description, ComponentConfiguration configuration) throws DeploymentUnitProcessingException {
            // get CapabilitySupport to resolve service names
            final CapabilityServiceSupport support = context.getDeploymentUnit().getAttachment(CAPABILITY_SERVICE_SUPPORT);
            MessageDrivenComponentDescription mdbDescription = (MessageDrivenComponentDescription) description;
            configuration.getCreateDependencies().add(new DependencyConfigurator<Service<Component>>() {

                @Override
                public void configureDependency(ServiceBuilder<?> serviceBuilder, Service<Component> service) throws DeploymentUnitProcessingException {
                    // add any dependencies here
                    final MessageDrivenComponentCreateService mdbComponentCreateService = (MessageDrivenComponentCreateService) service;
                    final String poolName = mdbComponentDescription.getPoolConfigName();
                    // If the default mdb pool config itself is not configured, then pooling is disabled for the bean
                    if (poolName == null) {
                        if (mdbComponentDescription.isDefaultMdbPoolAvailable()) {
                            ServiceName defaultPoolConfigServiceName = support.getCapabilityServiceName(DEFAULT_MDB_POOL_CONFIG_CAPABILITY_NAME);
                            serviceBuilder.addDependency(defaultPoolConfigServiceName, PoolConfig.class, mdbComponentCreateService.getPoolConfigInjector());
                        }
                    } else {
                        // pool name has been explicitly set so the pool config is a required dependency
                        ServiceName poolConfigServiceName = support.getCapabilityServiceName(STRICT_MAX_POOL_CONFIG_CAPABILITY_NAME, poolName);
                        serviceBuilder.addDependency(poolConfigServiceName, PoolConfig.class, mdbComponentCreateService.getPoolConfigInjector());
                    }
                }
            });
        }
    });
    // set up a configurator to inject ResourceAdapterService dependencies into the MessageDrivenComponentCreateService
    getConfigurators().add(new ComponentConfigurator() {

        @Override
        public void configure(DeploymentPhaseContext context, ComponentDescription description, ComponentConfiguration configuration) throws DeploymentUnitProcessingException {
            // get CapabilitySupport to resolve service names
            final CapabilityServiceSupport support = context.getDeploymentUnit().getAttachment(CAPABILITY_SERVICE_SUPPORT);
            configuration.getCreateDependencies().add(new DependencyConfigurator<MessageDrivenComponentCreateService>() {

                @Override
                public void configureDependency(ServiceBuilder<?> serviceBuilder, MessageDrivenComponentCreateService service) throws DeploymentUnitProcessingException {
                    final ServiceName raServiceName = ConnectorServices.getResourceAdapterServiceName(MessageDrivenComponentDescription.this.resourceAdapterName);
                    // add the dependency on the RA service
                    serviceBuilder.addDependency(ConnectorServices.RA_REPOSITORY_SERVICE, ResourceAdapterRepository.class, service.getResourceAdapterRepositoryInjector());
                    serviceBuilder.addDependency(raServiceName, ResourceAdapter.class, service.getResourceAdapterInjector());
                }
            });
        }
    });
    getConfigurators().add(new ComponentConfigurator() {

        @Override
        public void configure(DeploymentPhaseContext context, ComponentDescription description, ComponentConfiguration configuration) throws DeploymentUnitProcessingException {
            final ServiceName suspendControllerName = context.getDeploymentUnit().getAttachment(CAPABILITY_SERVICE_SUPPORT).getCapabilityServiceName("org.wildfly.server.suspend-controller");
            configuration.getCreateDependencies().add(new DependencyConfigurator<MessageDrivenComponentCreateService>() {

                @Override
                public void configureDependency(final ServiceBuilder<?> serviceBuilder, final MessageDrivenComponentCreateService mdbComponentCreateService) throws DeploymentUnitProcessingException {
                    serviceBuilder.addDependency(suspendControllerName, SuspendController.class, mdbComponentCreateService.getSuspendControllerInjectedValue());
                }
            });
        }
    });
    // add the BMT interceptor
    if (TransactionManagementType.BEAN.equals(this.getTransactionManagementType())) {
        getConfigurators().add(new ComponentConfigurator() {

            @Override
            public void configure(final DeploymentPhaseContext context, final ComponentDescription description, final ComponentConfiguration configuration) throws DeploymentUnitProcessingException {
                // add the bmt interceptor factory
                configuration.addComponentInterceptor(EjbBMTInterceptor.FACTORY, InterceptorOrder.Component.BMT_TRANSACTION_INTERCEPTOR, false);
            }
        });
    } else {
        getConfigurators().add(new ComponentConfigurator() {

            @Override
            public void configure(final DeploymentPhaseContext context, final ComponentDescription description, final ComponentConfiguration configuration) throws DeploymentUnitProcessingException {
                final EEApplicationClasses applicationClasses = context.getDeploymentUnit().getAttachment(Attachments.EE_APPLICATION_CLASSES_DESCRIPTION);
                InterceptorClassDescription interceptorConfig = ComponentDescription.mergeInterceptorConfig(configuration.getComponentClass(), applicationClasses.getClassByName(description.getComponentClassName()), description, MetadataCompleteMarker.isMetadataComplete(context.getDeploymentUnit()));
                configuration.addPostConstructInterceptor(new LifecycleCMTTxInterceptor.Factory(interceptorConfig.getPostConstruct(), true), InterceptorOrder.ComponentPostConstruct.TRANSACTION_INTERCEPTOR);
                configuration.addPreDestroyInterceptor(new LifecycleCMTTxInterceptor.Factory(interceptorConfig.getPreDestroy(), true), InterceptorOrder.ComponentPreDestroy.TRANSACTION_INTERCEPTOR);
                configuration.addTimeoutViewInterceptor(TimerCMTTxInterceptor.FACTORY, InterceptorOrder.View.CMT_TRANSACTION_INTERCEPTOR);
            }
        });
    }
    return mdbComponentConfiguration;
}
Also used : DeploymentUnitProcessingException(org.jboss.as.server.deployment.DeploymentUnitProcessingException) EJBComponentDescription(org.jboss.as.ejb3.component.EJBComponentDescription) ComponentDescription(org.jboss.as.ee.component.ComponentDescription) ComponentConfigurator(org.jboss.as.ee.component.ComponentConfigurator) DependencyConfigurator(org.jboss.as.ee.component.DependencyConfigurator) Service(org.jboss.msc.service.Service) ImmediateInterceptorFactory(org.jboss.invocation.ImmediateInterceptorFactory) DeploymentPhaseContext(org.jboss.as.server.deployment.DeploymentPhaseContext) CapabilityServiceSupport(org.jboss.as.controller.capability.CapabilityServiceSupport) ServiceBuilder(org.jboss.msc.service.ServiceBuilder) ComponentConfiguration(org.jboss.as.ee.component.ComponentConfiguration) InterceptorClassDescription(org.jboss.as.ee.component.interceptors.InterceptorClassDescription) ServiceName(org.jboss.msc.service.ServiceName) EEApplicationClasses(org.jboss.as.ee.component.EEApplicationClasses) Component(org.jboss.as.ee.component.Component)

Aggregations

ServiceName (org.jboss.msc.service.ServiceName)4 CapabilityServiceSupport (org.jboss.as.controller.capability.CapabilityServiceSupport)2 Component (org.jboss.as.ee.component.Component)2 ComponentConfiguration (org.jboss.as.ee.component.ComponentConfiguration)2 ComponentConfigurator (org.jboss.as.ee.component.ComponentConfigurator)2 ComponentDescription (org.jboss.as.ee.component.ComponentDescription)2 DependencyConfigurator (org.jboss.as.ee.component.DependencyConfigurator)2 EEApplicationClasses (org.jboss.as.ee.component.EEApplicationClasses)2 InterceptorClassDescription (org.jboss.as.ee.component.interceptors.InterceptorClassDescription)2 PoolConfig (org.jboss.as.ejb3.component.pool.PoolConfig)2 DeploymentPhaseContext (org.jboss.as.server.deployment.DeploymentPhaseContext)2 DeploymentUnitProcessingException (org.jboss.as.server.deployment.DeploymentUnitProcessingException)2 Service (org.jboss.msc.service.Service)2 ServiceBuilder (org.jboss.msc.service.ServiceBuilder)2 EJBComponentDescription (org.jboss.as.ejb3.component.EJBComponentDescription)1 ComponentTypeIdentityInterceptorFactory (org.jboss.as.ejb3.component.interceptors.ComponentTypeIdentityInterceptorFactory)1 StrictMaxPoolConfigService (org.jboss.as.ejb3.component.pool.StrictMaxPoolConfigService)1 Derive (org.jboss.as.ejb3.component.pool.StrictMaxPoolConfigService.Derive)1 SessionBeanComponentDescription (org.jboss.as.ejb3.component.session.SessionBeanComponentDescription)1 StatelessRemoteViewInstanceFactory (org.jboss.as.ejb3.component.session.StatelessRemoteViewInstanceFactory)1