Skip to content

Commit

Permalink
[WFCORE-7118] Provide an alternative to Attachments.ADDITIONAL_ANNOTA…
Browse files Browse the repository at this point in the history
…TION_INDEXES
  • Loading branch information
bstansberry committed Dec 23, 2024
1 parent bbd1404 commit 10f0947
Show file tree
Hide file tree
Showing 9 changed files with 26 additions and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -199,11 +199,17 @@ public final class Attachments {
/**
* 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 use {@link #ADDITIONAL_INDEX_MODULES}
*/
@Deprecated(forRemoval = true)
public static final AttachmentKey<AttachmentList<ModuleIdentifier>> ADDITIONAL_ANNOTATION_INDEXES = AttachmentKey.createList(ModuleIdentifier.class);

/**
* A list of modules for which annotation indexes should be prepared (or, in later phases, have been prepared).
*
*/
public static final AttachmentKey<AttachmentList<String>> ADDITIONAL_INDEX_MODULES = AttachmentKey.createList(String.class);

/**
* Annotation indices, keyed by the identifier of the module from which they were obtained.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,13 +58,16 @@ public void deploy(DeploymentPhaseContext phaseContext) throws DeploymentUnitPro
additionalModuleSpecificationMap.put(i.getModuleName(), i);
}
Map<String, CompositeIndex> additionalAnnotationIndexes = new HashMap<>();
final List<ModuleIdentifier> additionalModuleIndexes = deploymentUnit.getAttachmentList(Attachments.ADDITIONAL_ANNOTATION_INDEXES);
final List<Index> indexes = new ArrayList<Index>();
final List<String> additionalModuleIndexes = deploymentUnit.getAttachmentList(Attachments.ADDITIONAL_INDEX_MODULES);
// Until we remove ADDITIONAL_ANNOTATION_INDEXES, pick up any index modules added by the full WF ee subsystem
for (ModuleIdentifier mi: deploymentUnit.getAttachmentList(Attachments.ADDITIONAL_ANNOTATION_INDEXES)) {
additionalModuleIndexes.add(mi.toString());
}
final List<Index> indexes = new ArrayList<>();

Map<String, DeploymentUnit> subdeploymentDependencies = buildSubdeploymentDependencyMap(deploymentUnit);

for (final ModuleIdentifier moduleIdentifier : additionalModuleIndexes) {
String moduleName = moduleIdentifier.toString();
for (final String moduleName : additionalModuleIndexes) {
AdditionalModuleSpecification additional = additionalModuleSpecificationMap.get(moduleName);
if(additional != null) {
// This module id refers to a deployment-specific module created based on a MANIFEST.MF Class-Path entry
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
import org.jboss.as.server.deployment.SubDeploymentMarker;
import org.jboss.as.server.moduleservice.ServiceModuleLoader;
import org.jboss.modules.Module;
import org.jboss.modules.ModuleIdentifier;
import org.jboss.modules.ModuleLoader;
import org.jboss.modules.filter.PathFilters;

Expand Down Expand Up @@ -98,7 +97,7 @@ public void deploy(final DeploymentPhaseContext phaseContext) throws DeploymentU
dependencyLoader = Module.getBootModuleLoader();
}
if(annotations) {
deploymentUnit.addToAttachmentList(Attachments.ADDITIONAL_ANNOTATION_INDEXES, ModuleIdentifier.fromString(dependencyId));
deploymentUnit.addToAttachmentList(Attachments.ADDITIONAL_INDEX_MODULES, 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));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ public void deploy(final DeploymentPhaseContext phaseContext) throws DeploymentU
// handle additional modules
Map<String, AdditionalModuleSpecification> additionalModules = new HashMap<>();
for (final ModuleStructureSpec additionalModule : result.getAdditionalModules()) {
for (final ModuleIdentifier identifier : additionalModule.getAnnotationModules()) {
for (final String identifier : additionalModule.getAnnotationModules()) {
//additional modules don't support annotation imports
ServerLogger.DEPLOYMENT_LOGGER.annotationImportIgnored(identifier, additionalModule.getModuleName());
}
Expand Down Expand Up @@ -284,17 +284,15 @@ private void handleDeployment(final DeploymentPhaseContext phaseContext, final D
moduleSpec.addClassTransformer(classTransformer);
}
// handle annotations
for (final ModuleIdentifier dependency : rootDeploymentSpecification.getAnnotationModules()) {
String identifier = dependency.toString();
boolean aliased = false;
for (final String dependency : rootDeploymentSpecification.getAnnotationModules()) {
String identifier = dependency;
for (AdditionalModuleSpecification module : additionalModules.values()) {
if (module.getModuleAliases().contains(identifier)) {
identifier = module.getModuleName();
aliased = true;
break;
}
}
deploymentUnit.addToAttachmentList(Attachments.ADDITIONAL_ANNOTATION_INDEXES, aliased ? ModuleIdentifier.fromString(identifier) : dependency);
deploymentUnit.addToAttachmentList(Attachments.ADDITIONAL_INDEX_MODULES, identifier);
// additional modules will not be created till much later, a dep on them would fail
if (identifier.startsWith(ServiceModuleLoader.MODULE_PREFIX) &&
!(additionalModules.containsKey(identifier) || isSubdeployment(identifier, deploymentUnit))) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -598,7 +598,7 @@ private static void parseModuleDependency(final XMLStreamReader reader, final Mo
if (!required.isEmpty()) {
throw missingAttributes(reader.getLocation(), required);
}
final ModuleIdentifier identifier = ModuleIdentifier.create(name, slot);
final String identifier = ModuleIdentifierUtil.canonicalModuleIdentifier(name, slot);
final ModuleDependency dependency = new ModuleDependency(moduleLoader, identifier, optional, export,
services == Disposition.IMPORT, true);
if(annotations) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -605,7 +605,7 @@ private static void parseModuleDependency(final XMLStreamReader reader, final Mo
if (!required.isEmpty()) {
throw missingAttributes(reader.getLocation(), required);
}
final ModuleIdentifier identifier = ModuleIdentifier.create(name, slot);
final String identifier = ModuleIdentifierUtil.canonicalModuleIdentifier(name, slot);
final ModuleDependency dependency = new ModuleDependency(moduleLoader, identifier, optional, export,
services == Disposition.IMPORT, true);
if(annotations) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -615,7 +615,7 @@ private static void parseModuleDependency(final XMLStreamReader reader, final Mo
if (!required.isEmpty()) {
throw missingAttributes(reader.getLocation(), required);
}
final ModuleIdentifier identifier = ModuleIdentifier.create(name, slot);
final String identifier = ModuleIdentifierUtil.canonicalModuleIdentifier(name, slot);
final ModuleDependency dependency = new ModuleDependency(moduleLoader, identifier, optional, export,
services == Disposition.IMPORT, true);
if(annotations) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ class ModuleStructureSpec {
private final List<ModuleIdentifier> exclusions = new ArrayList<ModuleIdentifier>();
private final List<String> classTransformers = new ArrayList<String>();
private final List<ModuleIdentifier> aliases = new ArrayList<ModuleIdentifier>();
private final List<ModuleIdentifier> annotationModules = new ArrayList<ModuleIdentifier>();
private final List<String> annotationModules = new ArrayList<>();

/**
* Note that this being null is different to an empty list.
Expand Down Expand Up @@ -83,11 +83,11 @@ public List<ModuleIdentifier> getAliases() {
return Collections.unmodifiableList(aliases);
}

public void addAnnotationModule(final ModuleIdentifier dependency) {
public void addAnnotationModule(final String dependency) {
annotationModules.add(dependency);
}

public List<ModuleIdentifier> getAnnotationModules() {
public List<String> getAnnotationModules() {
return Collections.unmodifiableList(annotationModules);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@ public interface ServerLogger extends BasicLogger {

@LogMessage(level = WARN)
@Message(id = 17, value = "Annotations import option %s specified in jboss-deployment-structure.xml for additional module %s has been ignored. Additional modules cannot import annotations.")
void annotationImportIgnored(ModuleIdentifier annotationModuleId, String additionalModuleId);
void annotationImportIgnored(String annotationModuleId, String additionalModuleId);

@LogMessage(level = WARN)
@Message(id = 18, value = "Deployment \"%s\" is using a private module (\"%s\") which may be changed or removed in future versions without notice.")
Expand Down

0 comments on commit 10f0947

Please sign in to comment.