Java Code Examples for org.jboss.as.server.deployment.DeploymentUnit#getParent()
The following examples show how to use
org.jboss.as.server.deployment.DeploymentUnit#getParent() .
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: VirtualSecurityDomainProcessor.java From wildfly-core with GNU Lesser General Public License v2.1 | 6 votes |
@Override public void deploy(DeploymentPhaseContext phaseContext) throws DeploymentUnitProcessingException { DeploymentUnit deploymentUnit = phaseContext.getDeploymentUnit(); if (deploymentUnit.getParent() != null || !isVirtualDomainRequired(deploymentUnit)) { return; // Only interested in installation if this is really the root deployment. } ServiceName virtualDomainName = virtualDomainName(deploymentUnit); ServiceTarget serviceTarget = phaseContext.getServiceTarget(); ServiceBuilder<?> serviceBuilder = serviceTarget.addService(virtualDomainName); final SecurityDomain virtualDomain = SecurityDomain.builder().build(); final Consumer<SecurityDomain> consumer = serviceBuilder.provides(virtualDomainName); serviceBuilder.setInstance(Service.newInstance(consumer, virtualDomain)); serviceBuilder.setInitialMode(Mode.ON_DEMAND); serviceBuilder.install(); }
Example 2
Source File: CompositeIndexProcessor.java From wildfly-core with GNU Lesser General Public License v2.1 | 6 votes |
private Map<ModuleIdentifier, DeploymentUnit> buildSubdeploymentDependencyMap(DeploymentUnit deploymentUnit) { Set<ModuleIdentifier> depModuleIdentifiers = new HashSet<>(); for (ModuleDependency dep: deploymentUnit.getAttachment(Attachments.MODULE_SPECIFICATION).getAllDependencies()) { depModuleIdentifiers.add(dep.getIdentifier()); } DeploymentUnit top = deploymentUnit.getParent()==null?deploymentUnit:deploymentUnit.getParent(); Map<ModuleIdentifier, DeploymentUnit> res = new HashMap<>(); AttachmentList<DeploymentUnit> subDeployments = top.getAttachment(Attachments.SUB_DEPLOYMENTS); if (subDeployments != null) { for (DeploymentUnit subDeployment : subDeployments) { ModuleIdentifier moduleIdentifier = subDeployment.getAttachment(Attachments.MODULE_IDENTIFIER); if (depModuleIdentifiers.contains(moduleIdentifier)) { res.put(moduleIdentifier, subDeployment); } } } return res; }
Example 3
Source File: CamelDeploymentSettingsProcessor.java From wildfly-camel with Apache License 2.0 | 6 votes |
public void deploy(DeploymentPhaseContext phaseContext) throws DeploymentUnitProcessingException { final DeploymentUnit depUnit = phaseContext.getDeploymentUnit(); CamelDeploymentSettings.Builder depSettingsBuilder = depUnit .removeAttachment(CamelDeploymentSettings.BUILDER_ATTACHMENT_KEY); if (depSettingsBuilder != null && depUnit.getParent() == null) { /* * We do this only for parentless deployments because for ones that have a parent the build and attachment * is done by CamelDeploymentSettings.Builder.build() if the parent */ final CamelDeploymentSettings depSettings = depSettingsBuilder.build(); depUnit.putAttachment(CamelDeploymentSettings.ATTACHMENT_KEY, depSettings); } }
Example 4
Source File: CamelDependenciesProcessor.java From wildfly-camel with Apache License 2.0 | 6 votes |
public void deploy(DeploymentPhaseContext phaseContext) throws DeploymentUnitProcessingException { DeploymentUnit depUnit = phaseContext.getDeploymentUnit(); // Only operate on top level deployments if (depUnit.getParent() != null) { return; } List<DeploymentUnit> deployments = new ArrayList<>(); List<DeploymentUnit> subDeployments = depUnit.getAttachmentList(Attachments.SUB_DEPLOYMENTS); deployments.add(depUnit); deployments.addAll(subDeployments); for (DeploymentUnit deployment : deployments) { CamelDeploymentSettings depSettings = deployment.getAttachment(CamelDeploymentSettings.ATTACHMENT_KEY); if (depSettings.isEnabled()) { addDeploymentDependencies(deployment, depSettings); } } }
Example 5
Source File: DeploymentDependenciesProcessor.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(); if (deploymentUnit.hasAttachment(DeploymentDependencies.ATTACHMENT_KEY)) { if (deploymentUnit.getParent() != null) { ServerLogger.DEPLOYMENT_LOGGER.deploymentDependenciesAreATopLevelElement(deploymentUnit.getName()); } else { processDependencies(phaseContext, deploymentUnit); } } if (deploymentUnit.getParent() != null) { DeploymentUnit parent = deploymentUnit.getParent(); if (parent.hasAttachment(DeploymentDependencies.ATTACHMENT_KEY)) { processDependencies(phaseContext, parent); } } }
Example 6
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 7
Source File: ProcessApplicationAttachments.java From camunda-bpm-platform with Apache License 2.0 | 5 votes |
/** * return true if the deployment unit is either itself a process * application or part of a process application. */ public static boolean isPartOfProcessApplication(DeploymentUnit unit) { if(isProcessApplication(unit)) { return true; } if(unit.getParent() != null && unit.getParent() != unit) { return unit.getParent().hasAttachment(PART_OF_MARKER); } return false; }
Example 8
Source File: CamelDeploymentSettingsBuilderProcessor.java From wildfly-camel with Apache License 2.0 | 5 votes |
public void deploy(DeploymentPhaseContext phaseContext) throws DeploymentUnitProcessingException { final DeploymentUnit depUnit = phaseContext.getDeploymentUnit(); CamelDeploymentSettings.Builder depSettingsBuilder = depUnit.getAttachment(CamelDeploymentSettings.BUILDER_ATTACHMENT_KEY); if (depSettingsBuilder == null) { depSettingsBuilder = new CamelDeploymentSettings.Builder(); depUnit.putAttachment(CamelDeploymentSettings.BUILDER_ATTACHMENT_KEY, depSettingsBuilder); } else if (depSettingsBuilder.isDisabledByJbossAll()) { // Camel is explicitly disabled in jboss-all.xml return; } depSettingsBuilder.deploymentName(getDeploymentName(depUnit)); depSettingsBuilder.deploymentValid(isDeploymentValid(depUnit)); depSettingsBuilder.camelActivationAnnotationPresent(hasCamelActivationAnnotations(depUnit)); final DeploymentUnit parentDepUnit = depUnit.getParent(); if (parentDepUnit != null) { final CamelDeploymentSettings.Builder parentDepSettingsBuilder = parentDepUnit.getAttachment(CamelDeploymentSettings.BUILDER_ATTACHMENT_KEY); if (parentDepSettingsBuilder != null) { // This consumer is called by CamelDeploymentSettings.Builder.build() right after the child settings are built Consumer<CamelDeploymentSettings> consumer = (CamelDeploymentSettings ds) -> { depUnit.removeAttachment(CamelDeploymentSettings.BUILDER_ATTACHMENT_KEY); depUnit.putAttachment(CamelDeploymentSettings.ATTACHMENT_KEY, ds); }; parentDepSettingsBuilder.child(depSettingsBuilder, consumer); } } }
Example 9
Source File: VirtualDomainMarkerUtility.java From wildfly-core with GNU Lesser General Public License v2.1 | 5 votes |
private static DeploymentUnit toRoot(final DeploymentUnit deploymentUnit) { DeploymentUnit result = deploymentUnit; DeploymentUnit parent = result.getParent(); while (parent != null) { result = parent; parent = result.getParent(); } return result; }
Example 10
Source File: ProcessApplicationAttachments.java From camunda-bpm-platform with Apache License 2.0 | 5 votes |
/** * return true if the deployment unit is either itself a process * application or part of a process application. */ public static boolean isPartOfProcessApplication(DeploymentUnit unit) { if(isProcessApplication(unit)) { return true; } if(unit.getParent() != null && unit.getParent() != unit) { return unit.getParent().hasAttachment(PART_OF_MARKER); } return false; }
Example 11
Source File: ModuleIdentifierProcessor.java From wildfly-core with GNU Lesser General Public License v2.1 | 5 votes |
@Override public void deploy(DeploymentPhaseContext phaseContext) throws DeploymentUnitProcessingException { final DeploymentUnit deploymentUnit = phaseContext.getDeploymentUnit(); final ResourceRoot deploymentRoot = deploymentUnit.getAttachment(Attachments.DEPLOYMENT_ROOT); final DeploymentUnit parent = deploymentUnit.getParent(); final DeploymentUnit topLevelDeployment = parent == null ? deploymentUnit : parent; final VirtualFile toplevelRoot = topLevelDeployment.getAttachment(Attachments.DEPLOYMENT_ROOT).getRoot(); final ModuleIdentifier moduleIdentifier = createModuleIdentifier(deploymentUnit.getName(), deploymentRoot, topLevelDeployment, toplevelRoot, deploymentUnit.getParent() == null); deploymentUnit.putAttachment(Attachments.MODULE_IDENTIFIER, moduleIdentifier); }
Example 12
Source File: ModuleDependencyProcessor.java From wildfly-core with GNU Lesser General Public License v2.1 | 5 votes |
/** * Process the deployment root for module dependency information. * * @param phaseContext the deployment unit context * @throws DeploymentUnitProcessingException */ public void deploy(final DeploymentPhaseContext phaseContext) throws DeploymentUnitProcessingException { final DeploymentUnit deploymentUnit = phaseContext.getDeploymentUnit(); final ModuleSpecification moduleSpecification = deploymentUnit.getAttachment(Attachments.MODULE_SPECIFICATION); moduleSpecification.addUserDependencies(deploymentUnit.getAttachmentList(Attachments.MANIFEST_DEPENDENCIES)); if (deploymentUnit.getParent() != null) { // propagate parent manifest dependencies final List<ModuleDependency> parentDependencies = deploymentUnit.getParent().getAttachmentList(Attachments.MANIFEST_DEPENDENCIES); moduleSpecification.addUserDependencies(parentDependencies); } }
Example 13
Source File: ManifestExtensionNameProcessor.java From wildfly-core with GNU Lesser General Public License v2.1 | 5 votes |
/** {@inheritDoc} */ public void deploy(final DeploymentPhaseContext phaseContext) throws DeploymentUnitProcessingException { final DeploymentUnit deploymentUnit = phaseContext.getDeploymentUnit(); // we only want to process top level jar deployments if (deploymentUnit.getParent() != null) { return; } final ResourceRoot deploymentRoot = deploymentUnit.getAttachment(Attachments.DEPLOYMENT_ROOT); if (!deploymentRoot.getRoot().getName().endsWith(".jar")) { return; } // we are only interested in the root manifest // there should not be any additional resource roots for this type of deployment anyway final Manifest manifest = deploymentRoot.getAttachment(Attachments.MANIFEST); if (manifest == null) { return; } final Attributes mainAttributes = manifest.getMainAttributes(); final String extensionName = mainAttributes.getValue(EXTENSION_NAME); ServerLogger.DEPLOYMENT_LOGGER.debugf("Found Extension-Name manifest entry %s in %s", extensionName, deploymentRoot.getRoot().getPathName()); if (extensionName == null) { // no entry return; } final String implVersion = mainAttributes.getValue(IMPLEMENTATION_VERSION); final String implVendorId = mainAttributes.getValue(IMPLEMENTATION_VENDOR_ID); final String specVersion = mainAttributes.getValue(SPECIFICATION_VERSION); final ExtensionInfo info = new ExtensionInfo(extensionName, specVersion, implVersion, implVendorId); deploymentUnit.putAttachment(Attachments.EXTENSION_INFORMATION, info); phaseContext.addToAttachmentList(Attachments.NEXT_PHASE_DEPS, Services.JBOSS_DEPLOYMENT_EXTENSION_INDEX); }
Example 14
Source File: DeploymentStructureDescriptorParser.java From wildfly-core with GNU Lesser General Public License v2.1 | 4 votes |
private boolean isSubdeployment(ModuleIdentifier dependency, DeploymentUnit deploymentUnit) { DeploymentUnit top = deploymentUnit.getParent()==null?deploymentUnit:deploymentUnit.getParent(); return dependency.getName().startsWith(ServiceModuleLoader.MODULE_PREFIX.concat(top.getName())); }
Example 15
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 16
Source File: CamelDeploymentSettingsBuilderProcessor.java From wildfly-camel with Apache License 2.0 | 4 votes |
public static String getDeploymentName(final DeploymentUnit depUnit) { DeploymentUnit parent = depUnit.getParent(); return parent != null ? parent.getName() + "." + depUnit.getName() : depUnit.getName(); }
Example 17
Source File: KeycloakClusteredSsoDeploymentProcessor.java From keycloak with Apache License 2.0 | 4 votes |
private void addSamlReplicationConfiguration(DeploymentUnit deploymentUnit, DeploymentPhaseContext context) { WarMetaData warMetaData = deploymentUnit.getAttachment(WarMetaData.ATTACHMENT_KEY); if (warMetaData == null) { return; } JBossWebMetaData webMetaData = warMetaData.getMergedJBossWebMetaData(); if (webMetaData == null) { webMetaData = new JBossWebMetaData(); warMetaData.setMergedJBossWebMetaData(webMetaData); } // Find out default names of cache container and cache String cacheContainer = DEFAULT_CACHE_CONTAINER; String deploymentSessionCacheName = (deploymentUnit.getParent() == null ? "" : deploymentUnit.getParent().getName() + ".") + deploymentUnit.getName(); // Update names from jboss-web.xml's <replicationConfig> if (webMetaData.getReplicationConfig() != null && webMetaData.getReplicationConfig().getCacheName() != null) { ServiceName sn = ServiceName.parse(webMetaData.getReplicationConfig().getCacheName()); cacheContainer = (sn.length() > 1) ? sn.getParent().getSimpleName() : sn.getSimpleName(); deploymentSessionCacheName = sn.getSimpleName(); } String ssoCacheName = deploymentSessionCacheName + ".ssoCache"; // Override if they were set in the context parameters List<ParamValueMetaData> contextParams = webMetaData.getContextParams(); if (contextParams == null) { contextParams = new ArrayList<>(); } for (ParamValueMetaData contextParam : contextParams) { if (Objects.equals(contextParam.getParamName(), SSO_CACHE_CONTAINER_NAME_PARAM_NAME)) { cacheContainer = contextParam.getParamValue(); } else if (Objects.equals(contextParam.getParamName(), SSO_CACHE_NAME_PARAM_NAME)) { ssoCacheName = contextParam.getParamValue(); } } LOG.debugv("Determined SSO cache container configuration: container: {0}, cache: {1}", cacheContainer, ssoCacheName); // addCacheDependency(context, deploymentUnit, cacheContainer, cacheName); // Set context parameters for SSO cache container/name ParamValueMetaData paramContainer = new ParamValueMetaData(); paramContainer.setParamName(AdapterConstants.REPLICATION_CONFIG_CONTAINER_PARAM_NAME); paramContainer.setParamValue(cacheContainer); contextParams.add(paramContainer); ParamValueMetaData paramSsoCache = new ParamValueMetaData(); paramSsoCache.setParamName(AdapterConstants.REPLICATION_CONFIG_SSO_CACHE_PARAM_NAME); paramSsoCache.setParamValue(ssoCacheName); contextParams.add(paramSsoCache); webMetaData.setContextParams(contextParams); }
Example 18
Source File: KeycloakClusteredSsoDeploymentProcessor.java From keycloak with Apache License 2.0 | 4 votes |
private void addSamlReplicationConfiguration(DeploymentUnit deploymentUnit, DeploymentPhaseContext context) { WarMetaData warMetaData = deploymentUnit.getAttachment(WarMetaData.ATTACHMENT_KEY); if (warMetaData == null) { return; } JBossWebMetaData webMetaData = warMetaData.getMergedJBossWebMetaData(); if (webMetaData == null) { webMetaData = new JBossWebMetaData(); warMetaData.setMergedJBossWebMetaData(webMetaData); } // Find out default names of cache container and cache String cacheContainer = DEFAULT_CACHE_CONTAINER; String deploymentSessionCacheName = (deploymentUnit.getParent() == null ? "" : deploymentUnit.getParent().getName() + ".") + deploymentUnit.getName(); // Update names from jboss-web.xml's <replicationConfig> if (webMetaData.getReplicationConfig() != null && webMetaData.getReplicationConfig().getCacheName() != null) { ServiceName sn = ServiceName.parse(webMetaData.getReplicationConfig().getCacheName()); cacheContainer = (sn.length() > 1) ? sn.getParent().getSimpleName() : sn.getSimpleName(); deploymentSessionCacheName = sn.getSimpleName(); } String ssoCacheName = deploymentSessionCacheName + ".ssoCache"; // Override if they were set in the context parameters List<ParamValueMetaData> contextParams = webMetaData.getContextParams(); if (contextParams == null) { contextParams = new ArrayList<>(); } for (ParamValueMetaData contextParam : contextParams) { if (Objects.equals(contextParam.getParamName(), SSO_CACHE_CONTAINER_NAME_PARAM_NAME)) { cacheContainer = contextParam.getParamValue(); } else if (Objects.equals(contextParam.getParamName(), SSO_CACHE_NAME_PARAM_NAME)) { ssoCacheName = contextParam.getParamValue(); } } LOG.debugv("Determined SSO cache container configuration: container: {0}, cache: {1}", cacheContainer, ssoCacheName); addCacheDependency(context, deploymentUnit, cacheContainer, ssoCacheName); // Set context parameters for SSO cache container/name ParamValueMetaData paramContainer = new ParamValueMetaData(); paramContainer.setParamName(AdapterConstants.REPLICATION_CONFIG_CONTAINER_PARAM_NAME); paramContainer.setParamValue(cacheContainer); contextParams.add(paramContainer); ParamValueMetaData paramSsoCache = new ParamValueMetaData(); paramSsoCache.setParamName(AdapterConstants.REPLICATION_CONFIG_SSO_CACHE_PARAM_NAME); paramSsoCache.setParamValue(ssoCacheName); contextParams.add(paramSsoCache); webMetaData.setContextParams(contextParams); }
Example 19
Source File: ProcessApplicationAttachments.java From camunda-bpm-platform with Apache License 2.0 | 4 votes |
/** * marks a a {@link DeploymentUnit} as part of a process application */ public static void markPartOfProcessApplication(DeploymentUnit unit) { if(unit.getParent() != null && unit.getParent() != unit) { unit.getParent().putAttachment(PART_OF_MARKER, Boolean.TRUE); } }
Example 20
Source File: ProcessApplicationAttachments.java From camunda-bpm-platform with Apache License 2.0 | 4 votes |
/** * marks a a {@link DeploymentUnit} as part of a process application */ public static void markPartOfProcessApplication(DeploymentUnit unit) { if(unit.getParent() != null && unit.getParent() != unit) { unit.getParent().putAttachment(PART_OF_MARKER, Boolean.TRUE); } }