Skip to content

Commit 0bf79b1

Browse files
authored
Merge pull request #6412 from yersan/WFCORE-7242
[WFCORE-7242] Undeprecate ModuleIdentifierUtil from org.jboss.as.cont…
2 parents 2aa1f55 + 481cbde commit 0bf79b1

File tree

8 files changed

+41
-51
lines changed

8 files changed

+41
-51
lines changed

controller/src/main/java/org/jboss/as/controller/ModuleIdentifierUtil.java

Lines changed: 30 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,7 @@
1212

1313
/**
1414
* Provides utilities related to working with names of JBoss Modules modules.
15-
*
16-
* @deprecated use {@link JBossModulesNameUtil} instead
1715
*/
18-
@Deprecated(forRemoval = true, since = "28.0.0")
1916
public final class ModuleIdentifierUtil {
2017

2118
/**
@@ -26,30 +23,39 @@ public final class ModuleIdentifierUtil {
2623
* @param moduleSpec a module name specification in the form {@code name[:slot]}. Cannot be {@code null}
2724
* @return the canonical representation. Will not return @{code null}
2825
*
29-
* @deprecated use {@link JBossModulesNameUtil#parseCanonicalModuleIdentifier(String)}
26+
* @deprecated use {@link #parseCanonicalModuleIdentifier(String)}
3027
*/
3128
@Deprecated(forRemoval = true, since = "28.0.0")
3229
public static String canonicalModuleIdentifier(String moduleSpec) {
3330
return JBossModulesNameUtil.parseCanonicalModuleIdentifier(moduleSpec);
3431
}
3532

33+
/**
34+
* Provides the canonical string representation of a module identifier from a string
35+
* of the form {@code name[:slot]}. The canonical representation will not include
36+
* slot information if the slot is {@code main}.
37+
*
38+
* @param moduleSpec a module name specification in the form {@code name[:slot]}. Cannot be {@code null}
39+
* @return the canonical representation. Will not return @{code null}
40+
*/
41+
public static String parseCanonicalModuleIdentifier(String moduleSpec) {
42+
return JBossModulesNameUtil.parseCanonicalModuleIdentifier(moduleSpec);
43+
}
44+
3645
/**
3746
* Parses the given module identifier into name and optional slot elements, passing those to the given
3847
* function and returning the result of that function.
3948
* <p/>
40-
* This variant does not {@link #canonicalModuleIdentifier(String) canonicalize} the given identifier.
49+
* This variant does not {@link #parseCanonicalModuleIdentifier(String) canonicalize} the given identifier.
4150
*
4251
* @param moduleIdentifier an identifier for a module. Cannot be {@code null}
43-
* @param function a function to apply to the module's name and optional slot. Cannot be {@code null}.
44-
* The slot value passed to the function may be null if the identifier does not contain one.
52+
* @param function a function to apply to the module's name and optional slot. Cannot be {@code null}.
53+
* The slot value passed to the function may be null if the identifier does not contain one.
54+
* @param <R> the type returned by {@code function}
4555
* @return the value returned by {@code function}
46-
* @param <R> the type returned by {@code function}
47-
*
48-
* @deprecated use {@link JBossModulesNameUtil#parseModuleIdentifier(String, BiFunction)}
4956
*/
50-
@Deprecated(forRemoval = true, since = "28.0.0")
5157
public static <R> R parseModuleIdentifier(String moduleIdentifier, BiFunction<String, String, R> function) {
52-
return JBossModulesNameUtil.parseModuleIdentifier(moduleIdentifier, function);
58+
return JBossModulesNameUtil.parseModuleIdentifier(moduleIdentifier, function, false, null);
5359
}
5460

5561

@@ -59,36 +65,29 @@ public static <R> R parseModuleIdentifier(String moduleIdentifier, BiFunction<St
5965
* <p/>
6066
*
6167
* @param moduleIdentifier an identifier for a module. Cannot be {@code null}
62-
* @param function a function to apply to the module's name and optional slot. Cannot be {@code null}.
63-
* The slot value passed to the function may be null if the identifier does not contain one.
64-
* @param canonicalize if {@code true} the identifier will be {@link #canonicalModuleIdentifier(String) canonicalized} before parsing
68+
* @param function a function to apply to the module's name and optional slot. Cannot be {@code null}.
69+
* The slot value passed to the function may be null if the identifier does not contain one.
70+
* @param canonicalize if {@code true} the identifier will be {@link #parseCanonicalModuleIdentifier(String) canonicalized} before parsing
71+
* @param <R> the type returned by {@code function}
6572
* @return the value returned by {@code function}
66-
* @param <R> the type returned by {@code function}
67-
*
68-
* @deprecated use {@link JBossModulesNameUtil#parseModuleIdentifier(String, BiFunction, boolean)}
6973
*/
70-
@Deprecated(forRemoval = true, since = "28.0.0")
7174
public static <R> R parseModuleIdentifier(String moduleIdentifier, BiFunction<String, String, R> function, boolean canonicalize) {
72-
return JBossModulesNameUtil.parseModuleIdentifier(moduleIdentifier, function, canonicalize);
75+
return JBossModulesNameUtil.parseModuleIdentifier(moduleIdentifier, function, canonicalize, null);
7376
}
7477

75-
7678
/**
7779
* Parses the given module identifier into name and optional slot elements, passing those to the given
7880
* function and returning the result of that function.
7981
* <p/>
8082
*
8183
* @param moduleIdentifier an identifier for a module. Cannot be {@code null}
82-
* @param function a function to apply to the module's name and optional slot. Cannot be {@code null}.
83-
* The slot value passed to the function may be null if the identifier does not contain one.
84-
* @param canonicalize if {@code true} the identifier will be {@link #canonicalModuleIdentifier(String) canonicalized} before parsing
85-
* @param defaultSlot string to pass to {@code function} as the slot parameter if the identifier doesn't include a slot value. May be {@code null}
84+
* @param function a function to apply to the module's name and optional slot. Cannot be {@code null}.
85+
* The slot value passed to the function may be null if the identifier does not contain one.
86+
* @param canonicalize if {@code true} the identifier will be {@link #parseCanonicalModuleIdentifier(String) canonicalized} before parsing
87+
* @param defaultSlot string to pass to {@code function} as the slot parameter if the identifier doesn't include a slot value. May be {@code null}
88+
* @param <R> the type returned by {@code function}
8689
* @return the value returned by {@code function}
87-
* @param <R> the type returned by {@code function}
88-
*
89-
* @deprecated use {@link JBossModulesNameUtil#parseModuleIdentifier(String, BiFunction, boolean, String)}
9090
*/
91-
@Deprecated(forRemoval = true, since = "28.0.0")
9291
public static <R> R parseModuleIdentifier(String moduleIdentifier, BiFunction<String, String, R> function,
9392
boolean canonicalize, String defaultSlot) {
9493
return JBossModulesNameUtil.parseModuleIdentifier(moduleIdentifier, function, canonicalize, defaultSlot);
@@ -101,29 +100,22 @@ public static <R> R parseModuleIdentifier(String moduleIdentifier, BiFunction<St
101100
*
102101
* @param name the base module name. Cannot be {@code null}
103102
* @param slot the module slot. May be @{code null}
104-
*
105103
* @return the canonical representation. Will not return @{code null}
106-
*
107-
* @deprecated use {@link JBossModulesNameUtil#canonicalModuleIdentifier(String, String)}
108104
*/
109-
@Deprecated(forRemoval = true, since = "28.0.0")
110105
public static String canonicalModuleIdentifier(String name, String slot) {
111106
return JBossModulesNameUtil.canonicalModuleIdentifier(name, slot);
112107
}
113108

114109
/**
115-
* A {@link ParameterCorrector} that {@link #canonicalModuleIdentifier(String) canonicalizes}
110+
* A {@link ParameterCorrector} that {@link #parseCanonicalModuleIdentifier(String) canonicalizes}
116111
* values that are meant to represent JBoss Modules module names.
117-
*
118-
* @deprecated use {@link JBossModulesNameUtil#parseCanonicalModuleIdentifier} after resolving your attribute value in your step handler.
119112
*/
120-
@Deprecated(forRemoval = true, since = "28.0.0")
121113
public static final ParameterCorrector MODULE_NAME_CORRECTOR = new ParameterCorrector() {
122114
@Override
123115
public ModelNode correct(ModelNode newValue, ModelNode currentValue) {
124116
if (ModelType.STRING.equals(newValue.getType())) {
125117
String orig = newValue.asString();
126-
String corrected = canonicalModuleIdentifier(orig);
118+
String corrected = parseCanonicalModuleIdentifier(orig);
127119
if (!orig.equals(corrected)) {
128120
newValue.set(corrected);
129121
}

domain-http/interface/src/test/java/org/jboss/as/domain/http/server/ConsoleModeTestCase.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ public class ConsoleModeTestCase {
2626

2727
@Test
2828
public void testDefaultModules() throws Exception {
29-
checkModule(null, ModuleIdentifierUtil.canonicalModuleIdentifier("org.jboss.as.console"), "modules-default");
29+
checkModule(null, "org.jboss.as.console", "modules-default");
3030
}
3131

3232

elytron/src/main/java/org/wildfly/extension/elytron/ClassLoadingAttributeDefinitions.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ class ClassLoadingAttributeDefinitions {
4343
static ClassLoader resolveClassLoader(String module) throws ModuleLoadException {
4444
Module current = Module.getCallerModule();
4545
if (module != null && current != null) {
46-
current = current.getModule(ModuleIdentifierUtil.canonicalModuleIdentifier(module));
46+
current = current.getModule(ModuleIdentifierUtil.parseCanonicalModuleIdentifier(module));
4747
}
4848

4949
return current != null ? current.getClassLoader() : ClassLoadingAttributeDefinitions.class.getClassLoader();

elytron/src/main/java/org/wildfly/extension/elytron/DirContextDefinition.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -157,11 +157,10 @@ private static TrivialService.ValueSupplier<DirContextSupplier> obtainDirContext
157157
moduleName = MODULE.resolveModelAttribute(context, model).asString();
158158

159159
Module module = null;
160-
if(moduleName != null && !"".equals(moduleName)){
160+
if(moduleName != null && !moduleName.isEmpty()){
161161
try {
162162
Module cm = Module.getCallerModule();
163-
//module = Module.getCallerModule().getModule(ModuleIdentifier.create(moduleName));
164-
module = cm.getModule(ModuleIdentifierUtil.canonicalModuleIdentifier(moduleName));
163+
module = cm.getModule(ModuleIdentifierUtil.parseCanonicalModuleIdentifier(moduleName));
165164
} catch (ModuleLoadException e) {
166165
throw ElytronSubsystemMessages.ROOT_LOGGER.unableToLoadModule(moduleName, e);
167166
}

elytron/src/main/java/org/wildfly/extension/elytron/PermissionMapperDefinitions.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -431,7 +431,7 @@ static class Permission {
431431

432432
Permission(final String className, final String module, final String targetName, final String action) {
433433
this.className = className;
434-
this.module = module != null ? ModuleIdentifierUtil.canonicalModuleIdentifier(module) : module;
434+
this.module = module != null ? ModuleIdentifierUtil.parseCanonicalModuleIdentifier(module) : module;
435435
this.targetName = targetName;
436436
this.action = action;
437437
}

server/src/main/java/org/jboss/as/server/deployment/module/ManifestDependencyProcessor.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ public void deploy(final DeploymentPhaseContext phaseContext) throws DeploymentU
8484
}
8585
final String[] dependencyParts = trimmed.split(" ");
8686

87-
final String dependencyId = ModuleIdentifierUtil.canonicalModuleIdentifier(dependencyParts[0]);
87+
final String dependencyId = ModuleIdentifierUtil.parseCanonicalModuleIdentifier(dependencyParts[0]);
8888
final boolean export = containsParam(dependencyParts, EXPORT_PARAM);
8989
final boolean optional = containsParam(dependencyParts, OPTIONAL_PARAM);
9090
final boolean services = containsParam(dependencyParts, SERVICES_PARAM);

server/src/main/java/org/jboss/as/server/deployment/module/ModuleDependency.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ public static Builder of(ModuleLoader moduleLoader, String moduleName) {
3737

3838
private Builder(ModuleLoader moduleLoader, String moduleName) {
3939
this.moduleLoader = moduleLoader;
40-
this.identifier = ModuleIdentifierUtil.canonicalModuleIdentifier(moduleName);
40+
this.identifier = ModuleIdentifierUtil.parseCanonicalModuleIdentifier(moduleName);
4141
}
4242

4343
/**
@@ -148,7 +148,7 @@ public String toString() {
148148
*/
149149
@Deprecated(forRemoval = true)
150150
public ModuleDependency(final ModuleLoader moduleLoader, final String identifier, final boolean optional, final boolean export, final boolean importServices, final boolean userSpecified) {
151-
this(moduleLoader, ModuleIdentifierUtil.canonicalModuleIdentifier(identifier), null, optional, export, importServices, userSpecified);
151+
this(moduleLoader, ModuleIdentifierUtil.parseCanonicalModuleIdentifier(identifier), null, optional, export, importServices, userSpecified);
152152
}
153153

154154
/**
@@ -166,7 +166,7 @@ public ModuleDependency(final ModuleLoader moduleLoader, final String identifier
166166
*/
167167
@Deprecated(forRemoval = true)
168168
public ModuleDependency(final ModuleLoader moduleLoader, final String identifier, final boolean optional, final boolean export, final boolean importServices, final boolean userSpecified, String reason) {
169-
this(moduleLoader, ModuleIdentifierUtil.canonicalModuleIdentifier(identifier), reason, optional, export, importServices, userSpecified);
169+
this(moduleLoader, ModuleIdentifierUtil.parseCanonicalModuleIdentifier(identifier), reason, optional, export, importServices, userSpecified);
170170
}
171171

172172
/**
@@ -227,7 +227,7 @@ public ModuleIdentifier getIdentifier() {
227227
/**
228228
* Gets the name of the module upon which there is a dependency.
229229
*
230-
* @return the {@link ModuleIdentifierUtil#canonicalModuleIdentifier(String) canonical form} of the name of module
230+
* @return the {@link ModuleIdentifierUtil#parseCanonicalModuleIdentifier(String) canonical form} of the name of module
231231
*/
232232
public String getDependencyModule() {
233233
return identifier;

testsuite/standalone/src/test/java/org/wildfly/core/test/standalone/mgmt/api/core/ModuleInfoTestCase.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55

66
package org.wildfly.core.test.standalone.mgmt.api.core;
77

8-
import org.jboss.as.controller.ModuleIdentifierUtil;
98
import org.jboss.as.controller.PathAddress;
109
import org.jboss.as.controller.PathElement;
1110
import org.jboss.as.controller.operations.common.Util;
@@ -101,7 +100,7 @@ public void testModuleInfo() throws Exception {
101100
}*/
102101

103102
// load module.xml
104-
String identifier = ModuleIdentifierUtil.canonicalModuleIdentifier(TARGET_MODULE_NAME + ":main");
103+
String identifier = TARGET_MODULE_NAME;
105104
Module module = loadModule(identifier);
106105

107106
// run module-info operation

0 commit comments

Comments
 (0)