Skip to content

Commit

Permalink
[WFCORE-7127] Replace Attachments.CLASS_PATH_ENTRIES
Browse files Browse the repository at this point in the history
  • Loading branch information
bstansberry committed Dec 28, 2024
1 parent 1983240 commit 8a0a619
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@
/**
* @author <a href="mailto:[email protected]">David M. Lloyd</a>
*/
@SuppressWarnings("deprecation")
public final class Attachments {

//
Expand Down Expand Up @@ -125,14 +124,12 @@ public final class Attachments {
* <p/>
* <strong>Note: This is only meant for use within the server kernel.</strong>
*
* @deprecated this will either be changed incompatibly (to provide a string) or removed altogether in the next WildFly Core major.
*/
@Deprecated(forRemoval = true)
public static final AttachmentKey<AttachmentList<ModuleIdentifier>> CLASS_PATH_ENTRIES = AttachmentKey.createList(ModuleIdentifier.class);
public static final AttachmentKey<AttachmentList<String>> CLASS_PATH_MODULES = AttachmentKey.createList(String.class);

/**
* Resource roots for additional modules referenced via Class-Path.
*
* <p/>
* These are attached to the resource root that actually defined the class path entry, and are used to transitively resolve
* the annotation index for class path items.
*/
Expand Down Expand Up @@ -231,7 +228,7 @@ public final class Attachments {

/**
* A service target that can be used to install services outside the scope of the deployment.
*
* <p/>
* These services will not be removed automatically on undeploy, so if this is used some other strategy must be used
* to handle undeployment.
*/
Expand Down Expand Up @@ -296,7 +293,7 @@ public final class Attachments {

/**
* Sub deployments that are visible from this deployments module loader, in the order they are accessible.
*
* <p/>
* This list includes the current deployment, which under normal circumstances will be the first item in the list
*/
public static final AttachmentKey<AttachmentList<DeploymentUnit>> ACCESSIBLE_SUB_DEPLOYMENTS = AttachmentKey.createList(DeploymentUnit.class);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ public enum Phase {
* <p>
* In this phase, these phase attachments may be modified:
* <ul>
* <li>{@link Attachments#CLASS_PATH_ENTRIES} - class path entries found in the manifest and elsewhere.</li>
* <li>{@link Attachments#CLASS_PATH_MODULES} - class path entries found in the manifest and elsewhere.</li>
* <li>{@link Attachments#EXTENSION_LIST_ENTRIES} - extension-list entries found in the manifest and elsewhere.</li>
* </ul>
* <p>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ public synchronized void deploy(final DeploymentPhaseContext phaseContext) throw
if (item.startsWith("/")) {
if (externalModuleService.isValidFile(item)) {
final ModuleIdentifier moduleIdentifier = externalModuleService.addExternalModule(item, phaseContext.getServiceRegistry(), externalServiceTarget);
target.addToAttachmentList(Attachments.CLASS_PATH_ENTRIES, moduleIdentifier);
target.addToAttachmentList(Attachments.CLASS_PATH_MODULES, moduleIdentifier.toString());
ServerLogger.DEPLOYMENT_LOGGER.debugf("Resource %s added as external jar %s", classPathFile, resourceRoot.getRoot());
} else {
ServerLogger.DEPLOYMENT_LOGGER.classPathEntryNotValid(item, resourceRoot.getRoot().getPathName());
Expand Down Expand Up @@ -196,16 +196,16 @@ private void handlingExistingClassPathEntry(final ArrayDeque<RootEntry> resource
} else if (additionalModules.containsKey(classPathFile)) {
final AdditionalModuleSpecification moduleSpecification = additionalModules.get(classPathFile);
//as class path entries are exported, transitive dependencies will also be available
target.addToAttachmentList(Attachments.CLASS_PATH_ENTRIES, moduleSpecification.getModuleIdentifier());
target.addToAttachmentList(Attachments.CLASS_PATH_MODULES, moduleSpecification.getModuleName());
} else if (subDeployments.containsKey(classPathFile)) {
//now we need to calculate the sub deployment module identifier
//unfortunately the sub deployment has not been setup yet, so we cannot just
//get it from the sub deployment directly
final ResourceRoot otherRoot = subDeployments.get(classPathFile);
target.addToAttachmentList(Attachments.CLASS_PATH_ENTRIES, ModuleIdentifierProcessor.createModuleIdentifier(otherRoot.getRootName(), otherRoot, topLevelDeployment, topLevelRoot, false));
target.addToAttachmentList(Attachments.CLASS_PATH_MODULES, ModuleIdentifierProcessor.createModuleIdentifier(otherRoot.getRootName(), otherRoot, topLevelDeployment, topLevelRoot, false).toString());
} else {
ModuleIdentifier identifier = createAdditionalModule(resourceRoot, topLevelDeployment, topLevelRoot, additionalModules, classPathFile, resourceRoots);
target.addToAttachmentList(Attachments.CLASS_PATH_ENTRIES, identifier);
target.addToAttachmentList(Attachments.CLASS_PATH_MODULES, identifier.toString());
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
import org.jboss.as.server.deployment.DeploymentUnit;
import org.jboss.as.server.deployment.DeploymentUnitProcessingException;
import org.jboss.as.server.deployment.DeploymentUnitProcessor;
import org.jboss.modules.ModuleIdentifier;
import org.jboss.modules.ModuleLoader;

/**
Expand All @@ -29,9 +28,9 @@ public void deploy(final DeploymentPhaseContext phaseContext) throws DeploymentU
final ModuleSpecification moduleSpecification = deploymentUnit.getAttachment(Attachments.MODULE_SPECIFICATION);

final ModuleLoader moduleLoader = deploymentUnit.getAttachment(Attachments.SERVICE_MODULE_LOADER);
final AttachmentList<ModuleIdentifier> entries = deploymentUnit.getAttachment(Attachments.CLASS_PATH_ENTRIES);
final AttachmentList<String> entries = deploymentUnit.getAttachment(Attachments.CLASS_PATH_MODULES);
if (entries != null) {
for (ModuleIdentifier entry : entries) {
for (String entry : entries) {
//class path items are always exported to make transitive dependencies work
moduleSpecification.addLocalDependency(new ModuleDependency(moduleLoader, entry, false, true, true, false));
}
Expand All @@ -40,14 +39,14 @@ public void deploy(final DeploymentPhaseContext phaseContext) throws DeploymentU
final List<AdditionalModuleSpecification> additionalModules = deploymentUnit.getAttachment(Attachments.ADDITIONAL_MODULES);
if (additionalModules != null) {
for (AdditionalModuleSpecification additionalModule : additionalModules) {
final AttachmentList<ModuleIdentifier> dependencies = additionalModule.getAttachment(Attachments.CLASS_PATH_ENTRIES);
final AttachmentList<String> dependencies = additionalModule.getAttachment(Attachments.CLASS_PATH_MODULES);
if (dependencies == null || dependencies.isEmpty()) {
continue;
}
// additional modules export any class-path entries
// this means that a module that references the additional module
// gets access to the transitive closure of its call-path entries
for (ModuleIdentifier entry : dependencies) {
for (String entry : dependencies) {
additionalModule.addLocalDependency(new ModuleDependency(moduleLoader, entry, false, true, true, false));
}
// add a dependency on the top ear itself for good measure
Expand Down

0 comments on commit 8a0a619

Please sign in to comment.