Skip to content

Commit

Permalink
[WFCORE-7105] Use ModuleDependency.Builder instead of deprecated Modu…
Browse files Browse the repository at this point in the history
…leDependency ctor in Server
  • Loading branch information
ropalka committed Dec 18, 2024
1 parent ebf13df commit d838292
Show file tree
Hide file tree
Showing 15 changed files with 28 additions and 26 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ public void deploy(final DeploymentPhaseContext phaseContext) throws DeploymentU
for (ResourceRoot root : resourceRoots) {
VirtualFile child = root.getRoot().getChild(SERVICE_FILE_NAME);
if (child.exists()) {
moduleSpecification.addSystemDependency(new ModuleDependency(moduleLoader, JTA, false, false, false, false));
moduleSpecification.addSystemDependency(ModuleDependency.Builder.of(moduleLoader, JTA).build());
break;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ public void deploy(final DeploymentPhaseContext phaseContext) throws DeploymentU
}
}

final ModuleDependency dependency = new ModuleDependency(dependencyLoader, dependencyId, optional, export, services, true);
final ModuleDependency dependency = ModuleDependency.Builder.of(dependencyLoader, dependencyId.toString()).setOptional(optional).setExport(export).setImportServices(services).build();
if(metaInf) {
dependency.addImportFilter(PathFilters.getMetaInfSubdirectoriesFilter(), true);
dependency.addImportFilter(PathFilters.getMetaInfFilter(), true);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ public void deploy(final DeploymentPhaseContext phaseContext) throws DeploymentU
if (entries != null) {
for (ModuleIdentifier entry : entries) {
//class path items are always exported to make transitive dependencies work
moduleSpecification.addLocalDependency(new ModuleDependency(moduleLoader, entry, false, true, true, false));
moduleSpecification.addLocalDependency(ModuleDependency.Builder.of(moduleLoader, entry.toString()).setExport(true).setImportServices(true).build());
}
}

Expand All @@ -48,10 +48,10 @@ public void deploy(final DeploymentPhaseContext phaseContext) throws DeploymentU
// 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) {
additionalModule.addLocalDependency(new ModuleDependency(moduleLoader, entry, false, true, true, false));
additionalModule.addLocalDependency(ModuleDependency.Builder.of(moduleLoader, entry.toString()).setExport(true).setImportServices(true).build());
}
// add a dependency on the top ear itself for good measure
additionalModule.addLocalDependency(new ModuleDependency(moduleLoader, deploymentUnit.getAttachment(Attachments.MODULE_IDENTIFIER), false, false, true, false));
additionalModule.addLocalDependency(ModuleDependency.Builder.of(moduleLoader, deploymentUnit.getAttachment(Attachments.MODULE_IDENTIFIER).toString()).setImportServices(true).build());
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ public void deploy(final DeploymentPhaseContext phaseContext) throws DeploymentU
}

for (ModuleIdentifier extension : allExtensionListEntries) {
ModuleDependency dependency = new ModuleDependency(moduleLoader, extension, false, false, true, true);
ModuleDependency dependency = ModuleDependency.Builder.of(moduleLoader, extension.toString()).setImportServices(true).setUserSpecified(true).build();
dependency.addImportFilter(PathFilters.getMetaInfSubdirectoriesFilter(), true);
dependency.addImportFilter(PathFilters.getMetaInfFilter(), true);
moduleSpecification.addLocalDependency(dependency);
Expand All @@ -105,8 +105,7 @@ public void deploy(final DeploymentPhaseContext phaseContext) throws DeploymentU
.getSpecificationVersion(), entry.getImplementationVersion(), entry
.getImplementationVendorId());
if (extension != null) {
moduleSpecification.addLocalDependency(new ModuleDependency(moduleLoader, extension, false, false,
true, false));
moduleSpecification.addLocalDependency(ModuleDependency.Builder.of(moduleLoader, extension.toString()).setImportServices(true).build());
nextPhaseDeps.add(ServiceModuleLoader.moduleSpecServiceName(extension.toString()));
} else {
ServerLogger.DEPLOYMENT_LOGGER.cannotFindExtensionListEntry(entry, resourceRoot);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -288,7 +288,7 @@ private void installAliases(final ModuleSpecification moduleSpecification, final

HashSet<ModuleDependency> dependencies = new HashSet<>(moduleSpecification.getAllDependencies());
//we need to add the module we are aliasing as a dependency, to make sure that it will be resolved
dependencies.add(new ModuleDependency(moduleLoader, moduleIdentifier, false, false, false, false));
dependencies.add(ModuleDependency.Builder.of(moduleLoader, moduleIdentifier.toString()).build());
ModuleDefinition moduleDefinition = new ModuleDefinition(alias, dependencies, spec);

final ServiceBuilder sb = phaseContext.getServiceTarget().addService(moduleSpecServiceName);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ public void deploy(final DeploymentPhaseContext phaseContext) throws DeploymentU
for (String moduleName : DEFAULT_MODULES) {
try {
moduleLoader.loadModule(moduleName);
moduleSpecification.addSystemDependency(new ModuleDependency(moduleLoader, moduleName, false, false, false, false));
moduleSpecification.addSystemDependency(ModuleDependency.Builder.of(moduleLoader, moduleName).build());
} catch (ModuleLoadException ex) {
ServerLogger.ROOT_LOGGER.debugf("Module not found: %s", moduleName);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,15 +39,15 @@ public void deploy(DeploymentPhaseContext phaseContext) throws DeploymentUnitPro
final ModuleIdentifier parentModule = parent.getAttachment(Attachments.MODULE_IDENTIFIER);
if (parentModule != null) {
// access to ear classes
ModuleDependency moduleDependency = new ModuleDependency(moduleLoader, parentModule, false, false, true, false);
ModuleDependency moduleDependency = ModuleDependency.Builder.of(moduleLoader, parentModule.toString()).setImportServices(true).build();
moduleDependency.addImportFilter(PathFilters.acceptAll(), true);
moduleSpec.addLocalDependency(moduleDependency);
}
}

// make the deployment content available to any additional modules
for (AdditionalModuleSpecification module : deploymentUnit.getAttachmentList(Attachments.ADDITIONAL_MODULES)) {
module.addLocalDependency(new ModuleDependency(moduleLoader, moduleIdentifier, false, false, true, false));
module.addLocalDependency(ModuleDependency.Builder.of(moduleLoader, moduleIdentifier.toString()).setImportServices(true).build());
}

final List<DeploymentUnit> subDeployments = parent.getAttachmentList(Attachments.SUB_DEPLOYMENTS);
Expand All @@ -56,7 +56,7 @@ public void deploy(DeploymentPhaseContext phaseContext) throws DeploymentUnitPro
final ModuleSpecification subModule = subDeployment.getAttachment(Attachments.MODULE_SPECIFICATION);
if (!subModule.isPrivateModule() && (!parentModuleSpec.isSubDeploymentModulesIsolated() || subModule.isPublicModule())) {
ModuleIdentifier identifier = subDeployment.getAttachment(Attachments.MODULE_IDENTIFIER);
ModuleDependency dependency = new ModuleDependency(moduleLoader, identifier, false, false, true, false);
ModuleDependency dependency = ModuleDependency.Builder.of(moduleLoader, identifier.toString()).setImportServices(true).build();
dependency.addImportFilter(PathFilters.acceptAll(), true);
accessibleModules.add(dependency);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -243,10 +243,13 @@ private void handleDeployment(final DeploymentPhaseContext phaseContext, final D
}
}
// No more nested loop
ModuleDependency moduleDependency;
for (ModuleDependency dependency : moduleDependencies) {
String identifier = dependency.getIdentifier().toString();
if (index.containsKey(identifier)) {
aliasDependencies.add(new ModuleDependency(dependency.getModuleLoader(), index.get(identifier).getModuleIdentifier(), dependency.isOptional(), dependency.isExport(), dependency.isImportServices(), dependency.isUserSpecified()));
moduleDependency = ModuleDependency.Builder.of(dependency.getModuleLoader(), index.get(identifier).getModuleIdentifier().toString())
.setOptional(dependency.isOptional()).setExport(dependency.isExport()).setImportServices(dependency.isImportServices()).setUserSpecified(dependency.isUserSpecified()).build();
aliasDependencies.add(moduleDependency);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -390,8 +390,9 @@ private static void parseModuleDependency(final XMLStreamReader reader, final Mo
if (!required.isEmpty()) {
throw missingAttributes(reader.getLocation(), required);
}
ModuleDependency dependency = new ModuleDependency(moduleLoader, ModuleIdentifier.create(name, slot), optional, export,
services == Disposition.IMPORT, true);
final ModuleIdentifier identifier = ModuleIdentifier.create(name, slot);
ModuleDependency dependency = ModuleDependency.Builder.of(moduleLoader, identifier.toString())
.setOptional(optional).setExport(export).setImportServices(services == Disposition.IMPORT).setUserSpecified(true).build();
specBuilder.addModuleDependency(dependency);
while (reader.hasNext()) {
switch (reader.nextTag()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -598,8 +598,8 @@ private static void parseModuleDependency(final XMLStreamReader reader, final Mo
throw missingAttributes(reader.getLocation(), required);
}
final ModuleIdentifier identifier = ModuleIdentifier.create(name, slot);
final ModuleDependency dependency = new ModuleDependency(moduleLoader, identifier, optional, export,
services == Disposition.IMPORT, true);
ModuleDependency dependency = ModuleDependency.Builder.of(moduleLoader, identifier.toString())
.setOptional(optional).setExport(export).setImportServices(services == Disposition.IMPORT).setUserSpecified(true).build();
if(annotations) {
specBuilder.addAnnotationModule(identifier);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -605,8 +605,8 @@ private static void parseModuleDependency(final XMLStreamReader reader, final Mo
throw missingAttributes(reader.getLocation(), required);
}
final ModuleIdentifier identifier = ModuleIdentifier.create(name, slot);
final ModuleDependency dependency = new ModuleDependency(moduleLoader, identifier, optional, export,
services == Disposition.IMPORT, true);
ModuleDependency dependency = ModuleDependency.Builder.of(moduleLoader, identifier.toString())
.setOptional(optional).setExport(export).setImportServices(services == Disposition.IMPORT).setUserSpecified(true).build();
if(annotations) {
specBuilder.addAnnotationModule(identifier);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -615,8 +615,8 @@ private static void parseModuleDependency(final XMLStreamReader reader, final Mo
throw missingAttributes(reader.getLocation(), required);
}
final ModuleIdentifier identifier = ModuleIdentifier.create(name, slot);
final ModuleDependency dependency = new ModuleDependency(moduleLoader, identifier, optional, export,
services == Disposition.IMPORT, true);
ModuleDependency dependency = ModuleDependency.Builder.of(moduleLoader, identifier.toString())
.setOptional(optional).setExport(export).setImportServices(services == Disposition.IMPORT).setUserSpecified(true).build();
if(annotations) {
specBuilder.addAnnotationModule(identifier);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
import org.jboss.as.server.deployment.module.ModuleSpecification;
import org.jboss.as.server.deployment.module.ResourceRoot;
import org.jboss.modules.Module;
import org.jboss.modules.ModuleIdentifier;
import org.jboss.msc.service.ServiceActivator;

/**
Expand All @@ -24,7 +23,7 @@
*/
public class ServiceActivatorDependencyProcessor implements DeploymentUnitProcessor {

private static final ModuleDependency MSC_DEP = new ModuleDependency(Module.getBootModuleLoader(), ModuleIdentifier.create("org.jboss.msc"), false, false, false, false);
private static final ModuleDependency MSC_DEP = ModuleDependency.Builder.of(Module.getBootModuleLoader(), "org.jboss.msc").build();

/**
* Add the dependencies if the deployment contains a service activator loader entry.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ public static ServiceName install(final ServiceTarget target, final ModuleIdenti
public static ServiceName installAliases(final ServiceTarget target, final ModuleIdentifier identifier, final List<ModuleIdentifier> aliases) {
final ArrayList<ModuleDependency> dependencies = new ArrayList<ModuleDependency>(aliases.size());
for (final ModuleIdentifier i : aliases) {
dependencies.add(new ModuleDependency(null, i, false, false, false, false));
dependencies.add(ModuleDependency.Builder.of(null, i.toString()).build());
}
final ModuleLoadService service = new ModuleLoadService(dependencies);
return install(target, identifier, service);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ private static ModuleDependency createModuleDependency(String identifier) {
return createModuleDependency(identifier, (String) null);
}
private static ModuleDependency createModuleDependency(String identifier, String reason) {
return new ModuleDependency(TEST_LOADER, identifier, false, false, true, false, reason);
return ModuleDependency.Builder.of(TEST_LOADER, identifier).setImportServices(true).setReason(reason).build();
}
private static ModuleDependency createModuleDependency(String identifier, PathFilter importFilter) {
ModuleDependency dependency = createModuleDependency(identifier, (String) null);
Expand Down

0 comments on commit d838292

Please sign in to comment.