Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[WFCORE-7111] Prepare org.jboss.as.server.deployment.Attachments for … #6298

Merged
merged 1 commit into from
Dec 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading