Skip to content

Commit

Permalink
[WFCORE-7111] Prepare org.jboss.as.server.deployment.Attachments for …
Browse files Browse the repository at this point in the history
…removal of ModuleIdentifier
  • Loading branch information
bstansberry committed Dec 21, 2024
1 parent 604e53e commit 572a4d4
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -121,8 +121,13 @@ public final class Attachments {
public static final AttachmentKey<Manifest> MANIFEST = AttachmentKey.create(Manifest.class);

/**
* Module identifiers for Class-Path information
* Module identifiers for Class-Path information.
* <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);

/**
Expand Down Expand Up @@ -191,10 +196,27 @@ public final class Attachments {
*/
public static final AttachmentKey<AttachmentList<AdditionalModuleSpecification>> ADDITIONAL_MODULES = AttachmentKey.createList(AdditionalModuleSpecification.class);

/**
* A list of modules for which annotation indexes should be prepared (or, in later phases, have been prepared).
*
* @deprecated this will either be changed incompatibly (to provide a list of string) or removed altogether in the next WildFly Core major.
*/
@Deprecated(forRemoval = true)
public static final AttachmentKey<AttachmentList<ModuleIdentifier>> ADDITIONAL_ANNOTATION_INDEXES = AttachmentKey.createList(ModuleIdentifier.class);

/**
* Annotation indices, keyed by the identifier of the module from which they were obtained.
*
* @deprecated use {@link #ADDITIONAL_ANNOTATION_INDEXES_BY_MODULE_NAME}
*/
@Deprecated(forRemoval = true)
public static final AttachmentKey<Map<ModuleIdentifier, CompositeIndex>> ADDITIONAL_ANNOTATION_INDEXES_BY_MODULE = AttachmentKey.create(Map.class);

/**
* Annotation indices, keyed by the canonical name module from which they were obtained.
*/
public static final AttachmentKey<Map<String, CompositeIndex>> ADDITIONAL_ANNOTATION_INDEXES_BY_MODULE_NAME = AttachmentKey.create(Map.class);

public static final AttachmentKey<Map<String, MountedDeploymentOverlay>> DEPLOYMENT_OVERLAY_LOCATIONS = AttachmentKey.create(Map.class);

/**
Expand Down Expand Up @@ -237,9 +259,17 @@ public final class Attachments {
//
/**
* The module identifier.
*
* @deprecated use {@link #MODULE_NAME}
*/
@Deprecated(forRemoval = true)
public static final AttachmentKey<ModuleIdentifier> MODULE_IDENTIFIER = AttachmentKey.create(ModuleIdentifier.class);

/**
* The canonical name of the module.
*/
public static final AttachmentKey<String> MODULE_NAME = AttachmentKey.create(String.class);

//
// MODULARIZE
//
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
Expand Down Expand Up @@ -118,6 +119,14 @@ public void deploy(DeploymentPhaseContext phaseContext) throws DeploymentUnitPro
}
}
deploymentUnit.putAttachment(Attachments.ADDITIONAL_ANNOTATION_INDEXES_BY_MODULE, additionalAnnotationIndexes);
// Attach an additional map keyed by name. Next release this key will be the only map attached.
Map<String, CompositeIndex> additionalIndexesByName = new HashMap<>(additionalAnnotationIndexes.size());
for (Map.Entry<ModuleIdentifier, CompositeIndex> entry : additionalAnnotationIndexes.entrySet()) {
additionalIndexesByName.put(entry.getKey().toString(), entry.getValue());
}
deploymentUnit.putAttachment(Attachments.ADDITIONAL_ANNOTATION_INDEXES_BY_MODULE_NAME,
// This should have always been an immutable map
Collections.unmodifiableMap(additionalIndexesByName));

final List<ResourceRoot> allResourceRoots = new ArrayList<ResourceRoot>();
final List<ResourceRoot> resourceRoots = deploymentUnit.getAttachmentList(Attachments.RESOURCE_ROOTS);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ public void deploy(DeploymentPhaseContext phaseContext) throws DeploymentUnitPro
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);
deploymentUnit.putAttachment(Attachments.MODULE_NAME, moduleIdentifier.toString());
}

public static ModuleIdentifier createModuleIdentifier(final String deploymentUnitName, final ResourceRoot deploymentRoot, final DeploymentUnit topLevelDeployment, final VirtualFile toplevelRoot, final boolean topLevel) {
Expand Down

0 comments on commit 572a4d4

Please sign in to comment.