public ServiceComponentInstantiator(DeploymentUnit deploymentUnit, ComponentDescription componentDescription) { componentStartServiceName = componentDescription.getStartServiceName(); this.serviceRegistry = deploymentUnit.getServiceRegistry(); }
private List<ServiceName> getComponentStartServiceNames(DeploymentUnit deploymentUnit) { List<ServiceName> serviceNames = new ArrayList<>(); final EEModuleDescription eeModuleDescription = deploymentUnit.getAttachment(org.jboss.as.ee.component.Attachments.EE_MODULE_DESCRIPTION); if (eeModuleDescription == null) { return serviceNames; } for (ComponentDescription component : eeModuleDescription.getComponentDescriptions()) { serviceNames.add(component.getStartServiceName()); } return serviceNames; } }
private void installManagedBeanComponent(String className, final EEModuleDescription moduleDescription, final DeploymentUnit deploymentUnit, final EEApplicationClasses applicationClassesDescription) { final ComponentDescription componentDescription = new WebComponentDescription(MANAGED_BEAN.toString() + "." + className, className, moduleDescription, deploymentUnit.getServiceName(), applicationClassesDescription); moduleDescription.addComponent(componentDescription); deploymentUnit.addToAttachmentList(WebComponentDescription.WEB_COMPONENTS, componentDescription.getStartServiceName()); }
public void addComponent(final ComponentConfiguration componentConfiguration) { if(componentConfiguration.getViews().size() < 2) { if(componentConfiguration.getViews().size() == 0) { componentsByClass.put(componentConfiguration.getComponentClass(), new ComponentManagedReferenceFactory(componentConfiguration.getComponentDescription().getStartServiceName(), null)); } else { componentsByClass.put(componentConfiguration.getComponentClass(), new ComponentManagedReferenceFactory(componentConfiguration.getComponentDescription().getStartServiceName(), componentConfiguration.getViews().get(0).getViewServiceName())); } } }
private void setupDependencies(final EJBComponentDescription description, final EEApplicationDescription applicationDescription, final ResourceRoot deploymentRoot, final String[] annotationValues) throws DeploymentUnitProcessingException { for (final String annotationValue : annotationValues) { final Set<ComponentDescription> components = applicationDescription.getComponents(annotationValue, deploymentRoot.getRoot()); if (components.isEmpty()) { throw EjbLogger.ROOT_LOGGER.failToFindEjbRefByDependsOn(annotationValue, description.getComponentClassName()); } else if (components.size() != 1) { throw EjbLogger.ROOT_LOGGER.failToCallEjbRefByDependsOn(annotationValue, description.getComponentClassName(), components); } final ComponentDescription component = components.iterator().next(); description.addDependency(component.getStartServiceName()); if (description instanceof SingletonComponentDescription) { ((SingletonComponentDescription)description).getDependsOn().add(component.getStartServiceName()); if (ROOT_LOGGER.isDebugEnabled()) { ROOT_LOGGER.debugf(description.getEJBName() + " bean is dependent on " + component.getComponentName()); } } } } }
if (component instanceof EJBComponentDescription) { final EJBComponentDescription ejbComponentDescription = (EJBComponentDescription) component; componentStartServices.add(component.getStartServiceName());
deploymentUnit.addToAttachmentList(WebComponentDescription.WEB_COMPONENTS, description.getStartServiceName());
ROOT_LOGGER.debugf(e, "Not installing optional component %s due to an exception", componentDescription.getComponentName()); failed.add(componentDescription.getStartServiceName()); failed.add(componentDescription.getCreateServiceName()); failed.add(componentDescription.getServiceName());
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()); } } }
final ServiceName startServiceName = configuration.getComponentDescription().getStartServiceName(); final BasicComponentCreateService createService = configuration.getComponentCreateServiceFactory().constructService(configuration); final ServiceBuilder<Component> createBuilder = serviceTarget.addService(createServiceName, createService);
private void installManagementResource(ComponentConfiguration configuration, DeploymentUnit deploymentUnit) { final EJBComponentType type = EJBComponentType.getComponentType(configuration); PathAddress addr = getComponentAddress(type, configuration, deploymentUnit); final AbstractEJBComponentRuntimeHandler<?> handler = type.getRuntimeHandler(); handler.registerComponent(addr, configuration.getComponentDescription().getStartServiceName()); deploymentUnit.addToAttachmentList(EjbDeploymentAttachmentKeys.MANAGED_COMPONENTS, new InstalledComponent(type, addr)); final DeploymentResourceSupport deploymentResourceSupport = deploymentUnit.getAttachment(Attachments.DEPLOYMENT_RESOURCE_SUPPORT); deploymentResourceSupport.getDeploymentSubModel(EJB3Extension.SUBSYSTEM_NAME, addr.getLastElement()); final EJBComponentDescription description = (EJBComponentDescription) configuration.getComponentDescription(); if (description.isTimerServiceRequired()) { final PathAddress timerServiceAddress = PathAddress.pathAddress(addr.getLastElement(), EJB3SubsystemModel.TIMER_SERVICE_PATH); final TimerServiceResource timerServiceResource = ((TimerServiceImpl) description.getTimerService()).getResource(); deploymentResourceSupport.registerDeploymentSubResource(EJB3Extension.SUBSYSTEM_NAME, timerServiceAddress, timerServiceResource); } }
serviceBuilder.addDependency(paComponent.getStartServiceName()); serviceBuilder.addDependency(paViewServiceName, ComponentView.class, deploymentService.getPaComponentViewInjector()); } else {
serviceBuilder.addDependency(paComponent.getStartServiceName()); serviceBuilder.addDependency(paViewServiceName, ComponentView.class, deploymentService.getPaComponentViewInjector()); } else {
serviceBuilder.addDependency(paComponent.getStartServiceName()); serviceBuilder.addDependency(paViewServiceName, ComponentView.class, deploymentService.getPaComponentViewInjector()); } else {
public void addComponent(final ComponentConfiguration componentConfiguration) { if(componentConfiguration.getViews().size() < 2) { if(componentConfiguration.getViews().size() == 0) { componentsByClass.put(componentConfiguration.getComponentClass(), new ComponentManagedReferenceFactory(componentConfiguration.getComponentDescription().getStartServiceName(), null)); } else { componentsByClass.put(componentConfiguration.getComponentClass(), new ComponentManagedReferenceFactory(componentConfiguration.getComponentDescription().getStartServiceName(), componentConfiguration.getViews().get(0).getViewServiceName())); } } }
public void addComponent(final ComponentConfiguration componentConfiguration) { if(componentConfiguration.getViews().size() < 2) { if(componentConfiguration.getViews().size() == 0) { componentsByClass.put(componentConfiguration.getComponentClass(), new ComponentManagedReferenceFactory(componentConfiguration.getComponentDescription().getStartServiceName(), null)); } else { componentsByClass.put(componentConfiguration.getComponentClass(), new ComponentManagedReferenceFactory(componentConfiguration.getComponentDescription().getStartServiceName(), componentConfiguration.getViews().get(0).getViewServiceName())); } } }
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(); }
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(); }
private void setupDependencies(final EJBComponentDescription description, final EEApplicationDescription applicationDescription, final ResourceRoot deploymentRoot, final String[] annotationValues) throws DeploymentUnitProcessingException { for (final String annotationValue : annotationValues) { final Set<ComponentDescription> components = applicationDescription.getComponents(annotationValue, deploymentRoot.getRoot()); if (components.isEmpty()) { throw MESSAGES.failToFindEjbRefByDependsOn(annotationValue, description.getComponentClassName()); } else if (components.size() != 1) { throw MESSAGES.failToCallEjbRefByDependsOn(annotationValue, description.getComponentClassName(), components); } final ComponentDescription component = components.iterator().next(); description.addDependency(component.getStartServiceName(), DependencyType.REQUIRED); if (description instanceof SingletonComponentDescription) { ((SingletonComponentDescription)description).getDependsOn().add(component.getStartServiceName()); if (ROOT_LOGGER.isDebugEnabled()) { ROOT_LOGGER.debugf(description.getEJBName() + " bean is dependent on " + component.getComponentName()); } } } } }
private void installManagementResource(ComponentConfiguration configuration, DeploymentUnit deploymentUnit) { final EJBComponentType type = EJBComponentType.getComponentType(configuration); PathAddress addr = getComponentAddress(type, configuration, deploymentUnit); final AbstractEJBComponentRuntimeHandler handler = type.getRuntimeHandler(); handler.registerComponent(addr, configuration.getComponentDescription().getStartServiceName()); deploymentUnit.addToAttachmentList(EjbDeploymentAttachmentKeys.MANAGED_COMPONENTS, new InstalledComponent(type, addr)); deploymentUnit.createDeploymentSubModel(EJB3Extension.SUBSYSTEM_NAME, addr.getLastElement()); }