private ServiceName getProfileServiceName(final DeploymentPhaseContext phaseContext) { final DeploymentUnit deploymentUnit = phaseContext.getDeploymentUnit(); final DeploymentUnit parentDeploymentUnit = deploymentUnit.getParent(); if (parentDeploymentUnit != null) { return parentDeploymentUnit.getAttachment(EjbDeploymentAttachmentKeys.EJB_REMOTING_PROFILE_SERVICE_NAME); } else { return deploymentUnit.getAttachment(EjbDeploymentAttachmentKeys.EJB_REMOTING_PROFILE_SERVICE_NAME); } }
@Override public ClassLoader getValue() throws IllegalStateException, IllegalArgumentException { final Module module = deploymentUnit.getAttachment(Attachments.MODULE); return module != null ? module.getClassLoader() : null; } };
/** * returns true if the {@link DeploymentUnit} is part of a weld deployment */ public static boolean isPartOfWeldDeployment(DeploymentUnit unit) { if (unit.getParent() == null) { return unit.getAttachment(MARKER) != null; } else { return unit.getParent().getAttachment(MARKER) != null; } }
@Override public void deploy(final DeploymentPhaseContext phaseContext) throws DeploymentUnitProcessingException { final DeploymentUnit deploymentUnit = phaseContext.getDeploymentUnit(); final List<EEModuleDescription> descriptions = new ArrayList<EEModuleDescription>(); for (final DeploymentUnit visibleDeployment : deploymentUnit.getAttachmentList(org.jboss.as.server.deployment.Attachments.ACCESSIBLE_SUB_DEPLOYMENTS)) { final EEModuleDescription description = visibleDeployment.getAttachment(Attachments.EE_MODULE_DESCRIPTION); if (description != null) { descriptions.add(description); } } final EEApplicationClasses classes = new EEApplicationClasses(descriptions); deploymentUnit.putAttachment(Attachments.EE_APPLICATION_CLASSES_DESCRIPTION, classes); }
@Override public synchronized void start(StartContext context) throws StartException { ApplicationSecurityDomain applicationSecurityDomain = getApplicationSecurityDomain(); BiFunction<String, ClassLoader, Registration> securityFunction = applicationSecurityDomain != null ? applicationSecurityDomain.getSecurityFunction() : null; if (securityFunction != null) { final String deploymentName = deploymentUnit.getParent() == null ? deploymentUnit.getName() : deploymentUnit.getParent().getName() + "." + deploymentUnit.getName(); final Module module = deploymentUnit.getAttachment(Attachments.MODULE); final ClassLoader classLoader = module.getClassLoader(); registration = securityFunction.apply(deploymentName, classLoader); } }
@Override public void deploy(final DeploymentPhaseContext phaseContext) throws DeploymentUnitProcessingException { DeploymentUnit deploymentUnit = phaseContext.getDeploymentUnit(); CapabilityServiceSupport support = deploymentUnit.getAttachment(Attachments.CAPABILITY_SERVICE_SUPPORT); ServiceName namingStoreServiceName = support.getCapabilityServiceName(NamingService.CAPABILITY_NAME); //this will always be up but we need to make sure the naming service is //not shut down before the deployment is undeployed when the container is shut down phaseContext.addToAttachmentList(Attachments.NEXT_PHASE_DEPS, namingStoreServiceName); List<ServiceName> dependencies = deploymentUnit.getAttachmentList(Attachments.JNDI_DEPENDENCIES); final ServiceName serviceName = serviceName(deploymentUnit.getServiceName()); final ServiceBuilder<?> serviceBuilder = phaseContext.getServiceTarget().addService(serviceName, new RuntimeBindReleaseService()); for (final ServiceName dependency : dependencies) { serviceBuilder.requires(dependency); } if(deploymentUnit.getParent() != null) { for (final ServiceName jndiDependency : deploymentUnit.getParent().getAttachment(Attachments.JNDI_DEPENDENCIES)) { serviceBuilder.requires(jndiDependency); } } serviceBuilder.requires(namingStoreServiceName); serviceBuilder.install(); }
final DeploymentUnit deploymentUnit = phaseContext.getDeploymentUnit(); final JBossServiceXmlDescriptor serviceXmlDescriptor = deploymentUnit.getAttachment(JBossServiceXmlDescriptor.ATTACHMENT_KEY); if (serviceXmlDescriptor == null) { final Module module = deploymentUnit.getAttachment(Attachments.MODULE); if (module == null) throw SarLogger.ROOT_LOGGER.failedToGetAttachment("module", deploymentUnit); final DeploymentReflectionIndex reflectionIndex = deploymentUnit.getAttachment(Attachments.REFLECTION_INDEX); if (reflectionIndex == null) throw SarLogger.ROOT_LOGGER.failedToGetAttachment("reflection index", deploymentUnit); final ClassLoader classLoader = module.getClassLoader(); final List<JBossServiceConfig> serviceConfigs = serviceXmlDescriptor.getServiceConfigs(); final ServiceTarget target = phaseContext.getServiceTarget(); final Map<String,ServiceComponentInstantiator> serviceComponents = deploymentUnit.getAttachment(ServiceAttachments.SERVICE_COMPONENT_INSTANTIATORS); for (final JBossServiceConfig serviceConfig : serviceConfigs) { addServices(target, serviceConfig, classLoader, reflectionIndex, serviceComponents != null ? serviceComponents.get(serviceConfig.getName()) : null, phaseContext);
/** * Process a deployment for standard ra deployment files. Will parse the xml * file and attach a configuration discovered during processing. * @param phaseContext the deployment unit context * @throws DeploymentUnitProcessingException */ @Override public void deploy(DeploymentPhaseContext phaseContext) throws DeploymentUnitProcessingException { final VirtualFile deploymentRoot = phaseContext.getDeploymentUnit().getAttachment(Attachments.DEPLOYMENT_ROOT).getRoot(); process(deploymentRoot); }
@Override public void deploy(DeploymentPhaseContext phaseContext) throws DeploymentUnitProcessingException { final DeploymentUnit deploymentUnit = phaseContext.getDeploymentUnit(); final Module module = deploymentUnit.getAttachment(Attachments.MODULE); final EEModuleDescription moduleDescription = deploymentUnit.getAttachment(org.jboss.as.ee.component.Attachments.EE_MODULE_DESCRIPTION); if(module == null || moduleDescription == null) { return; } final LazyValidatorFactory factory = new LazyValidatorFactory(module.getClassLoader()); deploymentUnit.putAttachment(BeanValidationAttachments.VALIDATOR_FACTORY, factory); bindFactoryToJndi(factory,deploymentUnit,phaseContext,moduleDescription); }
@Override public void deploy(DeploymentPhaseContext phaseContext) throws DeploymentUnitProcessingException { final DeploymentUnit deploymentUnit = phaseContext.getDeploymentUnit(); final ModuleSpecification moduleSpecification = deploymentUnit.getAttachment(Attachments.MODULE_SPECIFICATION); final ModuleLoader moduleLoader = Module.getBootModuleLoader(); // for (final ModuleIdentifier moduleIdentifier : DEPENDENCIES) { moduleSpecification.addSystemDependency(new ModuleDependency(moduleLoader, moduleIdentifier, true, false, true, false)); } }
@Override public void deploy(final DeploymentPhaseContext phaseContext) throws DeploymentUnitProcessingException { final DeploymentUnit deploymentUnit = phaseContext.getDeploymentUnit(); final EEModuleDescription eeModuleDescription = deploymentUnit.getAttachment(Attachments.EE_MODULE_DESCRIPTION); final Module module = deploymentUnit.getAttachment(org.jboss.as.server.deployment.Attachments.MODULE); final DeploymentReflectionIndex deploymentReflectionIndex = deploymentUnit.getAttachment(org.jboss.as.server.deployment.Attachments.REFLECTION_INDEX); final EEApplicationClasses applicationClasses = deploymentUnit.getAttachment(Attachments.EE_APPLICATION_CLASSES_DESCRIPTION); for (ComponentDescription componentDescription : deploymentUnit.getAttachmentList(Attachments.ADDITIONAL_RESOLVABLE_COMPONENTS)) { if (componentDescription instanceof SessionBeanComponentDescription) { try {
public void deploy(final DeploymentPhaseContext phaseContext) throws DeploymentUnitProcessingException { final DeploymentUnit deploymentUnit = phaseContext.getDeploymentUnit(); CompositePropertyResolver propertyResolver = new CompositePropertyResolver(deploymentUnit.getAttachment(Attachments.DEPLOYMENT_PROPERTY_RESOLVERS)); deploymentUnit.putAttachment(Attachments.FINAL_PROPERTY_RESOLVER, propertyResolver); deploymentUnit.putAttachment(Attachments.FINAL_PROPERTY_REPLACER, PropertyReplacers.resolvingReplacer(propertyResolver)); }
private void handleInfoFile(DeploymentUnit deploymentUnit, Module module) { final List<PredicatedHandler> handlerWrappers = new ArrayList<>(); ClassLoader oldCl = Thread.currentThread().getContextClassLoader(); try { ResourceRoot root = deploymentUnit.getAttachment(Attachments.DEPLOYMENT_ROOT); VirtualFile config = root.getRoot().getChild(WEB_INF); try { if (config.exists()) { handlerWrappers.addAll(PredicatedHandlersParser.parse(config.openStream(), module.getClassLoader())); } Enumeration<URL> paths = module.getClassLoader().getResources(META_INF); while (paths.hasMoreElements()) { URL path = paths.nextElement(); handlerWrappers.addAll(PredicatedHandlersParser.parse(path.openStream(), module.getClassLoader())); } } catch (IOException e) { throw new RuntimeException(e); } if (!handlerWrappers.isEmpty()) { deploymentUnit.putAttachment(PREDICATED_HANDLERS, handlerWrappers); } } finally { Thread.currentThread().setContextClassLoader(oldCl); } }
private void processModuleDescription(final EEModuleDescription moduleDescription, DeploymentUnit deploymentUnit, DeploymentPhaseContext phaseContext) { final ConcurrentContext concurrentContext = moduleDescription.getConcurrentContext(); // setup context setupConcurrentContext(concurrentContext, moduleDescription.getApplicationName(), moduleDescription.getModuleName(), null, deploymentUnit.getAttachment(MODULE).getClassLoader(), moduleDescription.getNamespaceContextSelector(), deploymentUnit, phaseContext.getServiceTarget()); // add setup action for web modules final ConcurrentContextSetupAction setupAction = new ConcurrentContextSetupAction(concurrentContext); deploymentUnit.getAttachmentList(Attachments.WEB_SETUP_ACTIONS).add(setupAction); }
private Set<ViewDescription> getViews() { final EEApplicationDescription applicationDescription = deploymentUnit.getAttachment(EE_APPLICATION_DESCRIPTION); final ResourceRoot deploymentRoot = deploymentUnit.getAttachment(Attachments.DEPLOYMENT_ROOT); final Set<ViewDescription> componentsForViewName; if (beanName != null) { componentsForViewName = applicationDescription.getComponents(beanName, typeName, deploymentRoot.getRoot()); } else { componentsForViewName = applicationDescription.getComponentsForViewName(typeName, deploymentRoot.getRoot()); } return componentsForViewName; }
protected static EjbJarDescription getEjbJarDescription(final DeploymentUnit deploymentUnit) { EjbJarDescription ejbJarDescription = deploymentUnit.getAttachment(EjbDeploymentAttachmentKeys.EJB_JAR_DESCRIPTION); final EEApplicationClasses applicationClassesDescription = deploymentUnit.getAttachment(org.jboss.as.ee.component.Attachments.EE_APPLICATION_CLASSES_DESCRIPTION); if (ejbJarDescription == null) { final EEModuleDescription moduleDescription = deploymentUnit.getAttachment(org.jboss.as.ee.component.Attachments.EE_MODULE_DESCRIPTION); ejbJarDescription = new EjbJarDescription(moduleDescription, deploymentUnit.getName().endsWith(".war")); deploymentUnit.putAttachment(EjbDeploymentAttachmentKeys.EJB_JAR_DESCRIPTION, ejbJarDescription); } return ejbJarDescription; }
@Override public void deploy(final DeploymentPhaseContext phaseContext) throws DeploymentUnitProcessingException { final DeploymentUnit deploymentUnit = phaseContext.getDeploymentUnit(); if (deploymentUnit.hasAttachment(Attachments.MODULE) && !DeploymentTypeMarker.isType(DeploymentType.EAR, deploymentUnit) && deploymentUnit.hasAttachment(Attachments.DEPLOYMENT_ROOT)) { BatchLogger.LOGGER.tracef("Processing deployment '%s' for the batch deployment resources.", deploymentUnit.getName()); final DeploymentResourceSupport deploymentResourceSupport = deploymentUnit.getAttachment(Attachments.DEPLOYMENT_RESOURCE_SUPPORT); // Add the job operator service used interact with a deployments batch job final WildFlyJobOperator jobOperator = deploymentUnit.getAttachment(BatchAttachments.JOB_OPERATOR); // Process each job XML file for (String jobName : jobOperator.getAllJobNames()) { try { // Add the job information to the service BatchLogger.LOGGER.debugf("Added job %s to allowed jobs for deployment %s", jobName, deploymentUnit.getName()); // Register the a resource for each job found final PathAddress jobAddress = PathAddress.pathAddress(BatchJobResourceDefinition.JOB, jobName); if (!deploymentResourceSupport.hasDeploymentSubModel(subsystemName, jobAddress)) { deploymentResourceSupport.registerDeploymentSubResource(subsystemName, jobAddress, new BatchJobExecutionResource(jobOperator, jobName)); } } catch (Exception e) { // The deployment shouldn't fail in this case, just the specific resource registration should be skipped // Log a debug message so the error is not lost BatchLogger.LOGGER.debugf(e, "Batch jobs as an error occurred will not be registered for runtime views on the deployment (%s).", jobName, deploymentUnit.getName()); } } } }
public static WeldPortableExtensions getPortableExtensions(final DeploymentUnit deploymentUnit) { if (deploymentUnit.getParent() == null) { WeldPortableExtensions pes = deploymentUnit.getAttachment(WeldPortableExtensions.ATTACHMENT_KEY); if (pes == null) { deploymentUnit.putAttachment(ATTACHMENT_KEY, pes = new WeldPortableExtensions()); } return pes; } else { return getPortableExtensions(deploymentUnit.getParent()); } }
public static void setType(final DeploymentType deploymentType, final DeploymentUnit deploymentUnit) { deploymentUnit.putAttachment(Attachments.DEPLOYMENT_TYPE, deploymentType); final ResourceRoot resourceRoot = deploymentUnit.getAttachment(org.jboss.as.server.deployment.Attachments.DEPLOYMENT_ROOT); if (resourceRoot != null) { resourceRoot.putAttachment(Attachments.DEPLOYMENT_TYPE, deploymentType); } }
/** * Process a deployment for jboss-beans.xml files. * Will parse the xml file and attach a configuration discovered during processing. * * @param phaseContext the deployment unit context * @throws DeploymentUnitProcessingException * */ @Override public void deploy(DeploymentPhaseContext phaseContext) throws DeploymentUnitProcessingException { DeploymentUnit unit = phaseContext.getDeploymentUnit(); final VirtualFile deploymentRoot = unit.getAttachment(Attachments.DEPLOYMENT_ROOT).getRoot(); parseDescriptors(unit, deploymentRoot); final List<ResourceRoot> resourceRoots = unit.getAttachmentList(Attachments.RESOURCE_ROOTS); for (ResourceRoot root : resourceRoots) parseDescriptors(unit, root.getRoot()); }