private static void addAnnotation(final DeploymentUnit deploymentUnit, AnnotationType annotation) { deploymentUnit.addToAttachmentList(WeldAttachments.BEAN_DEFINING_ANNOTATIONS, annotation); }
public void deploy(DeploymentPhaseContext phaseContext) throws DeploymentUnitProcessingException { // Always add system property resolver phaseContext.getDeploymentUnit().addToAttachmentList(Attachments.DEPLOYMENT_PROPERTY_RESOLVERS, SystemPropertyResolver.INSTANCE); }
@Override public void deploy(final DeploymentPhaseContext phaseContext) throws DeploymentUnitProcessingException { final DeploymentUnit deploymentUnit = phaseContext.getDeploymentUnit(); final ServiceName serviceName = deploymentUnit.getServiceName().append(SERVICE_NAME); final CachedConnectionManagerSetupAction action = new CachedConnectionManagerSetupAction(serviceName); phaseContext.getServiceTarget().addService(serviceName, action) .addDependency(ConnectorServices.CCM_SERVICE, CachedConnectionManager.class, action.cachedConnectionManager) .addDependency(ConnectorServices.NON_TX_CCM_SERVICE, CachedConnectionManager.class, action.noTxCcmValue) .install(); deploymentUnit.addToAttachmentList(Attachments.WEB_SETUP_ACTIONS, action); deploymentUnit.addToAttachmentList(Attachments.OTHER_EE_SETUP_ACTIONS, action); }
@Override public void deploy(DeploymentPhaseContext phaseContext) throws DeploymentUnitProcessingException { final DeploymentUnit deploymentUnit = phaseContext.getDeploymentUnit(); final ServiceName serviceName = deploymentUnit.getServiceName().append(SERVICE_NAME); final TransactionRollbackSetupAction service = new TransactionRollbackSetupAction(serviceName); phaseContext.getServiceTarget().addService(serviceName, service) .addDependency(TransactionManagerService.INTERNAL_SERVICE_NAME, TransactionManager.class, service.getTransactionManager()) .install(); deploymentUnit.addToAttachmentList(Attachments.WEB_SETUP_ACTIONS, service); }
private void bindServices(DeploymentUnit deploymentUnit, ServiceTarget serviceTarget, ServiceName contextServiceName) { BinderService inAppClientContainerService = new BinderService("InAppClientContainer"); final ServiceName inAppClientServiceName = contextServiceName.append("InAppClientContainer"); inAppClientContainerService.getManagedObjectInjector().inject(new ValueManagedReferenceFactory(Values.immediateValue(appclient))); serviceTarget.addService(inAppClientServiceName, inAppClientContainerService) .addDependency(contextServiceName, ServiceBasedNamingStore.class, inAppClientContainerService.getNamingStoreInjector()) .install(); deploymentUnit.addToAttachmentList(org.jboss.as.server.deployment.Attachments.JNDI_DEPENDENCIES, inAppClientServiceName); }
public void deploy(DeploymentPhaseContext phaseContext) throws DeploymentUnitProcessingException { final DeploymentUnit deploymentUnit = phaseContext.getDeploymentUnit(); DeploymentUnit current = deploymentUnit; final List<PropertyResolver> propertyResolvers = new ArrayList<PropertyResolver>(); do { final Properties deploymentProperties = current.getAttachment(Attachments.DEPLOYMENT_PROPERTIES); if (deploymentProperties != null) { propertyResolvers.add(new PropertiesPropertyResolver(deploymentProperties)); } current = current.getParent(); } while (current != null); if (!propertyResolvers.isEmpty()) { deploymentUnit.addToAttachmentList(Attachments.DEPLOYMENT_PROPERTY_RESOLVERS, new CompositePropertyResolver(propertyResolvers)); } }
protected void addComponent(final DeploymentUnit deploymentUnit, final EJBComponentDescription beanDescription) { final EjbJarDescription ejbJarDescription = getEjbJarDescription(deploymentUnit); if (appclient) { deploymentUnit.addToAttachmentList(Attachments.ADDITIONAL_RESOLVABLE_COMPONENTS, beanDescription); } else { // Add this component description to module description ejbJarDescription.getEEModuleDescription().addComponent(beanDescription); } }
public void deploy(DeploymentPhaseContext phaseContext) throws DeploymentUnitProcessingException { final DeploymentUnit deploymentUnit = phaseContext.getDeploymentUnit(); final AbstractVaultReader vaultReader = deploymentUnit.getAttachment(org.jboss.as.server.deployment.Attachments.VAULT_READER_ATTACHMENT_KEY); if(vaultReader != null) { deploymentUnit.addToAttachmentList(Attachments.DEPLOYMENT_PROPERTY_RESOLVERS, new VaultPropertyResolver(vaultReader)); } }
@Override public void deploy(DeploymentPhaseContext phaseContext) throws DeploymentUnitProcessingException { phaseContext.getDeploymentUnit().putAttachment(SecurityAttachments.SECURITY_ENABLED, true); phaseContext.getDeploymentUnit().addToAttachmentList(Attachments.ADDITIONAL_FACTORIES, SecurityContextHandleFactory.INSTANCE); }
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()); }
private void processExternalMounts(DeploymentUnit deploymentUnit, VirtualFile deploymentRoot) throws DeploymentUnitProcessingException { VirtualFile mounts = deploymentRoot.getChild(WEB_INF_EXTERNAL_MOUNTS); if(!mounts.exists()) { return; } try (InputStream data = mounts.openStream()) { String contents = FileUtils.readFile(data); String[] lines = contents.split("\n"); for(String line : lines) { String trimmed = line; int commentIndex = trimmed.indexOf("#"); if(commentIndex > -1) { trimmed = trimmed.substring(0, commentIndex); } trimmed = trimmed.trim(); if(trimmed.isEmpty()) { continue; } File path = new File(trimmed); if(path.exists()) { deploymentUnit.addToAttachmentList(UndertowAttachments.EXTERNAL_RESOURCES, path); } else { throw UndertowLogger.ROOT_LOGGER.couldNotFindExternalPath(path); } } } catch (IOException e) { throw new RuntimeException(e); } }
/** * Binds the java:comp/UserTransaction service and the java:comp/TransactionSynchronizationRegistry * * @param deploymentUnit The deployment unit * @param serviceTarget The service target * @param contextServiceName The service name of the context to bind to */ private void bindServices(DeploymentUnit deploymentUnit, ServiceTarget serviceTarget, ServiceName contextServiceName) { final ServiceName userTransactionServiceName = contextServiceName.append("UserTransaction"); final UserTransactionBindingService userTransactionBindingService = new UserTransactionBindingService("UserTransaction"); serviceTarget.addService(userTransactionServiceName, userTransactionBindingService) .addDependency(UserTransactionAccessControlService.SERVICE_NAME, UserTransactionAccessControlService.class,userTransactionBindingService.getUserTransactionAccessControlServiceInjector()) .addDependency(UserTransactionService.INTERNAL_SERVICE_NAME, UserTransaction.class, new ManagedReferenceInjector<UserTransaction>(userTransactionBindingService.getManagedObjectInjector())) .addDependency(contextServiceName, ServiceBasedNamingStore.class, userTransactionBindingService.getNamingStoreInjector()) .install(); deploymentUnit.addToAttachmentList(org.jboss.as.server.deployment.Attachments.JNDI_DEPENDENCIES,userTransactionServiceName); final ServiceName transactionSynchronizationRegistryName = contextServiceName.append("TransactionSynchronizationRegistry"); BinderService transactionSyncBinderService = new BinderService("TransactionSynchronizationRegistry"); serviceTarget.addService(transactionSynchronizationRegistryName, transactionSyncBinderService) .addDependency(TransactionSynchronizationRegistryService.INTERNAL_SERVICE_NAME, TransactionSynchronizationRegistry.class, new ManagedReferenceInjector<TransactionSynchronizationRegistry>(transactionSyncBinderService.getManagedObjectInjector())) .addDependency(contextServiceName, ServiceBasedNamingStore.class, transactionSyncBinderService.getNamingStoreInjector()) .install(); deploymentUnit.addToAttachmentList(org.jboss.as.server.deployment.Attachments.JNDI_DEPENDENCIES,transactionSynchronizationRegistryName); }
@Override public void deploy(DeploymentPhaseContext phaseContext) throws DeploymentUnitProcessingException { final DeploymentUnit deploymentUnit = phaseContext.getDeploymentUnit(); if(JsfVersionMarker.isJsfDisabled(deploymentUnit)) { return; } // Get the CDI-enabled ValidatorFactory and add it to the servlet context ValidatorFactory validatorFactory = deploymentUnit.getAttachment(BeanValidationAttachments.VALIDATOR_FACTORY); if(validatorFactory != null) { deploymentUnit.addToAttachmentList(ServletContextAttribute.ATTACHMENT_KEY, new ServletContextAttribute(VALIDATOR_FACTORY_KEY, validatorFactory)); } }
public static void registerAsComponent(String listener, DeploymentUnit deploymentUnit) { final EEApplicationClasses applicationClasses = deploymentUnit.getAttachment(Attachments.EE_APPLICATION_CLASSES_DESCRIPTION); final EEModuleDescription module = deploymentUnit.getAttachment(Attachments.EE_MODULE_DESCRIPTION); final WebComponentDescription componentDescription = new WebComponentDescription(listener, listener, module, deploymentUnit.getServiceName(), applicationClasses); module.addComponent(componentDescription); deploymentUnit.addToAttachmentList(WebComponentDescription.WEB_COMPONENTS, componentDescription.getStartServiceName()); }
/** * Add a ContextService for this module. * * @param phaseContext the deployment unit context * @throws DeploymentUnitProcessingException */ public void deploy(DeploymentPhaseContext phaseContext) throws DeploymentUnitProcessingException { final DeploymentUnit deploymentUnit = phaseContext.getDeploymentUnit(); if (deploymentUnit.getParent() != null) { return; } EEModuleDescription moduleDescription = deploymentUnit.getAttachment(org.jboss.as.ee.component.Attachments.EE_MODULE_DESCRIPTION); final ServiceTarget serviceTarget = phaseContext.getServiceTarget(); final ServiceName applicationContextServiceName = ContextNames.contextServiceNameOfApplication(moduleDescription.getApplicationName()); final NamingStoreService contextService = new NamingStoreService(true); serviceTarget.addService(applicationContextServiceName, contextService).install(); final ServiceName appNameServiceName = applicationContextServiceName.append("AppName"); final BinderService applicationNameBinder = new BinderService("AppName"); applicationNameBinder.getManagedObjectInjector().inject(new ValueManagedReferenceFactory(Values.immediateValue(moduleDescription.getApplicationName()))); serviceTarget.addService(appNameServiceName, applicationNameBinder) .addDependency(applicationContextServiceName, ServiceBasedNamingStore.class, applicationNameBinder.getNamingStoreInjector()) .install(); deploymentUnit.addToAttachmentList(org.jboss.as.server.deployment.Attachments.JNDI_DEPENDENCIES, appNameServiceName); deploymentUnit.putAttachment(Attachments.APPLICATION_CONTEXT_CONFIG, applicationContextServiceName); }
/** * Creates a {@link ResourceRoot} for the passed {@link VirtualFile file} and adds it to the list of {@link ResourceRoot}s * in the {@link DeploymentUnit deploymentUnit} * * @param deploymentUnit The deployment unit * @param file The file for which the resource root will be created * @param markAsSubDeployment If this is true, then the {@link ResourceRoot} that is created will be marked as a subdeployment * through a call to {@link SubDeploymentMarker#mark(org.jboss.as.server.deployment.module.ResourceRoot)} * @param explodeDuringMount If this is true then the {@link VirtualFile file} will be exploded during mount, * while creating the {@link ResourceRoot} * @return Returns the created {@link ResourceRoot} * @throws IOException */ private ResourceRoot createResourceRoot(final DeploymentUnit deploymentUnit, final VirtualFile file, final boolean markAsSubDeployment, final boolean explodeDuringMount) throws IOException { final boolean war = file.getName().toLowerCase(Locale.ENGLISH).endsWith(WAR_EXTENSION); final Closeable closable = file.isFile() ? mount(file, explodeDuringMount) : exportExplodedWar(war, file, deploymentUnit); final MountHandle mountHandle = new MountHandle(closable); final ResourceRoot resourceRoot = new ResourceRoot(file, mountHandle); deploymentUnit.addToAttachmentList(Attachments.RESOURCE_ROOTS, resourceRoot); if (markAsSubDeployment) { SubDeploymentMarker.mark(resourceRoot); } if (war) { resourceRoot.putAttachment(Attachments.INDEX_RESOURCE_ROOT, false); SubExplodedDeploymentMarker.mark(resourceRoot); } return resourceRoot; }
/** * Parse -jboss-beans.xml file. * * @param unit the deployment unit * @param beansXmlFile the beans xml file * @throws DeploymentUnitProcessingException * for any error */ protected void parseDescriptor(DeploymentUnit unit, VirtualFile beansXmlFile) throws DeploymentUnitProcessingException { if (beansXmlFile == null || beansXmlFile.exists() == false) return; InputStream xmlStream = null; try { xmlStream = beansXmlFile.openStream(); final XMLStreamReader reader = inputFactory.createXMLStreamReader(xmlStream); final ParseResult<KernelDeploymentXmlDescriptor> result = new ParseResult<KernelDeploymentXmlDescriptor>(); xmlMapper.parseDocument(result, reader); final KernelDeploymentXmlDescriptor xmlDescriptor = result.getResult(); if (xmlDescriptor != null) unit.addToAttachmentList(KernelDeploymentXmlDescriptor.ATTACHMENT_KEY, xmlDescriptor); else throw PojoLogger.ROOT_LOGGER.failedToParse(beansXmlFile); } catch (DeploymentUnitProcessingException e) { throw e; } catch (Exception e) { throw PojoLogger.ROOT_LOGGER.parsingException(beansXmlFile, e); } finally { VFSUtils.safeClose(xmlStream); } }
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 deploy(final DeploymentPhaseContext phaseContext) throws DeploymentUnitProcessingException { final DeploymentUnit deploymentUnit = phaseContext.getDeploymentUnit(); final ModuleSpecification moduleSpecification = deploymentUnit.getAttachment(Attachments.MODULE_SPECIFICATION); final List<GlobalModule> globalMods = this.globalModules; for (final GlobalModule module : globalMods) { final ModuleDependency dependency = new ModuleDependency(Module.getBootModuleLoader(), module.getModuleIdentifier(), false, false, module.isServices(), false); if (module.isMetaInf()) { dependency.addImportFilter(PathFilters.getMetaInfSubdirectoriesFilter(), true); dependency.addImportFilter(PathFilters.getMetaInfFilter(), true); } if(module.isAnnotations()) { deploymentUnit.addToAttachmentList(Attachments.ADDITIONAL_ANNOTATION_INDEXES, module.getModuleIdentifier()); } moduleSpecification.addSystemDependency(dependency); } }
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); } }