Skip to content
Open
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 @@ -9,6 +9,7 @@
import static org.jboss.as.controller.descriptions.ModelDescriptionConstants.EXTENSION;

import org.jboss.as.controller.ModelVersion;
import org.jboss.as.controller.ModuleIdentifierUtil;
import org.jboss.as.controller.OperationDefinition;
import org.jboss.as.controller.PathElement;
import org.jboss.as.controller.SimpleAttributeDefinition;
Expand All @@ -31,11 +32,14 @@
public class ExtensionResourceDefinition extends SimpleResourceDefinition {

public static final SimpleAttributeDefinition MODULE = new SimpleAttributeDefinitionBuilder(ModelDescriptionConstants.MODULE, ModelType.STRING, false)
.setValidator(new StringLengthValidator(1)).build();
.setValidator(new StringLengthValidator(1))
.setCorrector(ModuleIdentifierUtil.MODULE_NAME_CORRECTOR)
.build();

private static final OperationDefinition ADD_OP = new SimpleOperationDefinitionBuilder(ADD, ControllerResolver.getResolver(EXTENSION))
.addParameter(new SimpleAttributeDefinitionBuilder(ModelDescriptionConstants.MODULE, ModelType.STRING, true)
.setValidator(new StringLengthValidator(1))
.setCorrector(ModuleIdentifierUtil.MODULE_NAME_CORRECTOR)
.setDeprecated(ModelVersion.create(6))
.build())
.build();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
import org.jboss.as.controller.AbstractAddStepHandler;
import org.jboss.as.controller.AbstractRemoveStepHandler;
import org.jboss.as.controller.AttributeDefinition;
import org.jboss.as.controller.ModuleIdentifierUtil;
import org.jboss.as.controller.OperationContext;
import org.jboss.as.controller.OperationFailedException;
import org.jboss.as.controller.PersistentResourceDefinition;
Expand Down Expand Up @@ -57,6 +58,7 @@ public class ProcessStateListenerResourceDefinition extends PersistentResourceDe
.setRestartAllServices()
.build();
public static final AttributeDefinition LISTENER_MODULE = SimpleAttributeDefinitionBuilder.create(MODULE, ModelType.STRING, false)
.setCorrector(ModuleIdentifierUtil.MODULE_NAME_CORRECTOR)
.setAllowExpression(false)
.setRestartAllServices()
.build();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ class ClassLoadingAttributeDefinitions {
static final SimpleAttributeDefinition MODULE = new SimpleAttributeDefinitionBuilder(ElytronDescriptionConstants.MODULE, ModelType.STRING, true)
.setAttributeGroup(ElytronDescriptionConstants.CLASS_LOADING)
.setAllowExpression(false)
.setCorrector(ModuleIdentifierUtil.MODULE_NAME_CORRECTOR)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since the module will be provided now in a canonicalized form, apparently, we can now remove the canonicalization request done at

current = current.getModule(ModuleIdentifierUtil.parseCanonicalModuleIdentifier(module));

The only one I have in doubt is the invocation of that method from

@darranl What's your feeling about this? Would this configuration.get("module") always be in a canonicalized form? I've tried by finding the usages of the enclosing method, but it returns that there are no usages at all, so not sure from where this method gets invoked.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unless I am misreading this comment this sounds like a breaking change we can not make to the management model.

Is the call to parseCanonicalModuleIdentifier more permissive than ModuleIdentifierUtil.MODULE_NAME_CORRECTOR?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@darranl The ModuleIdentifierUtil.MODULE_NAME_CORRECTOR as an attribute corrector just moves the #parseCanonicalModuleIdentifier(String) to the attribute, so it will always return the canonicalized form of the module, see

/**
* A {@link ParameterCorrector} that {@link #parseCanonicalModuleIdentifier(String) canonicalizes}
* values that are meant to represent JBoss Modules module names.
*/
.

They are equivalents, but having it at the attribute level is preferred since it is supposed to be the entry of the user values.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The idea has always been to place this sort of conversions/adjustments as close as possible to the external inputs, hence on the attribute definitions via ModuleIdentifierUtil.MODULE_NAME_CORRECTOR, however, for this JaasCustomSecurityRealmWrapper.java class, which is indeed deprecated, I'm not sure what the external input is for this configuration object

.setMinSize(1)
.setRestartAllServices()
.build();
Expand All @@ -43,7 +44,7 @@ class ClassLoadingAttributeDefinitions {
static ClassLoader resolveClassLoader(String module) throws ModuleLoadException {
Module current = Module.getCallerModule();
if (module != null && current != null) {
current = current.getModule(ModuleIdentifierUtil.parseCanonicalModuleIdentifier(module));
current = current.getModule(module);
}

return current != null ? current.getClassLoader() : ClassLoadingAttributeDefinitions.class.getClassLoader();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,7 @@ class DirContextDefinition extends SimpleResourceDefinition {

static final SimpleAttributeDefinition MODULE = new SimpleAttributeDefinitionBuilder(ElytronDescriptionConstants.MODULE, ModelType.STRING, true)
.setAllowExpression(true)
.setCorrector(ModuleIdentifierUtil.MODULE_NAME_CORRECTOR)
Comment thread
yersan marked this conversation as resolved.
.setRestartAllServices()
.build();

Expand Down Expand Up @@ -160,7 +161,7 @@ private static TrivialService.ValueSupplier<DirContextSupplier> obtainDirContext
if(moduleName != null && !moduleName.isEmpty()){
try {
Module cm = Module.getCallerModule();
module = cm.getModule(ModuleIdentifierUtil.parseCanonicalModuleIdentifier(moduleName));
module = cm.getModule(moduleName);
} catch (ModuleLoadException e) {
throw ElytronSubsystemMessages.ROOT_LOGGER.unableToLoadModule(moduleName, e);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

import org.jboss.as.controller.AbstractAddStepHandler;
import org.jboss.as.controller.AttributeDefinition;
import org.jboss.as.controller.ModuleIdentifierUtil;
import org.jboss.as.controller.OperationContext;
import org.jboss.as.controller.OperationFailedException;
import org.jboss.as.controller.OperationStepHandler;
Expand Down Expand Up @@ -68,6 +69,7 @@ public class JaasRealmDefinition extends SimpleResourceDefinition {

static final SimpleAttributeDefinition MODULE = new SimpleAttributeDefinitionBuilder(ElytronDescriptionConstants.MODULE, ModelType.STRING, false)
.setRequired(false)
.setCorrector(ModuleIdentifierUtil.MODULE_NAME_CORRECTOR)
.setRestartAllServices()
.build();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
import org.jboss.as.controller.AttributeDefinition;
import org.jboss.as.controller.MapAttributeDefinition;
import org.jboss.as.controller.ModelOnlyWriteAttributeHandler;
import org.jboss.as.controller.ModuleIdentifierUtil;
import org.jboss.as.controller.PathElement;
import org.jboss.as.controller.PropertiesAttributeDefinition;
import org.jboss.as.controller.SimpleAttributeDefinition;
Expand Down Expand Up @@ -44,6 +45,7 @@ public class DiscoveryOptionResourceDefinition extends SimpleResourceDefinition
public static final SimpleAttributeDefinition MODULE = new SimpleAttributeDefinitionBuilder(ModelDescriptionConstants.MODULE, ModelType.STRING, true)
.setDefaultValue(new ModelNode(DEFAULT_MODULE))
.setValidator(new StringLengthValidator(1))
.setCorrector(ModuleIdentifierUtil.MODULE_NAME_CORRECTOR)
Comment thread
yersan marked this conversation as resolved.
.setStorageRuntime()
.setRuntimeServiceNotRequired()
.build();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@

import org.jboss.as.controller.OperationContext;
import org.jboss.as.controller.OperationFailedException;
import org.jboss.as.controller.client.helpers.JBossModulesNameUtil;
import org.jboss.as.controller.registry.Resource;
import org.jboss.as.host.controller.discovery.DiscoveryOption;
import org.jboss.as.host.controller.discovery.DiscoveryOptionResourceDefinition;
Expand Down Expand Up @@ -76,7 +75,7 @@ protected void populateHostControllerInfo(LocalHostControllerInfoImpl hostContro

try {
String moduleID = moduleName != null
? JBossModulesNameUtil.parseCanonicalModuleIdentifier(moduleName)
? moduleName
: Module.forClass(getClass()).getName();
final Class<? extends DiscoveryOption> discoveryOptionClass = Module.loadClassFromCallerModuleLoader(moduleID, discoveryOptionClassName)
.asSubclass(DiscoveryOption.class);
Expand Down
11 changes: 8 additions & 3 deletions logging/src/main/java/org/jboss/as/logging/CommonAttributes.java
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,13 @@
import org.jboss.as.controller.CaseParameterCorrector;
import org.jboss.as.controller.DefaultAttributeMarshaller;
import org.jboss.as.controller.ModelVersion;
import org.jboss.as.controller.ModuleIdentifierUtil;
import org.jboss.as.controller.ObjectTypeAttributeDefinition;
import org.jboss.as.controller.OperationFailedException;
import org.jboss.as.controller.SimpleAttributeDefinition;
import org.jboss.as.controller.SimpleAttributeDefinitionBuilder;
import org.jboss.as.controller.SimpleMapAttributeDefinition;
import org.jboss.as.controller.descriptions.ModelDescriptionConstants;
import org.jboss.as.controller.operations.validation.ObjectTypeValidator;
import org.jboss.as.controller.registry.AttributeAccess.Flag;
import org.jboss.as.controller.services.path.PathManager;
Expand Down Expand Up @@ -111,18 +113,21 @@ public void marshallAsElement(final AttributeDefinition attribute, final ModelNo

String LOGGING_PROFILES = "logging-profiles";

SimpleAttributeDefinition MODULE = SimpleAttributeDefinitionBuilder.create("module", ModelType.STRING)
SimpleAttributeDefinition MODULE = SimpleAttributeDefinitionBuilder
.create(ModelDescriptionConstants.MODULE, ModelType.STRING)
.setAllowExpression(false)
.setCorrector(ModuleIdentifierUtil.MODULE_NAME_CORRECTOR)
.setRestartAllServices()
.build();

SimpleAttributeDefinition NAME = SimpleAttributeDefinitionBuilder.create("name", ModelType.STRING, true)
SimpleAttributeDefinition NAME = SimpleAttributeDefinitionBuilder
.create(ModelDescriptionConstants.NAME, ModelType.STRING, true)
.setAllowExpression(false)
.setDeprecated(ModelVersion.create(1, 2, 0))
.setResourceOnly()
.build();

SimpleMapAttributeDefinition PROPERTIES = new SimpleMapAttributeDefinition.Builder("properties", true)
SimpleMapAttributeDefinition PROPERTIES = new SimpleMapAttributeDefinition.Builder(ModelDescriptionConstants.PROPERTIES, true)
.setAllowExpression(true)
.setAttributeMarshaller(PropertyAttributeMarshaller.INSTANCE)
.build();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

package org.jboss.as.logging.deployments.resources;

import org.jboss.as.controller.ModuleIdentifierUtil;
import org.jboss.as.controller.PathElement;
import org.jboss.as.controller.SimpleAttributeDefinition;
import org.jboss.as.controller.SimpleAttributeDefinitionBuilder;
Expand Down Expand Up @@ -33,6 +34,7 @@ class HandlerResourceDefinition extends SimpleResourceDefinition {
.build();

private static final SimpleAttributeDefinition MODULE = SimpleAttributeDefinitionBuilder.create("module", ModelType.STRING, true)
.setCorrector(ModuleIdentifierUtil.MODULE_NAME_CORRECTOR)
.setStorageRuntime()
.build();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

import java.util.Collection;

import org.jboss.as.controller.ModuleIdentifierUtil;
import org.jboss.as.controller.PathAddress;
import org.jboss.as.controller.PathElement;
import org.jboss.as.controller.ResourceDefinition;
Expand Down Expand Up @@ -121,6 +122,7 @@ private abstract static class PropertiesResourceDefinition extends SimpleResourc
.build();

static final SimpleAttributeDefinition MODULE = SimpleAttributeDefinitionBuilder.create("module", ModelType.STRING, true)
.setCorrector(ModuleIdentifierUtil.MODULE_NAME_CORRECTOR)
.setStorageRuntime()
.build();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
import java.util.Collections;

import org.jboss.as.controller.AttributeDefinition;
import org.jboss.as.controller.ModuleIdentifierUtil;
import org.jboss.as.controller.ObjectListAttributeDefinition;
import org.jboss.as.controller.ObjectTypeAttributeDefinition;
import org.jboss.as.controller.PathElement;
Expand Down Expand Up @@ -57,6 +58,7 @@ class DeploymentPermissionsResourceDefinition extends PersistentResourceDefiniti

static final SimpleAttributeDefinition MODULE = new SimpleAttributeDefinitionBuilder(PERMISSION_MODULE, ModelType.STRING)
.setRequired(false)
.setCorrector(ModuleIdentifierUtil.MODULE_NAME_CORRECTOR)
.setFlags(AttributeAccess.Flag.RESTART_ALL_SERVICES)
.build();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
import org.jboss.as.controller.AbstractRuntimeOnlyHandler;
import org.jboss.as.controller.AttributeDefinition;
import org.jboss.as.controller.ModelVersion;
import org.jboss.as.controller.ModuleIdentifierUtil;
import org.jboss.as.controller.OperationContext;
import org.jboss.as.controller.OperationDefinition;
import org.jboss.as.controller.OperationFailedException;
Expand All @@ -34,7 +35,6 @@
import org.jboss.as.controller.SimpleOperationDefinitionBuilder;
import org.jboss.as.controller.SimpleResourceDefinition;
import org.jboss.as.controller.access.management.SensitiveTargetAccessConstraintDefinition;
import org.jboss.as.controller.client.helpers.JBossModulesNameUtil;
import org.jboss.as.controller.registry.ManagementResourceRegistration;
import org.jboss.as.server.controller.descriptions.ServerDescriptions;
import org.jboss.dmr.ModelNode;
Expand All @@ -55,7 +55,8 @@
*/
public class ModuleLoadingResourceDefinition extends SimpleResourceDefinition {

private static final AttributeDefinition MODULE_NAME = new SimpleAttributeDefinitionBuilder(MODULE, ModelType.STRING).build();
private static final AttributeDefinition MODULE_NAME = new SimpleAttributeDefinitionBuilder(MODULE,
ModelType.STRING).setCorrector(ModuleIdentifierUtil.MODULE_NAME_CORRECTOR).build();
Comment thread
yersan marked this conversation as resolved.

public static final ModuleLoadingResourceDefinition INSTANCE = new ModuleLoadingResourceDefinition();

Expand Down Expand Up @@ -207,7 +208,7 @@ public List<String> run() throws Exception {
private static List<String> findResourcePaths(String moduleName) throws ModuleLoadException, ReflectiveOperationException, IOException, URISyntaxException {
ModuleLoader moduleLoader = Module.getCallerModuleLoader();
ModuleLoaderMXBean loader = ModuleInfoHandler.INSTANCE.getMxBean(moduleLoader);
moduleLoader.loadModule(JBossModulesNameUtil.parseCanonicalModuleIdentifier(moduleName));
moduleLoader.loadModule(moduleName);

List<String> result = new LinkedList<>();
for (ResourceLoaderInfo rl : loader.getResourceLoaders(moduleName)){
Expand Down
Loading