Search in sources :

Example 21 with ComponentDescription

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

the class DeploymentDescriptorMethodProcessor method deploy.

@Override
public void deploy(final DeploymentPhaseContext phaseContext) throws DeploymentUnitProcessingException {
    final DeploymentUnit deploymentUnit = phaseContext.getDeploymentUnit();
    final EEModuleDescription eeModuleDescription = deploymentUnit.getAttachment(org.jboss.as.ee.component.Attachments.EE_MODULE_DESCRIPTION);
    final DeploymentReflectionIndex reflectionIndex = deploymentUnit.getAttachment(org.jboss.as.server.deployment.Attachments.REFLECTION_INDEX);
    final Module module = deploymentUnit.getAttachment(Attachments.MODULE);
    if (eeModuleDescription != null) {
        for (final ComponentDescription component : eeModuleDescription.getComponentDescriptions()) {
            if (component instanceof EJBComponentDescription) {
                try {
                    if (component instanceof SessionBeanComponentDescription || component instanceof MessageDrivenComponentDescription)
                        handleSessionBean((EJBComponentDescription) component, module, reflectionIndex);
                    if (component instanceof StatelessComponentDescription || component instanceof MessageDrivenComponentDescription) {
                        handleStatelessSessionBean((EJBComponentDescription) component, module, reflectionIndex);
                    }
                } catch (ClassNotFoundException e) {
                    throw EjbLogger.ROOT_LOGGER.failToLoadComponentClass(e, component.getComponentName());
                }
            }
        }
    }
}
Also used : StatelessComponentDescription(org.jboss.as.ejb3.component.stateless.StatelessComponentDescription) EJBComponentDescription(org.jboss.as.ejb3.component.EJBComponentDescription) SessionBeanComponentDescription(org.jboss.as.ejb3.component.session.SessionBeanComponentDescription) MessageDrivenComponentDescription(org.jboss.as.ejb3.component.messagedriven.MessageDrivenComponentDescription) ComponentDescription(org.jboss.as.ee.component.ComponentDescription) EEModuleDescription(org.jboss.as.ee.component.EEModuleDescription) MessageDrivenComponentDescription(org.jboss.as.ejb3.component.messagedriven.MessageDrivenComponentDescription) StatelessComponentDescription(org.jboss.as.ejb3.component.stateless.StatelessComponentDescription) Module(org.jboss.modules.Module) DeploymentUnit(org.jboss.as.server.deployment.DeploymentUnit) DeploymentReflectionIndex(org.jboss.as.server.deployment.reflect.DeploymentReflectionIndex) EJBComponentDescription(org.jboss.as.ejb3.component.EJBComponentDescription) SessionBeanComponentDescription(org.jboss.as.ejb3.component.session.SessionBeanComponentDescription)

Example 22 with ComponentDescription

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

the class EjbClientContextSetupProcessor method deploy.

@Override
public void deploy(final DeploymentPhaseContext phaseContext) throws DeploymentUnitProcessingException {
    final DeploymentUnit deploymentUnit = phaseContext.getDeploymentUnit();
    final Module module = deploymentUnit.getAttachment(org.jboss.as.server.deployment.Attachments.MODULE);
    if (module == null) {
        return;
    }
    RegistrationService registrationService = new RegistrationService(module);
    ServiceName registrationServiceName = deploymentUnit.getServiceName().append("ejb3", "client-context", "registration-service");
    final ServiceName profileServiceName = deploymentUnit.getAttachment(EjbDeploymentAttachmentKeys.EJB_REMOTING_PROFILE_SERVICE_NAME);
    final ServiceBuilder<Void> builder = phaseContext.getServiceTarget().addService(registrationServiceName, registrationService).addDependency(getEJBClientContextServiceName(phaseContext), EJBClientContextService.class, registrationService.ejbClientContextInjectedValue).addDependency(getDiscoveryServiceName(phaseContext), Discovery.class, registrationService.discoveryInjector);
    if (profileServiceName != null) {
        builder.addDependency(profileServiceName, RemotingProfileService.class, registrationService.profileServiceInjectedValue);
    }
    builder.install();
    final EEModuleDescription moduleDescription = deploymentUnit.getAttachment(Attachments.EE_MODULE_DESCRIPTION);
    if (moduleDescription == null) {
        return;
    }
    //we need to make sure all our components have a dependency on the EJB client context registration, which in turn implies a dependency on the context
    for (final ComponentDescription component : moduleDescription.getComponentDescriptions()) {
        component.addDependency(registrationServiceName, ServiceBuilder.DependencyType.REQUIRED);
    }
}
Also used : ComponentDescription(org.jboss.as.ee.component.ComponentDescription) EEModuleDescription(org.jboss.as.ee.component.EEModuleDescription) ServiceName(org.jboss.msc.service.ServiceName) EJBClientContextService(org.jboss.as.ejb3.remote.EJBClientContextService) Module(org.jboss.modules.Module) DeploymentUnit(org.jboss.as.server.deployment.DeploymentUnit)

Example 23 with ComponentDescription

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

the class TimerServiceDeploymentProcessor method deploy.

@Override
public void deploy(final DeploymentPhaseContext phaseContext) throws DeploymentUnitProcessingException {
    final DeploymentUnit deploymentUnit = phaseContext.getDeploymentUnit();
    final EEModuleDescription moduleDescription = deploymentUnit.getAttachment(Attachments.EE_MODULE_DESCRIPTION);
    final Module module = deploymentUnit.getAttachment(org.jboss.as.server.deployment.Attachments.MODULE);
    final EjbJarMetaData ejbJarMetaData = deploymentUnit.getAttachment(EjbDeploymentAttachmentKeys.EJB_JAR_METADATA);
    ServiceName defaultTimerPersistenceService = TimerPersistence.SERVICE_NAME.append(defaultTimerDataStore);
    final Map<String, ServiceName> timerPersistenceServices = new HashMap<String, ServiceName>();
    // if this is an EJB deployment then create an EJB module level TimerServiceRegistry which can be used by the timer services
    // of all EJB components that belong to this EJB module.
    final TimerServiceRegistry timerServiceRegistry = EjbDeploymentMarker.isEjbDeployment(deploymentUnit) ? new TimerServiceRegistry() : null;
    if (ejbJarMetaData != null && ejbJarMetaData.getAssemblyDescriptor() != null) {
        List<TimerServiceMetaData> timerService = ejbJarMetaData.getAssemblyDescriptor().getAny(TimerServiceMetaData.class);
        if (timerService != null) {
            for (TimerServiceMetaData data : timerService) {
                if (data.getEjbName().equals("*")) {
                    defaultTimerPersistenceService = TimerPersistence.SERVICE_NAME.append(data.getDataStoreName());
                } else {
                    timerPersistenceServices.put(data.getEjbName(), TimerPersistence.SERVICE_NAME.append(data.getDataStoreName()));
                }
            }
        }
    }
    final ServiceName finalDefaultTimerPersistenceService = defaultTimerPersistenceService;
    for (final ComponentDescription componentDescription : moduleDescription.getComponentDescriptions()) {
        if (componentDescription.isTimerServiceApplicable()) {
            if (componentDescription.isTimerServiceRequired()) {
                //the component has timeout methods, it needs a 'real' timer service
                final String deploymentName;
                if (moduleDescription.getDistinctName() == null || moduleDescription.getDistinctName().length() == 0) {
                    deploymentName = moduleDescription.getApplicationName() + "." + moduleDescription.getModuleName();
                } else {
                    deploymentName = moduleDescription.getApplicationName() + "." + moduleDescription.getModuleName() + "." + moduleDescription.getDistinctName();
                }
                ROOT_LOGGER.debugf("Installing timer service for component %s", componentDescription.getComponentName());
                componentDescription.getConfigurators().add(new ComponentConfigurator() {

                    @Override
                    public void configure(final DeploymentPhaseContext context, final ComponentDescription description, final ComponentConfiguration configuration) throws DeploymentUnitProcessingException {
                        final EJBComponentDescription ejbComponentDescription = (EJBComponentDescription) description;
                        final ServiceName invokerServiceName = ejbComponentDescription.getServiceName().append(TimedObjectInvokerImpl.SERVICE_NAME);
                        final TimedObjectInvokerImpl invoker = new TimedObjectInvokerImpl(deploymentName, module);
                        context.getServiceTarget().addService(invokerServiceName, invoker).addDependency(componentDescription.getCreateServiceName(), EJBComponent.class, invoker.getEjbComponent()).install();
                        //install the timer create service
                        final ServiceName serviceName = componentDescription.getServiceName().append(TimerServiceImpl.SERVICE_NAME);
                        final TimerServiceImpl service = new TimerServiceImpl(ejbComponentDescription.getScheduleMethods(), serviceName, timerServiceRegistry);
                        final ServiceBuilder<javax.ejb.TimerService> createBuilder = context.getServiceTarget().addService(serviceName, service);
                        createBuilder.addDependency(TIMER_SERVICE_NAME, Timer.class, service.getTimerInjectedValue());
                        createBuilder.addDependency(componentDescription.getCreateServiceName(), EJBComponent.class, service.getEjbComponentInjectedValue());
                        createBuilder.addDependency(timerServiceThreadPool, ExecutorService.class, service.getExecutorServiceInjectedValue());
                        if (timerPersistenceServices.containsKey(ejbComponentDescription.getEJBName())) {
                            createBuilder.addDependency(timerPersistenceServices.get(ejbComponentDescription.getEJBName()), TimerPersistence.class, service.getTimerPersistence());
                        } else {
                            createBuilder.addDependency(finalDefaultTimerPersistenceService, TimerPersistence.class, service.getTimerPersistence());
                        }
                        createBuilder.addDependency(invokerServiceName, TimedObjectInvoker.class, service.getTimedObjectInvoker());
                        createBuilder.install();
                        ejbComponentDescription.setTimerService(service);
                        //inject the timer service directly into the start service
                        configuration.getStartDependencies().add(new DependencyConfigurator<ComponentStartService>() {

                            @Override
                            public void configureDependency(final ServiceBuilder<?> serviceBuilder, final ComponentStartService service) throws DeploymentUnitProcessingException {
                                serviceBuilder.addDependency(serviceName);
                            }
                        });
                    }
                });
            } else {
                //the EJB is of a type that could have a timer service, but has no timer methods.
                //just bind the non-functional timer service
                componentDescription.getConfigurators().add(new ComponentConfigurator() {

                    @Override
                    public void configure(final DeploymentPhaseContext context, final ComponentDescription description, final ComponentConfiguration configuration) throws DeploymentUnitProcessingException {
                        final EJBComponentDescription ejbComponentDescription = (EJBComponentDescription) description;
                        final ServiceName nonFunctionalTimerServiceName = NonFunctionalTimerService.serviceNameFor(ejbComponentDescription);
                        final NonFunctionalTimerService nonFunctionalTimerService;
                        if (ejbComponentDescription instanceof StatefulComponentDescription) {
                            // for stateful beans, use a different error message that gets thrown from the NonFunctionalTimerService
                            nonFunctionalTimerService = new NonFunctionalTimerService(EjbLogger.ROOT_LOGGER.timerServiceMethodNotAllowedForSFSB(ejbComponentDescription.getComponentName()), timerServiceRegistry);
                        } else {
                            nonFunctionalTimerService = new NonFunctionalTimerService(EjbLogger.ROOT_LOGGER.ejbHasNoTimerMethods(), timerServiceRegistry);
                        }
                        // add the non-functional timer service as a MSC service
                        context.getServiceTarget().addService(nonFunctionalTimerServiceName, nonFunctionalTimerService).install();
                        // set the timer service in the EJB component
                        ejbComponentDescription.setTimerService(nonFunctionalTimerService);
                        // now we want the EJB component to depend on this non-functional timer service to start
                        configuration.getStartDependencies().add(new DependencyConfigurator<ComponentStartService>() {

                            @Override
                            public void configureDependency(ServiceBuilder<?> serviceBuilder, ComponentStartService service) throws DeploymentUnitProcessingException {
                                serviceBuilder.addDependency(nonFunctionalTimerServiceName);
                            }
                        });
                    }
                });
            }
        }
    }
}
Also used : DeploymentUnitProcessingException(org.jboss.as.server.deployment.DeploymentUnitProcessingException) StatefulComponentDescription(org.jboss.as.ejb3.component.stateful.StatefulComponentDescription) EJBComponentDescription(org.jboss.as.ejb3.component.EJBComponentDescription) ComponentDescription(org.jboss.as.ee.component.ComponentDescription) HashMap(java.util.HashMap) ComponentConfigurator(org.jboss.as.ee.component.ComponentConfigurator) DependencyConfigurator(org.jboss.as.ee.component.DependencyConfigurator) DeploymentPhaseContext(org.jboss.as.server.deployment.DeploymentPhaseContext) EJBComponentDescription(org.jboss.as.ejb3.component.EJBComponentDescription) ServiceBuilder(org.jboss.msc.service.ServiceBuilder) EEModuleDescription(org.jboss.as.ee.component.EEModuleDescription) StatefulComponentDescription(org.jboss.as.ejb3.component.stateful.StatefulComponentDescription) TimedObjectInvokerImpl(org.jboss.as.ejb3.timerservice.TimedObjectInvokerImpl) TimerServiceImpl(org.jboss.as.ejb3.timerservice.TimerServiceImpl) TimerPersistence(org.jboss.as.ejb3.timerservice.persistence.TimerPersistence) ComponentStartService(org.jboss.as.ee.component.ComponentStartService) TimerServiceMetaData(org.jboss.as.ejb3.timerservice.TimerServiceMetaData) EjbJarMetaData(org.jboss.metadata.ejb.spec.EjbJarMetaData) TimedObjectInvoker(org.jboss.as.ejb3.timerservice.spi.TimedObjectInvoker) EJBComponent(org.jboss.as.ejb3.component.EJBComponent) ComponentConfiguration(org.jboss.as.ee.component.ComponentConfiguration) TimerServiceRegistry(org.jboss.as.ejb3.component.TimerServiceRegistry) Timer(java.util.Timer) ServiceName(org.jboss.msc.service.ServiceName) NonFunctionalTimerService(org.jboss.as.ejb3.timerservice.NonFunctionalTimerService) ExecutorService(java.util.concurrent.ExecutorService) Module(org.jboss.modules.Module) DeploymentUnit(org.jboss.as.server.deployment.DeploymentUnit)

Example 24 with ComponentDescription

use of org.jboss.as.ee.component.ComponentDescription 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();
    statelessComponentConfiguration.getCreateDependencies().add(new PoolInjectingConfigurator(statelessComponentDescription));
    // 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 : ComponentConfiguration(org.jboss.as.ee.component.ComponentConfiguration) DeploymentUnitProcessingException(org.jboss.as.server.deployment.DeploymentUnitProcessingException) SessionBeanComponentDescription(org.jboss.as.ejb3.component.session.SessionBeanComponentDescription) ComponentDescription(org.jboss.as.ee.component.ComponentDescription) InterceptorClassDescription(org.jboss.as.ee.component.interceptors.InterceptorClassDescription) ComponentConfigurator(org.jboss.as.ee.component.ComponentConfigurator) EEApplicationClasses(org.jboss.as.ee.component.EEApplicationClasses) ComponentTypeIdentityInterceptorFactory(org.jboss.as.ejb3.component.interceptors.ComponentTypeIdentityInterceptorFactory) StatelessRemoteViewInstanceFactory(org.jboss.as.ejb3.component.session.StatelessRemoteViewInstanceFactory) DeploymentPhaseContext(org.jboss.as.server.deployment.DeploymentPhaseContext)

Example 25 with ComponentDescription

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

the class IIOPJndiBindingProcessor method deploy.

@Override
public void deploy(DeploymentPhaseContext phaseContext) throws DeploymentUnitProcessingException {
    final DeploymentUnit deploymentUnit = phaseContext.getDeploymentUnit();
    final EEModuleDescription moduleDescription = deploymentUnit.getAttachment(Attachments.EE_MODULE_DESCRIPTION);
    final Module module = deploymentUnit.getAttachment(org.jboss.as.server.deployment.Attachments.MODULE);
    if (moduleDescription == null) {
        return;
    }
    //do not bind if jacORB not present
    if (!IIOPDeploymentMarker.isIIOPDeployment(deploymentUnit)) {
        return;
    }
    final ServiceTarget serviceTarget = phaseContext.getServiceTarget();
    if (DeploymentTypeMarker.isType(DeploymentType.WAR, deploymentUnit) || DeploymentTypeMarker.isType(DeploymentType.APPLICATION_CLIENT, deploymentUnit)) {
        final ServiceName moduleContextServiceName = ContextNames.contextServiceNameOfModule(moduleDescription.getApplicationName(), moduleDescription.getModuleName());
        bindService(serviceTarget, moduleContextServiceName, module);
    }
    for (ComponentDescription component : moduleDescription.getComponentDescriptions()) {
        if (component.getNamingMode() == ComponentNamingMode.CREATE) {
            final ServiceName compContextServiceName = ContextNames.contextServiceNameOfComponent(moduleDescription.getApplicationName(), moduleDescription.getModuleName(), component.getComponentName());
            bindService(serviceTarget, compContextServiceName, module);
        }
    }
}
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) Module(org.jboss.modules.Module) DeploymentUnit(org.jboss.as.server.deployment.DeploymentUnit)

Aggregations

ComponentDescription (org.jboss.as.ee.component.ComponentDescription)65 EEModuleDescription (org.jboss.as.ee.component.EEModuleDescription)45 DeploymentUnit (org.jboss.as.server.deployment.DeploymentUnit)44 ServiceName (org.jboss.msc.service.ServiceName)20 ComponentConfiguration (org.jboss.as.ee.component.ComponentConfiguration)19 DeploymentUnitProcessingException (org.jboss.as.server.deployment.DeploymentUnitProcessingException)18 Module (org.jboss.modules.Module)18 EJBComponentDescription (org.jboss.as.ejb3.component.EJBComponentDescription)17 ComponentConfigurator (org.jboss.as.ee.component.ComponentConfigurator)16 DeploymentPhaseContext (org.jboss.as.server.deployment.DeploymentPhaseContext)16 SessionBeanComponentDescription (org.jboss.as.ejb3.component.session.SessionBeanComponentDescription)15 DeploymentReflectionIndex (org.jboss.as.server.deployment.reflect.DeploymentReflectionIndex)11 HashMap (java.util.HashMap)10 HashSet (java.util.HashSet)9 EEApplicationClasses (org.jboss.as.ee.component.EEApplicationClasses)9 ServiceTarget (org.jboss.msc.service.ServiceTarget)9 ImmediateInterceptorFactory (org.jboss.invocation.ImmediateInterceptorFactory)8 BindingConfiguration (org.jboss.as.ee.component.BindingConfiguration)5 DependencyConfigurator (org.jboss.as.ee.component.DependencyConfigurator)5 InterceptorDescription (org.jboss.as.ee.component.InterceptorDescription)5