new ClassDescriptionTraversal(configuration.getComponentClass(), applicationClasses) { @Override public void handle(Class<?> clazz, EEModuleClassDescription classDescription) throws DeploymentUnitProcessingException { new ClassDescriptionTraversal(configuration.getComponentClass(), applicationClasses) { @Override public void handle(final Class<?> clazz, EEModuleClassDescription classDescription) throws DeploymentUnitProcessingException { configuration.addPostConstructInterceptors(new ArrayList<>(injectors), InterceptorOrder.ComponentPostConstruct.COMPONENT_RESOURCE_INJECTION_INTERCEPTORS); configuration.addPostConstructInterceptors(userPostConstruct, InterceptorOrder.ComponentPostConstruct.COMPONENT_USER_INTERCEPTORS); configuration.addPostConstructInterceptor(Interceptors.getTerminalInterceptorFactory(), InterceptorOrder.ComponentPostConstruct.TERMINAL_INTERCEPTOR); configuration.addPostConstructInterceptor(tcclInterceptor, InterceptorOrder.ComponentPostConstruct.TCCL_INTERCEPTOR); configuration.addPreDestroyInterceptors(new ArrayList<>(uninjectors), InterceptorOrder.ComponentPreDestroy.COMPONENT_UNINJECTION_INTERCEPTORS); configuration.addPreDestroyInterceptors(new ArrayList<>(destructors), InterceptorOrder.ComponentPreDestroy.COMPONENT_DESTRUCTION_INTERCEPTORS); configuration.addPreDestroyInterceptors(userPreDestroy, InterceptorOrder.ComponentPreDestroy.COMPONENT_USER_INTERCEPTORS); configuration.addPreDestroyInterceptor(Interceptors.getTerminalInterceptorFactory(), InterceptorOrder.ComponentPreDestroy.TERMINAL_INTERCEPTOR); configuration.addPreDestroyInterceptor(tcclInterceptor, InterceptorOrder.ComponentPreDestroy.TCCL_INTERCEPTOR); configuration.addPrePassivateInterceptors(componentUserPrePassivate, InterceptorOrder.ComponentPassivation.COMPONENT_USER_INTERCEPTORS); configuration.addPrePassivateInterceptor(Interceptors.getTerminalInterceptorFactory(), InterceptorOrder.ComponentPassivation.TERMINAL_INTERCEPTOR); configuration.addPrePassivateInterceptor(tcclInterceptor, InterceptorOrder.ComponentPassivation.TCCL_INTERCEPTOR); if (!componentUserPostActivate.isEmpty()) {
private static ServiceName addWeldInterceptorBindingService(final ServiceTarget target, final ComponentConfiguration configuration, final Class<?> componentClass, final String beanName, final ServiceName weldServiceName, final ServiceName weldStartService, final String beanDeploymentArchiveId, final ComponentInterceptorSupport componentInterceptorSupport) { ServiceName bindingServiceName = configuration.getComponentDescription().getServiceName().append(WeldInterceptorBindingsService.SERVICE_NAME); final ServiceBuilder<?> sb = target.addService(bindingServiceName); final Consumer<InterceptorBindings> interceptorBindingsConsumer = sb.provides(bindingServiceName); final Supplier<WeldBootstrapService> weldContainerSupplier = sb.requires(weldServiceName); sb.requires(weldStartService); sb.setInstance(new WeldInterceptorBindingsService(interceptorBindingsConsumer, weldContainerSupplier, beanDeploymentArchiveId, beanName, componentClass, componentInterceptorSupport)); sb.install(); return bindingServiceName; }
configuration.addTimeoutViewInterceptor(AdditionalSetupInterceptor.factory(ejbSetupActions), InterceptorOrder.View.EE_SETUP); configuration.addTimeoutViewInterceptor(shutDownInterceptorFactory, InterceptorOrder.View.SHUTDOWN_INTERCEPTOR); final ClassLoader classLoader = configuration.getModuleClassLoader(); configuration.addTimeoutViewInterceptor(AccessCheckingInterceptor.getFactory(), InterceptorOrder.View.CHECKING_INTERCEPTOR); configuration.addTimeoutViewInterceptor(new ImmediateInterceptorFactory(new ContextClassLoaderInterceptor(classLoader)), InterceptorOrder.View.TCCL_INTERCEPTOR); configuration.addTimeoutViewInterceptor(configuration.getNamespaceContextInterceptorFactory(), InterceptorOrder.View.JNDI_NAMESPACE_INTERCEPTOR); configuration.addTimeoutViewInterceptor(CurrentInvocationContextInterceptor.FACTORY, InterceptorOrder.View.INVOCATION_CONTEXT_INTERCEPTOR); EJBComponentDescription ejbComponentDescription = (EJBComponentDescription) description; final boolean securityRequired = hasBeanLevelSecurityMetadata(); if (ejbComponentDescription.isSecurityDomainKnown()) { final HashMap<Integer, InterceptorFactory> elytronInterceptorFactories = getElytronInterceptorFactories(policyContextID, ejbComponentDescription.isEnableJacc(), true); elytronInterceptorFactories.forEach((priority, elytronInterceptorFactory) -> configuration.addTimeoutViewInterceptor(elytronInterceptorFactory, priority)); } else if (deploymentUnit.hasAttachment(SecurityAttachments.SECURITY_ENABLED)) { configuration.addTimeoutViewInterceptor(new SecurityContextInterceptorFactory(securityRequired, policyContextID), InterceptorOrder.View.SECURITY_CONTEXT); final Set<Method> classMethods = configuration.getClassIndex().getClassMethods(); for (final Method method : classMethods) { configuration.addTimeoutViewInterceptor(method, new ImmediateInterceptorFactory(new ComponentDispatcherInterceptor(method)), InterceptorOrder.View.COMPONENT_DISPATCHER); configuration.getStartDependencies().add(new DependencyConfigurator<ComponentStartService>() { @Override public void configureDependency(final ServiceBuilder<?> serviceBuilder, final ComponentStartService service) throws DeploymentUnitProcessingException { configuration.addComponentInterceptor(ExecutionTimeInterceptor.FACTORY, InterceptorOrder.Component.EJB_EXECUTION_TIME_INTERCEPTOR, true); configuration.getCreateDependencies().add(new DependencyConfigurator<EJBComponentCreateService>() { @Override
@Override public void configure(final DeploymentPhaseContext context, final ComponentDescription description, final ComponentConfiguration configuration) throws DeploymentUnitProcessingException { configuration.addPostConstructInterceptor(EjbBMTInterceptor.FACTORY, InterceptorOrder.ComponentPostConstruct.TRANSACTION_INTERCEPTOR); configuration.addPreDestroyInterceptor(EjbBMTInterceptor.FACTORY, InterceptorOrder.ComponentPreDestroy.TRANSACTION_INTERCEPTOR); // add the bmt interceptor factory configuration.addComponentInterceptor(EjbBMTInterceptor.FACTORY, InterceptorOrder.Component.BMT_TRANSACTION_INTERCEPTOR, false); } });
@Override public void configure(DeploymentPhaseContext context, ComponentDescription description, ComponentConfiguration configuration) throws DeploymentUnitProcessingException { configuration.addPostConstructInterceptor(CurrentInvocationContextInterceptor.FACTORY, InterceptorOrder.ComponentPostConstruct.EJB_SESSION_CONTEXT_INTERCEPTOR); configuration.addPreDestroyInterceptor(CurrentInvocationContextInterceptor.FACTORY, InterceptorOrder.ComponentPostConstruct.EJB_SESSION_CONTEXT_INTERCEPTOR); } });
@Override public void configure(DeploymentPhaseContext context, ComponentDescription description, ComponentConfiguration configuration) throws DeploymentUnitProcessingException { configuration.addPostConstructInterceptor(CurrentInvocationContextInterceptor.FACTORY, InterceptorOrder.ComponentPostConstruct.EJB_SESSION_CONTEXT_INTERCEPTOR); configuration.addPreDestroyInterceptor(CurrentInvocationContextInterceptor.FACTORY, InterceptorOrder.ComponentPreDestroy.EJB_SESSION_CONTEXT_INTERCEPTOR); if(description.isPassivationApplicable()) { configuration.addPrePassivateInterceptor(CurrentInvocationContextInterceptor.FACTORY, InterceptorOrder.ComponentPassivation.EJB_SESSION_CONTEXT_INTERCEPTOR); configuration.addPostActivateInterceptor(CurrentInvocationContextInterceptor.FACTORY, InterceptorOrder.ComponentPassivation.EJB_SESSION_CONTEXT_INTERCEPTOR); } configuration.getConcurrentContext().addFactory(EJBContextHandleFactory.INSTANCE); } });
if (bindingConfiguration.getName().startsWith("java:comp") || !bindingConfiguration.getName().startsWith("java:")) { final String bindingName = bindingConfiguration.getName().startsWith("java:comp") ? bindingConfiguration.getName() : "java:comp/env/" + bindingConfiguration.getName(); final ContextNames.BindInfo bindInfo = ContextNames.bindInfoForEnvEntry(configuration.getApplicationName(), configuration.getModuleName(), configuration.getComponentName(), configuration.getComponentDescription().getNamingMode() == ComponentNamingMode.CREATE, bindingName); if (bound.contains(bindInfo.getBinderServiceName())) { continue; try { final BinderService service = new BinderService(bindInfo.getBindName(), bindingConfiguration.getSource()); jndiDepServiceBuilder.requires(bindInfo.getBinderServiceName()); ServiceBuilder<ManagedReferenceFactory> serviceBuilder = serviceTarget.addService(bindInfo.getBinderServiceName(), service); bindingConfiguration.getSource().getResourceValue(resolutionContext, serviceBuilder, phaseContext, service.getManagedObjectInjector()); serviceBuilder.addDependency(bindInfo.getParentContextServiceName(), ServiceBasedNamingStore.class, service.getNamingStoreInjector()); serviceBuilder.install(); } catch (DuplicateServiceException e) { ServiceController<ManagedReferenceFactory> registered = (ServiceController<ManagedReferenceFactory>) CurrentServiceContainer.getServiceContainer().getService(bindInfo.getBinderServiceName());
final String applicationName = configuration.getApplicationName(); final String moduleName = configuration.getModuleName(); final String componentName = configuration.getComponentName(); final EEApplicationClasses applicationClasses = deploymentUnit.getAttachment(Attachments.EE_APPLICATION_CLASSES_DESCRIPTION); final Module module = deploymentUnit.getAttachment(org.jboss.as.server.deployment.Attachments.MODULE); final ServiceName createServiceName = configuration.getComponentDescription().getCreateServiceName(); final ServiceName startServiceName = configuration.getComponentDescription().getStartServiceName(); final BasicComponentCreateService createService = configuration.getComponentCreateServiceFactory().constructService(configuration); final ServiceBuilder<Component> createBuilder = serviceTarget.addService(createServiceName, createService); ServiceName jndiDepServiceName = configuration.getComponentDescription().getServiceName().append(JNDI_BINDINGS_SERVICE); final ServiceBuilder<Void> jndiDepServiceBuilder = serviceTarget.addService(jndiDepServiceName, Service.NULL); jndiDependencies.add(jndiDepServiceName); for (DependencyConfigurator configurator : configuration.getCreateDependencies()) { configurator.configureDependency(createBuilder, createService); for (DependencyConfigurator configurator : configuration.getStartDependencies()) { configurator.configureDependency(startBuilder, startService); if (configuration.getComponentDescription().getNamingMode() == ComponentNamingMode.CREATE) { final NamingStoreService contextService = new NamingStoreService(true); serviceTarget.addService(configuration.getComponentDescription().getContextServiceName(), contextService).install(); configuration.getComponentDescription().getNamingMode() == ComponentNamingMode.USE_MODULE, configuration.getComponentName(), configuration.getModuleName(), configuration.getApplicationName()
@Override public void deploy(DeploymentPhaseContext phaseContext) throws DeploymentUnitProcessingException { final DeploymentUnit deploymentUnit = phaseContext.getDeploymentUnit(); final EEModuleConfiguration moduleConfiguration = deploymentUnit.getAttachment(EE_MODULE_CONFIGURATION); if (moduleConfiguration == null) { return; final ServiceTarget serviceTarget = phaseContext.getServiceTarget(); boolean clusteredSingletonFound = false; for (final ComponentConfiguration configuration : moduleConfiguration.getComponentConfigurations()) { ComponentDescription description = configuration.getComponentDescription(); if (description instanceof MessageDrivenComponentDescription) { final MessageDrivenComponentDescription mdbDescription = (MessageDrivenComponentDescription) description; final MdbDeliveryControllerService mdbDeliveryControllerService = new MdbDeliveryControllerService(); final ServiceBuilder<MdbDeliveryControllerService> builder = serviceTarget .addService(mdbDescription.getDeliveryControllerName(), mdbDeliveryControllerService) .addDependency(description.getCreateServiceName(), MessageDrivenComponent.class, mdbDeliveryControllerService.getMdbComponent()) .setInitialMode(Mode.PASSIVE); if (mdbDescription.isClusteredSingleton()) { clusteredSingletonFound = true; builder.requires(CLUSTERED_SINGLETON_CAPABILITY.getCapabilityServiceName()); if (phaseContext.getServiceRegistry().getService(deliveryGroupServiceName) == null) { throw EjbLogger.DEPLOYMENT_LOGGER.missingMdbDeliveryGroup(mdbDescription.getDeliveryGroup()); serviceTarget.addDependency(SingletonBarrierService.SERVICE_NAME);
public static ServiceController<CamelEndpointDeployerService> addService(DeploymentUnit deploymentUnit, ServiceTarget serviceTarget, ServiceName deploymentInfoServiceName, ServiceName hostServiceName) { CamelEndpointDeployerService service = new CamelEndpointDeployerService(); ServiceBuilder<CamelEndpointDeployerService> sb = serviceTarget .addService(deployerServiceName(deploymentUnit.getServiceName()), service); sb.addDependency(hostServiceName, Host.class, service.hostSupplier); sb.addDependency(deploymentInfoServiceName, DeploymentInfo.class, service.deploymentInfoSupplier); sb.addDependency( CamelEndpointDeploymentSchedulerService.deploymentSchedulerServiceName(deploymentUnit.getServiceName()), CamelEndpointDeploymentSchedulerService.class, service.deploymentSchedulerServiceSupplier); sb.addDependency(UndertowService.SERVLET_CONTAINER.append("default"), ServletContainerService.class, service.servletContainerServiceSupplier); final EEModuleConfiguration moduleConfiguration = deploymentUnit .getAttachment(org.jboss.as.ee.component.Attachments.EE_MODULE_CONFIGURATION); if (moduleConfiguration != null) { for (final ComponentConfiguration c : moduleConfiguration.getComponentConfigurations()) { sb.addDependency(c.getComponentDescription().getStartServiceName()); } } return sb.install(); }
context.getServiceTarget().addService(invokerServiceName, invoker) .addDependency(componentDescription.getCreateServiceName(), EJBComponent.class, invoker.getEjbComponent()) .install(); 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())) { ejbComponentDescription.setTimerService(service); configuration.getStartDependencies().add(new DependencyConfigurator<ComponentStartService>() { @Override public void configureDependency(final ServiceBuilder<?> serviceBuilder, final ComponentStartService service) throws DeploymentUnitProcessingException {
final ServiceName serviceName = configuration.getComponentDescription().getServiceName().append("WeldInstantiator"); final WeldManagedReferenceFactory factory = new WeldManagedReferenceFactory(componentClass, beanName, interceptorClasses, classLoader, beanDeploymentArchiveId, description.isCDIInterceptorEnabled()); configuration.setInstanceFactory(factory); configuration.getStartDependencies().add(new DependencyConfigurator<ComponentStartService>() { @Override public void configureDependency(final ServiceBuilder<?> serviceBuilder, ComponentStartService service) throws DeploymentUnitProcessingException { configuration.addComponentInterceptor(requestFactory, InterceptorOrder.Component.CDI_REQUEST_SCOPE, false); configuration.addComponentInterceptor(new UserInterceptorFactory(aroundInvokeFactory, aroundTimeoutFactory), InterceptorOrder.Component.CDI_INTERCEPTORS, false); final Jsr299BindingsInterceptor.Factory preDestroyInterceptor = new Jsr299BindingsInterceptor.Factory(description.getBeanDeploymentArchiveId(), beanName, InterceptionType.PRE_DESTROY, classLoader); builder.addDependency(weldServiceName, WeldBootstrapService.class, preDestroyInterceptor.getWeldContainer()); configuration.addPreDestroyInterceptor(preDestroyInterceptor, InterceptorOrder.ComponentPreDestroy.CDI_INTERCEPTORS); if (description.isPassivationApplicable()) { final Jsr299BindingsInterceptor.Factory prePassivateInterceptor = new Jsr299BindingsInterceptor.Factory(description.getBeanDeploymentArchiveId(), beanName, InterceptionType.PRE_PASSIVATE, classLoader); builder.addDependency(weldServiceName, WeldBootstrapService.class, prePassivateInterceptor.getWeldContainer()); configuration.addPrePassivateInterceptor(prePassivateInterceptor, InterceptorOrder.ComponentPassivation.CDI_INTERCEPTORS); final Jsr299BindingsInterceptor.Factory postActivateInterceptor = new Jsr299BindingsInterceptor.Factory(description.getBeanDeploymentArchiveId(), beanName, InterceptionType.POST_ACTIVATE, classLoader); builder.addDependency(weldServiceName, WeldBootstrapService.class, postActivateInterceptor.getWeldContainer()); configuration.addPostActivateInterceptor(postActivateInterceptor, InterceptorOrder.ComponentPassivation.CDI_INTERCEPTORS); final Jsr299BindingsInterceptor.Factory postConstruct = new Jsr299BindingsInterceptor.Factory(description.getBeanDeploymentArchiveId(), beanName, InterceptionType.POST_CONSTRUCT, classLoader); builder.addDependency(weldServiceName, WeldBootstrapService.class, postConstruct.getWeldContainer()); configuration.addPostConstructInterceptor(postConstruct, InterceptorOrder.ComponentPostConstruct.CDI_INTERCEPTORS);
final ComponentFactory instanceFactory = configuration.getInstanceFactory(); if (instanceFactory != null) { instantiator = new ImmediateInterceptorFactory(new ComponentInstantiatorInterceptor(instanceFactory, BasicComponentInstance.INSTANCE_KEY, true)); } else { final ClassReflectionIndex componentClassIndex = deploymentReflectionIndex.getClassIndex(configuration.getComponentClass()); throw EeLogger.ROOT_LOGGER.defaultConstructorNotFound(configuration.getComponentClass()); configuration.getInterceptorContextKeys().add(contextKey); throw EeLogger.ROOT_LOGGER.defaultConstructorNotFoundOnComponent(interceptorClassName, configuration.getComponentClass()); configuration.addPostConstructInterceptors(new ArrayList<>(injectors), InterceptorOrder.ComponentPostConstruct.INTERCEPTOR_RESOURCE_INJECTION_INTERCEPTORS); configuration.addPostConstructInterceptors(new ArrayList<>(instantiators), InterceptorOrder.ComponentPostConstruct.INTERCEPTOR_INSTANTIATION_INTERCEPTORS); configuration.addAroundConstructInterceptors(userAroundConstruct, InterceptorOrder.AroundConstruct.INTERCEPTOR_AROUND_CONSTRUCT); configuration.addAroundConstructInterceptor(instantiator, InterceptorOrder.AroundConstruct.CONSTRUCT_COMPONENT); configuration.addAroundConstructInterceptor(new ImmediateInterceptorFactory(Interceptors.getTerminalInterceptor()), InterceptorOrder.AroundConstruct.TERMINAL_INTERCEPTOR); if(!configuration.getAroundConstructInterceptors().isEmpty()) { configuration.addPostConstructInterceptor(new AroundConstructInterceptorFactory(Interceptors.getChainedInterceptorFactory(configuration.getAroundConstructInterceptors())), InterceptorOrder.ComponentPostConstruct.AROUND_CONSTRUCT_CHAIN); configuration.addPostConstructInterceptors(userPostConstruct, InterceptorOrder.ComponentPostConstruct.INTERCEPTOR_USER_INTERCEPTORS); configuration.addPreDestroyInterceptors(new ArrayList<>(uninjectors), InterceptorOrder.ComponentPreDestroy.INTERCEPTOR_UNINJECTION_INTERCEPTORS); configuration.addPreDestroyInterceptors(new ArrayList<>(destructors), InterceptorOrder.ComponentPreDestroy.INTERCEPTOR_DESTRUCTION_INTERCEPTORS);
final ServiceName serviceName = configuration.getComponentDescription().getServiceName().append("WeldInstantiator"); final ServiceBuilder<?> builder = target.addService(serviceName); builder.requires(weldStartService); configuration.setInstanceFactory(WeldManagedReferenceFactory.INSTANCE); configuration.getStartDependencies().add(new DependencyConfigurator<ComponentStartService>() { @Override public void configureDependency(final ServiceBuilder<?> serviceBuilder, ComponentStartService service) throws DeploymentUnitProcessingException { componentInterceptorSupport); addCommonLifecycleInterceptionSupport(configuration, builder, bindingServiceName, beanManagerService, componentInterceptorSupport); configuration.addComponentInterceptor( new UserInterceptorFactory(factory(InterceptionType.AROUND_INVOKE, builder, bindingServiceName, componentInterceptorSupport), factory(InterceptionType.AROUND_TIMEOUT, builder, bindingServiceName, componentInterceptorSupport)), description.setIgnoreLifecycleInterceptors(true); //otherwise they will be called twice configuration.addPostConstructInterceptor(new ImmediateInterceptorFactory(new AbstractInjectionTargetDelegatingInterceptor() { @Override protected void run(Object instance) { configuration.addPreDestroyInterceptor(new ImmediateInterceptorFactory(new AbstractInjectionTargetDelegatingInterceptor() { @Override protected void run(Object instance) { configuration.addPostConstructInterceptor(new ImmediateInterceptorFactory(new WeldInjectionContextInterceptor(weldComponentService)), InterceptorOrder.ComponentPostConstruct.WELD_INJECTION_CONTEXT_INTERCEPTOR); configuration.addPostConstructInterceptor(new ImmediateInterceptorFactory(new WeldInterceptorInjectionInterceptor(interceptorClasses)), InterceptorOrder.ComponentPostConstruct.INTERCEPTOR_WELD_INJECTION); configuration.addPostConstructInterceptor(WeldInjectionInterceptor.FACTORY, InterceptorOrder.ComponentPostConstruct.COMPONENT_WELD_INJECTION);
@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.requires(nonFunctionalTimerServiceName); } }); } });
public void deploy(final DeploymentPhaseContext phaseContext) throws DeploymentUnitProcessingException { final DeploymentUnit deploymentUnit = phaseContext.getDeploymentUnit(); final Module module = deploymentUnit.getAttachment(MODULE); final EEModuleConfiguration moduleConfiguration = deploymentUnit.getAttachment(EE_MODULE_CONFIGURATION); if (module == null || moduleConfiguration == null) { return; } ComponentRegistry componentRegistry = deploymentUnit.getAttachment(COMPONENT_REGISTRY); final List<ServiceName> dependencies = deploymentUnit.getAttachmentList(org.jboss.as.server.deployment.Attachments.JNDI_DEPENDENCIES); final ServiceName bindingDependencyService = JndiNamingDependencyProcessor.serviceName(deploymentUnit.getServiceName()); // Iterate through each component, installing it into the container for (final ComponentConfiguration configuration : moduleConfiguration.getComponentConfigurations()) { try { ROOT_LOGGER.tracef("Installing component %s", configuration.getComponentClass().getName()); deployComponent(phaseContext, configuration, dependencies, bindingDependencyService); componentRegistry.addComponent(configuration); //we need to make sure that the web deployment has a dependency on all components it the app, so web components are started //when the web subsystem is starting //we only add a dependency on components in the same sub deployment, otherwise we get circular dependencies when initialize-in-order is used deploymentUnit.addToAttachmentList(org.jboss.as.server.deployment.Attachments.WEB_DEPENDENCIES, configuration.getComponentDescription().getStartServiceName()); } catch (Exception e) { throw EeLogger.ROOT_LOGGER.failedToInstallComponent(e, configuration.getComponentName()); } } }
@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); } });
@Override public void configure(DeploymentPhaseContext context, ComponentDescription description, final ComponentConfiguration configuration) throws DeploymentUnitProcessingException { final ConcurrentContext concurrentContext = configuration.getConcurrentContext(); // setup context setupConcurrentContext(concurrentContext, description.getApplicationName(), description.getModuleName(), description.getComponentName(), configuration.getModuleClassLoader(), configuration.getNamespaceContextSelector(), context.getDeploymentUnit(), context.getServiceTarget()); // add the interceptor which manages the concurrent context final ConcurrentContextInterceptor interceptor = new ConcurrentContextInterceptor(concurrentContext); final InterceptorFactory interceptorFactory = new ImmediateInterceptorFactory(interceptor); configuration.addPostConstructInterceptor(interceptorFactory, InterceptorOrder.ComponentPostConstruct.CONCURRENT_CONTEXT); configuration.addPreDestroyInterceptor(interceptorFactory, InterceptorOrder.ComponentPreDestroy.CONCURRENT_CONTEXT); if (description.isPassivationApplicable()) { configuration.addPrePassivateInterceptor(interceptorFactory, InterceptorOrder.ComponentPassivation.CONCURRENT_CONTEXT); configuration.addPostActivateInterceptor(interceptorFactory, InterceptorOrder.ComponentPassivation.CONCURRENT_CONTEXT); } configuration.addComponentInterceptor(interceptorFactory, InterceptorOrder.Component.CONCURRENT_CONTEXT, false); } };
final ComponentNamingMode namingMode = description.getNamingMode(); final InjectedEENamespaceContextSelector selector = new InjectedEENamespaceContextSelector(); final String applicationName = configuration.getApplicationName(); final String moduleName = configuration.getModuleName(); final String compName = configuration.getComponentName(); final ServiceName appContextServiceName = ContextNames.contextServiceNameOfApplication(applicationName); final ServiceName moduleContextServiceName = ContextNames.contextServiceNameOfModule(applicationName, moduleName); final Injector<NamingStore> exportedInjector = selector.getExportedContextInjector(); configuration.getStartDependencies().add(new DependencyConfigurator<ComponentStartService>() { public void configureDependency(final ServiceBuilder<?> serviceBuilder, ComponentStartService service) { serviceBuilder.addDependency(appContextServiceName, NamingStore.class, appInjector); final InterceptorFactory interceptorFactory = new ImmediateInterceptorFactory(new NamespaceContextInterceptor(selector, context.getDeploymentUnit().getServiceName())); configuration.addPostConstructInterceptor(interceptorFactory, InterceptorOrder.ComponentPostConstruct.JNDI_NAMESPACE_INTERCEPTOR); configuration.addPreDestroyInterceptor(interceptorFactory, InterceptorOrder.ComponentPreDestroy.JNDI_NAMESPACE_INTERCEPTOR); if(description.isPassivationApplicable()) { configuration.addPrePassivateInterceptor(interceptorFactory, InterceptorOrder.ComponentPassivation.JNDI_NAMESPACE_INTERCEPTOR); configuration.addPostActivateInterceptor(interceptorFactory, InterceptorOrder.ComponentPassivation.JNDI_NAMESPACE_INTERCEPTOR); configuration.setNamespaceContextInterceptorFactory(interceptorFactory); configuration.setNamespaceContextSelector(selector);
public void deploy(final DeploymentPhaseContext phaseContext) throws DeploymentUnitProcessingException { final DeploymentUnit deploymentUnit = phaseContext.getDeploymentUnit(); final EEApplicationClasses applicationClasses = deploymentUnit.getAttachment(Attachments.EE_APPLICATION_CLASSES_DESCRIPTION); final EEModuleConfiguration moduleConfiguration = deploymentUnit.getAttachment(Attachments.EE_MODULE_CONFIGURATION); final EEModuleDescription eeModuleDescription = deploymentUnit.getAttachment(Attachments.EE_MODULE_DESCRIPTION); final Module module = deploymentUnit.getAttachment(org.jboss.as.server.deployment.Attachments.MODULE); if (moduleConfiguration == null) { final List<BindingConfiguration> bindingConfigurations = eeModuleDescription.getBindingConfigurations(); for (BindingConfiguration binding : componentConfiguration.getComponentDescription().getBindingConfigurations()) { final String bindingName = binding.getName(); final boolean compBinding = bindingName.startsWith("java:comp") || !bindingName.startsWith("java:"); if (componentConfiguration.getComponentDescription().getNamingMode() == ComponentNamingMode.CREATE && compBinding) { classConfigurations.add(componentConfiguration.getComponentClass()); for (final InterceptorDescription interceptor : componentConfiguration.getComponentDescription().getAllInterceptors()) { try { classConfigurations.add(ClassLoadingUtils.loadClass(interceptor.getInterceptorClassName(), module)); } catch (ClassNotFoundException e) { throw EeLogger.ROOT_LOGGER.cannotLoadInterceptor(e, interceptor.getInterceptorClassName(), componentConfiguration.getComponentClass()); processClassConfigurations(phaseContext, applicationClasses, moduleConfiguration, deploymentDescriptorBindings, handledClasses, componentConfiguration.getComponentDescription().getNamingMode(), classConfigurations, componentConfiguration.getComponentName(), dependencies); if (!MetadataCompleteMarker.isMetadataComplete(phaseContext.getDeploymentUnit()) && !appClient) { for (EEModuleClassDescription config : eeModuleDescription.getClassDescriptions()) { if (handledClasses.contains(config.getClassName())) { continue;