Java Code Examples for org.jboss.as.server.deployment.DeploymentUnit#addToAttachmentList()
The following examples show how to use
org.jboss.as.server.deployment.DeploymentUnit#addToAttachmentList() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: DeploymentVisibilityProcessor.java From wildfly-core with GNU Lesser General Public License v2.1 | 6 votes |
@Override public void deploy(final DeploymentPhaseContext phaseContext) throws DeploymentUnitProcessingException { final DeploymentUnit deploymentUnit = phaseContext.getDeploymentUnit(); final ModuleSpecification moduleSpec = deploymentUnit.getAttachment(org.jboss.as.server.deployment.Attachments.MODULE_SPECIFICATION); final Map<ModuleIdentifier, DeploymentUnit> deployments = new HashMap<ModuleIdentifier, DeploymentUnit>(); //local classes are always first deploymentUnit.addToAttachmentList(Attachments.ACCESSIBLE_SUB_DEPLOYMENTS, deploymentUnit); buildModuleMap(deploymentUnit, deployments); for (final ModuleDependency dependency : moduleSpec.getAllDependencies()) { final DeploymentUnit sub = deployments.get(dependency.getIdentifier()); if (sub != null) { deploymentUnit.addToAttachmentList(Attachments.ACCESSIBLE_SUB_DEPLOYMENTS, sub); } } }
Example 2
Source File: CamelContextBootstrapProcessor.java From wildfly-camel with Apache License 2.0 | 6 votes |
@Override public void deploy(final DeploymentPhaseContext phaseContext) throws DeploymentUnitProcessingException { final DeploymentUnit depUnit = phaseContext.getDeploymentUnit(); final Module module = depUnit.getAttachment(Attachments.MODULE); final String runtimeName = depUnit.getName(); // Add the camel context bootstraps to the deployment CamelDeploymentSettings depSettings = depUnit.getAttachment(CamelDeploymentSettings.ATTACHMENT_KEY); for (URL contextURL : depSettings.getCamelContextUrls()) { ClassLoader tccl = SecurityActions.getContextClassLoader(); try { SecurityActions.setContextClassLoader(module.getClassLoader()); SpringCamelContextBootstrap bootstrap = new SpringCamelContextBootstrap(contextURL, module.getClassLoader()); depUnit.addToAttachmentList(CamelConstants.CAMEL_CONTEXT_BOOTSTRAP_KEY, bootstrap); } catch (Exception ex) { throw new IllegalStateException("Cannot create camel context: " + runtimeName, ex); } finally { SecurityActions.setContextClassLoader(tccl); } } }
Example 3
Source File: Seam2Processor.java From wildfly-core with GNU Lesser General Public License v2.1 | 5 votes |
public void deploy(DeploymentPhaseContext phaseContext) throws DeploymentUnitProcessingException { DeploymentUnit deploymentUnit = phaseContext.getDeploymentUnit(); if (deploymentUnit.getParent() != null) { return; } final List<DeploymentUnit> deploymentUnits = new ArrayList<DeploymentUnit>(); deploymentUnits.add(deploymentUnit); deploymentUnits.addAll(deploymentUnit.getAttachmentList(Attachments.SUB_DEPLOYMENTS)); for (DeploymentUnit unit : deploymentUnits) { final ResourceRoot mainRoot = unit.getAttachment(Attachments.DEPLOYMENT_ROOT); if (mainRoot == null) continue; VirtualFile root = mainRoot.getRoot(); for (String path : SEAM_FILES) { if (root.getChild(path).exists()) { final ModuleSpecification moduleSpecification = deploymentUnit .getAttachment(Attachments.MODULE_SPECIFICATION); final ModuleLoader moduleLoader = Module.getBootModuleLoader(); moduleSpecification.addSystemDependency(new ModuleDependency(moduleLoader, VFS_MODULE, false, false, false, false)); // for VFS scanner try { ResourceLoader resourceLoader = ResourceLoaders.createJarResourceLoader(SEAM_INT_JAR, new JarFile( getSeamIntResourceRoot().getRoot().getPathName())); moduleSpecification.addResourceLoader(ResourceLoaderSpec.createResourceLoaderSpec(resourceLoader)); } catch (Exception e) { throw new DeploymentUnitProcessingException(e); } unit.addToAttachmentList(Attachments.RESOURCE_ROOTS, getSeamIntResourceRoot()); return; } } } }
Example 4
Source File: ManifestClassPathProcessor.java From wildfly-core with GNU Lesser General Public License v2.1 | 5 votes |
private ModuleIdentifier createAdditionalModule(final ResourceRoot resourceRoot, final DeploymentUnit topLevelDeployment, final VirtualFile topLevelRoot, final Map<VirtualFile, AdditionalModuleSpecification> additionalModules, final VirtualFile classPathFile, final ArrayDeque<RootEntry> resourceRoots) throws DeploymentUnitProcessingException { final ResourceRoot root = createResourceRoot(classPathFile, topLevelDeployment, topLevelRoot); final String pathName = root.getRoot().getPathNameRelativeTo(topLevelRoot); ModuleIdentifier identifier = ModuleIdentifier.create(ServiceModuleLoader.MODULE_PREFIX + topLevelDeployment.getName() + "." + pathName); AdditionalModuleSpecification module = new AdditionalModuleSpecification(identifier, root); topLevelDeployment.addToAttachmentList(Attachments.ADDITIONAL_MODULES, module); additionalModules.put(classPathFile, module); resourceRoot.addToAttachmentList(Attachments.CLASS_PATH_RESOURCE_ROOTS, root); //add this to the list of roots to be processed, so transitive class path entries will be respected resourceRoots.add(new RootEntry(module, root)); return identifier; }
Example 5
Source File: CamelContextActivationProcessor.java From wildfly-camel with Apache License 2.0 | 5 votes |
@Override public void deploy(final DeploymentPhaseContext phaseContext) throws DeploymentUnitProcessingException { DeploymentUnit depUnit = phaseContext.getDeploymentUnit(); CamelDeploymentSettings depSettings = depUnit.getAttachment(CamelDeploymentSettings.ATTACHMENT_KEY); if (!depSettings.isEnabled()) { return; } String runtimeName = depUnit.getName(); ServiceTarget serviceTarget = phaseContext.getServiceTarget(); ServiceName camelActivationServiceName = depUnit.getServiceName().append(CAMEL_CONTEXT_ACTIVATION_SERVICE_NAME.append(runtimeName)); List<SpringCamelContextBootstrap> camelctxBootstrapList = depUnit.getAttachmentList(CamelConstants.CAMEL_CONTEXT_BOOTSTRAP_KEY); CamelContextActivationService activationService = new CamelContextActivationService(camelctxBootstrapList, runtimeName); ServiceBuilder builder = serviceTarget.addService(camelActivationServiceName, activationService); // Ensure all camel contexts in the deployment are started before constructing servlets etc depUnit.addToAttachmentList(Attachments.WEB_DEPENDENCIES, camelActivationServiceName); // Add JNDI binding dependencies to CamelContextActivationService for (SpringCamelContextBootstrap bootstrap : camelctxBootstrapList) { for (String jndiName : bootstrap.getJndiNames()) { if (jndiName.startsWith("${")) { // Don't add the binding if it appears to be a Spring property placeholder value // these can't be resolved before refresh() has been called on the ApplicationContext LOGGER.warn("Skipping JNDI binding dependency for property placeholder value: {}", jndiName); } else { LOGGER.debug("Add CamelContextActivationService JNDI binding dependency for {}", jndiName); installBindingDependency(builder, jndiName); } } } builder.install(); }
Example 6
Source File: ManifestDependencyProcessor.java From wildfly-core with GNU Lesser General Public License v2.1 | 4 votes |
/** * Process the deployment root for module dependency information. * * @param phaseContext the deployment unit context * @throws org.jboss.as.server.deployment.DeploymentUnitProcessingException */ public void deploy(final DeploymentPhaseContext phaseContext) throws DeploymentUnitProcessingException { final DeploymentUnit deploymentUnit = phaseContext.getDeploymentUnit(); final ServiceModuleLoader deploymentModuleLoader = deploymentUnit.getAttachment(Attachments.SERVICE_MODULE_LOADER); final List<ResourceRoot> allResourceRoots = DeploymentUtils.allResourceRoots(deploymentUnit); DeploymentUnit top = deploymentUnit.getParent() == null ? deploymentUnit : deploymentUnit.getParent(); final Set<ModuleIdentifier> additionalModules = new HashSet<>(); final List<AdditionalModuleSpecification> additionalModuleList = top.getAttachmentList(Attachments.ADDITIONAL_MODULES); // Must synchronize on list as subdeployments executing Phase.STRUCTURE may be concurrently modifying it //noinspection SynchronizationOnLocalVariableOrMethodParameter synchronized (additionalModuleList) { for (AdditionalModuleSpecification i : additionalModuleList) { additionalModules.add(i.getModuleIdentifier()); } } for (final ResourceRoot resourceRoot : allResourceRoots) { final Manifest manifest = resourceRoot.getAttachment(Attachments.MANIFEST); if (manifest == null) continue; final String dependencyString = ManifestHelper.getMainAttributeValue(manifest, DEPENDENCIES_ATTR); if (dependencyString == null) continue; if(deploymentUnit.getParent() == null && SubDeploymentMarker.isSubDeployment(resourceRoot)) { //we do not want ears reading sub deployments manifests continue; } final String[] dependencyDefs = dependencyString.split(","); for (final String dependencyDef : dependencyDefs) { final String trimmed = dependencyDef.trim(); if(trimmed.isEmpty()) { continue; } final String[] dependencyParts = trimmed.split(" "); final ModuleIdentifier dependencyId = ModuleIdentifier.fromString(dependencyParts[0]); final boolean export = containsParam(dependencyParts, EXPORT_PARAM); final boolean optional = containsParam(dependencyParts, OPTIONAL_PARAM); final boolean services = containsParam(dependencyParts, SERVICES_PARAM); final boolean annotations = containsParam(dependencyParts, ANNOTATIONS_PARAM); final boolean metaInf = containsParam(dependencyParts, META_INF); final ModuleLoader dependencyLoader; if (dependencyId.getName().startsWith(ServiceModuleLoader.MODULE_PREFIX)) { dependencyLoader = deploymentModuleLoader; } else { dependencyLoader = Module.getBootModuleLoader(); } if(annotations) { deploymentUnit.addToAttachmentList(Attachments.ADDITIONAL_ANNOTATION_INDEXES, dependencyId); if(dependencyLoader == deploymentModuleLoader && !additionalModules.contains(dependencyId)) { //additional modules will not be created till much later, a dep on them would fail phaseContext.addToAttachmentList(Attachments.NEXT_PHASE_DEPS, ServiceModuleLoader.moduleServiceName(dependencyId)); } } final ModuleDependency dependency = new ModuleDependency(dependencyLoader, dependencyId, optional, export, services, true); if(metaInf) { dependency.addImportFilter(PathFilters.getMetaInfSubdirectoriesFilter(), true); dependency.addImportFilter(PathFilters.getMetaInfFilter(), true); } deploymentUnit.addToAttachmentList(Attachments.MANIFEST_DEPENDENCIES, dependency); } } }
Example 7
Source File: ProcessApplicationAttachments.java From camunda-bpm-platform with Apache License 2.0 | 2 votes |
/** * Attach the parsed ProcessesXml file to a deployment unit. * */ public static void addProcessesXml(DeploymentUnit unit, ProcessesXmlWrapper processesXmlWrapper) { unit.addToAttachmentList(PROCESSES_XML_LIST, processesXmlWrapper); }
Example 8
Source File: ProcessApplicationAttachments.java From camunda-bpm-platform with Apache License 2.0 | 2 votes |
/** * Attach the parsed ProcessesXml file to a deployment unit. * */ public static void addProcessesXml(DeploymentUnit unit, ProcessesXmlWrapper processesXmlWrapper) { unit.addToAttachmentList(PROCESSES_XML_LIST, processesXmlWrapper); }