Search in sources :

Example 11 with ComponentConfigurator

use of org.jboss.as.ee.component.ComponentConfigurator in project wildfly by wildfly.

the class EJBComponentDescription method addRemoteTransactionsDependency.

/**
 * Adds a dependency for the ComponentConfiguration on the remote transaction service if the EJB exposes at least one remote view
 */
protected void addRemoteTransactionsDependency() {
    this.getConfigurators().add(new ComponentConfigurator() {

        @Override
        public void configure(DeploymentPhaseContext context, ComponentDescription description, ComponentConfiguration componentConfiguration) throws DeploymentUnitProcessingException {
            if (this.hasRemoteView((EJBComponentDescription) description)) {
                // add a dependency on local transaction service
                componentConfiguration.getCreateDependencies().add(new DependencyConfigurator<EJBComponentCreateService>() {

                    @Override
                    public void configureDependency(ServiceBuilder<?> serviceBuilder, EJBComponentCreateService ejbComponentCreateService) throws DeploymentUnitProcessingException {
                        CapabilityServiceSupport support = context.getDeploymentUnit().getAttachment(org.jboss.as.server.deployment.Attachments.CAPABILITY_SERVICE_SUPPORT);
                        // add dependency on the remote transaction service
                        serviceBuilder.requires(support.getCapabilityServiceName(REMOTE_TRANSACTION_SERVICE_CAPABILITY_NAME));
                    }
                });
            }
        }

        /**
         * Returns true if the passed EJB component description has at least one remote view
         * @param ejbComponentDescription
         * @return
         */
        private boolean hasRemoteView(final EJBComponentDescription ejbComponentDescription) {
            final Set<ViewDescription> views = ejbComponentDescription.getViews();
            for (final ViewDescription view : views) {
                if (!(view instanceof EJBViewDescription)) {
                    continue;
                }
                final MethodIntf viewType = ((EJBViewDescription) view).getMethodIntf();
                if (viewType == MethodIntf.REMOTE || viewType == MethodIntf.HOME) {
                    return true;
                }
            }
            return false;
        }
    });
}
Also used : DeploymentUnitProcessingException(org.jboss.as.server.deployment.DeploymentUnitProcessingException) ComponentDescription(org.jboss.as.ee.component.ComponentDescription) Set(java.util.Set) HashSet(java.util.HashSet) ComponentConfigurator(org.jboss.as.ee.component.ComponentConfigurator) ViewDescription(org.jboss.as.ee.component.ViewDescription) DependencyConfigurator(org.jboss.as.ee.component.DependencyConfigurator) DeploymentPhaseContext(org.jboss.as.server.deployment.DeploymentPhaseContext) ServiceBuilder(org.jboss.msc.service.ServiceBuilder) CapabilityServiceSupport(org.jboss.as.controller.capability.CapabilityServiceSupport) ComponentConfiguration(org.jboss.as.ee.component.ComponentConfiguration)

Example 12 with ComponentConfigurator

use of org.jboss.as.ee.component.ComponentConfigurator in project wildfly by wildfly.

the class EJBComponentDescription method addTransactionManagerDependencies.

/**
 * Sets up a {@link ComponentConfigurator} which then sets up the relevant dependencies on the transaction manager services for the {@link EJBComponentCreateService}
 */
protected void addTransactionManagerDependencies() {
    this.getConfigurators().add(new ComponentConfigurator() {

        @Override
        public void configure(final DeploymentPhaseContext context, final ComponentDescription description, final ComponentConfiguration componentConfiguration) throws DeploymentUnitProcessingException {
            componentConfiguration.getCreateDependencies().add(new DependencyConfigurator<EJBComponentCreateService>() {

                @Override
                public void configureDependency(final ServiceBuilder<?> serviceBuilder, final EJBComponentCreateService ejbComponentCreateService) throws DeploymentUnitProcessingException {
                    CapabilityServiceSupport support = context.getDeploymentUnit().getAttachment(org.jboss.as.server.deployment.Attachments.CAPABILITY_SERVICE_SUPPORT);
                    // add dependency on the local transaction provider
                    serviceBuilder.requires(support.getCapabilityServiceName(TRANSACTION_GLOBAL_DEFAULT_LOCAL_PROVIDER_CAPABILITY_NAME));
                    // add dependency on TransactionSynchronizationRegistry
                    serviceBuilder.addDependency(support.getCapabilityServiceName(TRANSACTION_SYNCHRONIZATION_REGISTRY_CAPABILITY_NAME), TransactionSynchronizationRegistry.class, ejbComponentCreateService.getTransactionSynchronizationRegistryInjector());
                }
            });
        }
    });
}
Also used : ComponentConfiguration(org.jboss.as.ee.component.ComponentConfiguration) DeploymentUnitProcessingException(org.jboss.as.server.deployment.DeploymentUnitProcessingException) ComponentDescription(org.jboss.as.ee.component.ComponentDescription) ComponentConfigurator(org.jboss.as.ee.component.ComponentConfigurator) DependencyConfigurator(org.jboss.as.ee.component.DependencyConfigurator) DeploymentPhaseContext(org.jboss.as.server.deployment.DeploymentPhaseContext) ServiceBuilder(org.jboss.msc.service.ServiceBuilder) CapabilityServiceSupport(org.jboss.as.controller.capability.CapabilityServiceSupport)

Example 13 with ComponentConfigurator

use of org.jboss.as.ee.component.ComponentConfigurator in project wildfly by wildfly.

the class EJBComponentSuspendDeploymentUnitProcessor method deploy.

@Override
public void deploy(DeploymentPhaseContext context) {
    final DeploymentUnit deploymentUnit = context.getDeploymentUnit();
    final String topLevelName;
    // check if the controller is installed
    if (!RequestControllerActivationMarker.isRequestControllerEnabled(deploymentUnit)) {
        return;
    }
    if (deploymentUnit.getParent() == null) {
        topLevelName = deploymentUnit.getName();
    } else {
        topLevelName = deploymentUnit.getParent().getName();
    }
    for (ComponentDescription component : deploymentUnit.getAttachment(Attachments.EE_MODULE_DESCRIPTION).getComponentDescriptions()) {
        if (component instanceof EJBComponentDescription) {
            final String entryPoint = ENTRY_POINT_NAME + deploymentUnit.getName() + "." + component.getComponentName();
            ControlPointService.install(context.getServiceTarget(), topLevelName, entryPoint);
            component.getConfigurators().add(new ComponentConfigurator() {

                @Override
                public void configure(DeploymentPhaseContext context, ComponentDescription description, ComponentConfiguration configuration) {
                    EjbSuspendInterceptor interceptor = null;
                    ImmediateInterceptorFactory factory = null;
                    for (ViewConfiguration view : configuration.getViews()) {
                        EJBViewConfiguration ejbView = (EJBViewConfiguration) view;
                        if (INTERFACES.contains(ejbView.getMethodIntf())) {
                            if (factory == null) {
                                interceptor = new EjbSuspendInterceptor();
                                factory = new ImmediateInterceptorFactory(interceptor);
                            }
                            view.addViewInterceptor(factory, InterceptorOrder.View.GRACEFUL_SHUTDOWN);
                        }
                    }
                    configuration.getCreateDependencies().add(new DependencyConfigurator<EJBComponentCreateService>() {

                        @Override
                        public void configureDependency(ServiceBuilder<?> serviceBuilder, EJBComponentCreateService service) {
                            serviceBuilder.addDependency(ControlPointService.serviceName(topLevelName, entryPoint), ControlPoint.class, service.getControlPointInjector());
                        }
                    });
                }
            });
        }
    }
}
Also used : EJBComponentDescription(org.jboss.as.ejb3.component.EJBComponentDescription) ComponentDescription(org.jboss.as.ee.component.ComponentDescription) ComponentConfigurator(org.jboss.as.ee.component.ComponentConfigurator) EJBViewConfiguration(org.jboss.as.ejb3.component.EJBViewConfiguration) DependencyConfigurator(org.jboss.as.ee.component.DependencyConfigurator) EJBComponentDescription(org.jboss.as.ejb3.component.EJBComponentDescription) DeploymentPhaseContext(org.jboss.as.server.deployment.DeploymentPhaseContext) ServiceBuilder(org.jboss.msc.service.ServiceBuilder) ComponentConfiguration(org.jboss.as.ee.component.ComponentConfiguration) ViewConfiguration(org.jboss.as.ee.component.ViewConfiguration) EJBViewConfiguration(org.jboss.as.ejb3.component.EJBViewConfiguration) ImmediateInterceptorFactory(org.jboss.invocation.ImmediateInterceptorFactory) EJBComponentCreateService(org.jboss.as.ejb3.component.EJBComponentCreateService) DeploymentUnit(org.jboss.as.server.deployment.DeploymentUnit)

Example 14 with ComponentConfigurator

use of org.jboss.as.ee.component.ComponentConfigurator in project wildfly by wildfly.

the class EjbJndiBindingsDeploymentUnitProcessor method registerRemoteBinding.

private void registerRemoteBinding(final EJBComponentDescription componentDescription, final ViewDescription viewDescription, final String jndiName) {
    final EEModuleDescription moduleDescription = componentDescription.getModuleDescription();
    final InjectedValue<ClassLoader> viewClassLoader = new InjectedValue<ClassLoader>();
    moduleDescription.getBindingConfigurations().add(new BindingConfiguration(jndiName, new RemoteViewInjectionSource(null, moduleDescription.getEarApplicationName(), moduleDescription.getModuleName(), moduleDescription.getDistinctName(), componentDescription.getComponentName(), viewDescription.getViewClassName(), componentDescription.isStateful(), viewClassLoader, appclient)));
    componentDescription.getConfigurators().add(new ComponentConfigurator() {

        public void configure(DeploymentPhaseContext context, ComponentDescription description, ComponentConfiguration configuration) throws DeploymentUnitProcessingException {
            viewClassLoader.setValue(Values.immediateValue(configuration.getModuleClassLoader()));
        }
    });
}
Also used : ComponentConfiguration(org.jboss.as.ee.component.ComponentConfiguration) DeploymentUnitProcessingException(org.jboss.as.server.deployment.DeploymentUnitProcessingException) InjectedValue(org.jboss.msc.value.InjectedValue) EJBComponentDescription(org.jboss.as.ejb3.component.EJBComponentDescription) SessionBeanComponentDescription(org.jboss.as.ejb3.component.session.SessionBeanComponentDescription) ComponentDescription(org.jboss.as.ee.component.ComponentDescription) EEModuleDescription(org.jboss.as.ee.component.EEModuleDescription) RemoteViewInjectionSource(org.jboss.as.ejb3.remote.RemoteViewInjectionSource) ComponentConfigurator(org.jboss.as.ee.component.ComponentConfigurator) DeploymentPhaseContext(org.jboss.as.server.deployment.DeploymentPhaseContext) BindingConfiguration(org.jboss.as.ee.component.BindingConfiguration)

Example 15 with ComponentConfigurator

use of org.jboss.as.ee.component.ComponentConfigurator in project wildfly by wildfly.

the class EEConcurrencyContextHandleFactoryProcessor method deploy.

@Override
public void deploy(DeploymentPhaseContext phaseContext) throws DeploymentUnitProcessingException {
    final DeploymentUnit deploymentUnit = phaseContext.getDeploymentUnit();
    final EEModuleDescription eeModuleDescription = deploymentUnit.getAttachment(Attachments.EE_MODULE_DESCRIPTION);
    if (eeModuleDescription == null) {
        return;
    }
    final ComponentConfigurator componentConfigurator = new ComponentConfigurator() {

        @Override
        public void configure(DeploymentPhaseContext context, ComponentDescription description, final ComponentConfiguration configuration) {
            final TransactionLeakContextHandleFactory transactionLeakContextHandleFactory = new TransactionLeakContextHandleFactory();
            context.requires(TransactionManagerService.INTERNAL_SERVICE_NAME, transactionLeakContextHandleFactory.getTransactionManagerSupplier());
            configuration.getConcurrentContext().addFactory(transactionLeakContextHandleFactory);
        }
    };
    for (ComponentDescription componentDescription : eeModuleDescription.getComponentDescriptions()) {
        componentDescription.getConfigurators().add(componentConfigurator);
    }
}
Also used : ComponentConfiguration(org.jboss.as.ee.component.ComponentConfiguration) ComponentDescription(org.jboss.as.ee.component.ComponentDescription) EEModuleDescription(org.jboss.as.ee.component.EEModuleDescription) ComponentConfigurator(org.jboss.as.ee.component.ComponentConfigurator) DeploymentUnit(org.jboss.as.server.deployment.DeploymentUnit) DeploymentPhaseContext(org.jboss.as.server.deployment.DeploymentPhaseContext)

Aggregations

ComponentConfiguration (org.jboss.as.ee.component.ComponentConfiguration)16 ComponentConfigurator (org.jboss.as.ee.component.ComponentConfigurator)16 ComponentDescription (org.jboss.as.ee.component.ComponentDescription)16 DeploymentPhaseContext (org.jboss.as.server.deployment.DeploymentPhaseContext)15 DeploymentUnitProcessingException (org.jboss.as.server.deployment.DeploymentUnitProcessingException)11 DeploymentUnit (org.jboss.as.server.deployment.DeploymentUnit)8 ServiceBuilder (org.jboss.msc.service.ServiceBuilder)8 DependencyConfigurator (org.jboss.as.ee.component.DependencyConfigurator)7 ImmediateInterceptorFactory (org.jboss.invocation.ImmediateInterceptorFactory)7 ServiceName (org.jboss.msc.service.ServiceName)7 CapabilityServiceSupport (org.jboss.as.controller.capability.CapabilityServiceSupport)6 EEModuleDescription (org.jboss.as.ee.component.EEModuleDescription)6 EJBComponentDescription (org.jboss.as.ejb3.component.EJBComponentDescription)6 SessionBeanComponentDescription (org.jboss.as.ejb3.component.session.SessionBeanComponentDescription)6 ViewConfiguration (org.jboss.as.ee.component.ViewConfiguration)5 InterceptorClassDescription (org.jboss.as.ee.component.interceptors.InterceptorClassDescription)5 EEApplicationClasses (org.jboss.as.ee.component.EEApplicationClasses)4 Method (java.lang.reflect.Method)3 HashSet (java.util.HashSet)3 Component (org.jboss.as.ee.component.Component)3