Skip to content

Commit

Permalink
Merge pull request #6105 from pferraro/WFCORE-6926
Browse files Browse the repository at this point in the history
WFCORE-6926 Remove usage of deprecated AbstractWriteAttributeHandler constructors in logging subsystem
  • Loading branch information
yersan authored Jul 24, 2024
2 parents 6b365d0 + 7904d32 commit f9d6bcf
Show file tree
Hide file tree
Showing 13 changed files with 14 additions and 49 deletions.
15 changes: 0 additions & 15 deletions logging/src/main/java/org/jboss/as/logging/LoggingOperations.java
Original file line number Diff line number Diff line change
Expand Up @@ -392,12 +392,6 @@ protected void revertRuntime(final OperationContext context, final ModelNode ope
* A default log handler write attribute step handler.
*/
public abstract static class LoggingWriteAttributeHandler extends AbstractWriteAttributeHandler<ConfigurationPersistence> {
private final AttributeDefinition[] attributes;

protected LoggingWriteAttributeHandler(final AttributeDefinition[] attributes) {
super(attributes);
this.attributes = attributes;
}

@Override
protected final boolean applyUpdateToRuntime(final OperationContext context, final ModelNode operation, final String attributeName, final ModelNode resolvedValue, final ModelNode currentValue, final HandbackHolder<ConfigurationPersistence> handbackHolder) throws OperationFailedException {
Expand Down Expand Up @@ -464,14 +458,5 @@ protected void validateUpdatedModel(final OperationContext context, final Resour
submodel.get(LoggerAttributes.FILTER_SPEC.getName()).set(filterSpec.isEmpty() ? new ModelNode() : new ModelNode(filterSpec));
}
}

/**
* Returns a collection of attributes used for the write attribute.
*
* @return a collection of attributes
*/
public final AttributeDefinition[] getAttributes() {
return attributes;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -150,9 +150,8 @@ protected LoggingResourceDefinition(final PathManager pathManager, final WildFly
public void registerAttributes(final ManagementResourceRegistration resourceRegistration) {
super.registerAttributes(resourceRegistration);

final OperationStepHandler writeHandler = new ReloadRequiredWriteAttributeHandler(ATTRIBUTES);
for (SimpleAttributeDefinition attribute : ATTRIBUTES) {
resourceRegistration.registerReadWriteAttribute(attribute, null, writeHandler);
resourceRegistration.registerReadWriteAttribute(attribute, null, ReloadRequiredWriteAttributeHandler.INSTANCE);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ public void performRuntime(final OperationContext context, final ModelNode opera
}
};

private static final OperationStepHandler WRITE = new LoggingWriteAttributeHandler(ATTRIBUTES) {
private static final OperationStepHandler WRITE = new LoggingWriteAttributeHandler() {

@Override
protected boolean applyUpdate(final OperationContext context, final String attributeName, final String addressName, final ModelNode value, final LogContextConfiguration logContextConfiguration) throws OperationFailedException {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ public void performRuntime(final OperationContext context, final ModelNode opera
}
};

private static final OperationStepHandler WRITE = new LoggingWriteAttributeHandler(ATTRIBUTES) {
private static final OperationStepHandler WRITE = new LoggingWriteAttributeHandler() {

@Override
protected boolean applyUpdate(final OperationContext context, final String attributeName, final String addressName, final ModelNode value, final LogContextConfiguration logContextConfiguration) throws OperationFailedException {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ public void performRuntime(final OperationContext context, final ModelNode opera
}
};

private static final OperationStepHandler WRITE = new LoggingWriteAttributeHandler(ATTRIBUTES) {
private static final OperationStepHandler WRITE = new LoggingWriteAttributeHandler() {

@Override
protected boolean applyUpdate(final OperationContext context, final String attributeName, final String addressName, final ModelNode value, final LogContextConfiguration logContextConfiguration) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -293,7 +293,7 @@ public void performRuntime(final OperationContext context, final ModelNode opera
.setCapabilities(Capabilities.FORMATTER_CAPABILITY)
);
attributes = Logging.join(DEFAULT_ATTRIBUTES, additionalAttributes);
writeHandler = new WriteStructuredFormatterStepHandler(attributes);
writeHandler = new WriteStructuredFormatterStepHandler();
}

@Override
Expand Down Expand Up @@ -431,10 +431,6 @@ private static boolean isSamePropertyValue(final FormatterConfiguration configur

private static class WriteStructuredFormatterStepHandler extends LoggingOperations.LoggingWriteAttributeHandler {

WriteStructuredFormatterStepHandler(final AttributeDefinition[] attributes) {
super(attributes);
}

@Override
protected boolean applyUpdate(final OperationContext context, final String attributeName, final String addressName,
final ModelNode value, final LogContextConfiguration logContextConfiguration) throws OperationFailedException {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ protected AbstractHandlerDefinition(final Parameters parameters,
super(parameters);
this.registerLegacyOps = registerLegacyOps;
this.writableAttributes = writableAttributes;
writeHandler = new HandlerOperations.LogHandlerWriteAttributeHandler(this.writableAttributes);
writeHandler = new HandlerOperations.LogHandlerWriteAttributeHandler();
this.readOnlyAttributes = readOnlyAttributes;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -262,10 +262,6 @@ HandlerConfiguration createHandlerConfiguration(final String className,
*/
static class LogHandlerWriteAttributeHandler extends LoggingOperations.LoggingWriteAttributeHandler {

LogHandlerWriteAttributeHandler(final AttributeDefinition... attributes) {
super(attributes);
}

@Override
protected boolean applyUpdate(final OperationContext context, final String attributeName, final String addressName, final ModelNode value, final LogContextConfiguration logContextConfiguration) throws OperationFailedException {
boolean restartRequired = false;
Expand Down Expand Up @@ -312,13 +308,9 @@ protected boolean applyUpdate(final OperationContext context, final String attri
// queue-length is a construction parameter, runtime changes are not allowed
restartRequired = true;
} else {
for (AttributeDefinition attribute : getAttributes()) {
if (attribute.getName().equals(attributeName)) {
handleProperty(attribute, context, value, logContextConfiguration, configuration, false);
restartRequired = Logging.requiresReload(attribute.getFlags());
break;
}
}
AttributeDefinition attribute = context.getResourceRegistration().getAttributeAccess(PathAddress.EMPTY_ADDRESS, attributeName).getAttributeDefinition();
handleProperty(attribute, context, value, logContextConfiguration, configuration, false);
restartRequired = Logging.requiresReload(attribute.getFlags());
}
}
return restartRequired;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
import org.jboss.as.controller.OperationContext.Stage;
import org.jboss.as.controller.OperationFailedException;
import org.jboss.as.controller.OperationStepHandler;
import org.jboss.as.controller.PathAddress;
import org.jboss.as.controller.PathElement;
import org.jboss.as.controller.SimpleAttributeDefinition;
import org.jboss.as.controller.SimpleAttributeDefinitionBuilder;
Expand Down Expand Up @@ -311,10 +312,6 @@ public void registerTransformers(final KnownModelVersion modelVersion, final Res
private static class WriteAttributeHandler extends LoggingOperations.LoggingWriteAttributeHandler {
static final WriteAttributeHandler INSTANCE = new WriteAttributeHandler();

WriteAttributeHandler() {
super(ATTRIBUTES);
}

@SuppressWarnings("deprecation")
@Override
protected boolean applyUpdate(final OperationContext context, final String attributeName, final String addressName,
Expand All @@ -341,7 +338,7 @@ protected boolean applyUpdate(final OperationContext context, final String attri
configuration.setFilter(null);
}
}
return Logging.requiresReload(getAttributeDefinition(attributeName).getFlags());
return Logging.requiresReload(context.getResourceRegistration().getAttributeAccess(PathAddress.EMPTY_ADDRESS, attributeName).getFlags());

}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ public void marshallAsElement(final AttributeDefinition attribute, final ModelNo
};

private static final HandlerAddOperationStepHandler ADD_HANDLER = new HandlerAddOperationStepHandler(SyslogHandler.class, ATTRIBUTES);
private static final LogHandlerWriteAttributeHandler WRITE_HANDLER = new LogHandlerWriteAttributeHandler(ATTRIBUTES);
private static final LogHandlerWriteAttributeHandler WRITE_HANDLER = new LogHandlerWriteAttributeHandler();

public static final SyslogHandlerResourceDefinition INSTANCE = new SyslogHandlerResourceDefinition();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -120,10 +120,6 @@ public void performRuntime(final OperationContext context, final ModelNode opera
*/
static class LoggerWriteAttributeHandler extends LoggingOperations.LoggingWriteAttributeHandler {

LoggerWriteAttributeHandler(final AttributeDefinition[] attributes) {
super(attributes);
}

@Override
protected boolean applyUpdate(final OperationContext context, final String attributeName, final String addressName, final ModelNode value, final LogContextConfiguration logContextConfiguration) throws OperationFailedException {
final String loggerName = getLogManagerLoggerName(addressName);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ public LoggerResourceDefinition(final boolean includeLegacy) {
.setAccessConstraints(new ApplicationTypeAccessConstraintDefinition(new ApplicationTypeConfig(LoggingExtension.SUBSYSTEM_NAME, NAME)))
.setCapabilities(Capabilities.LOGGER_CAPABILITY));
writableAttributes = (includeLegacy ? join(WRITABLE_ATTRIBUTES, LEGACY_ATTRIBUTES) : WRITABLE_ATTRIBUTES);
this.writeHandler = new LoggerOperations.LoggerWriteAttributeHandler(writableAttributes);
this.writeHandler = new LoggerOperations.LoggerWriteAttributeHandler();
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ public RootLoggerResourceDefinition(final boolean includeLegacy) {
.setCapabilities(Capabilities.LOGGER_CAPABILITY));
attributes = (includeLegacy ? join(ATTRIBUTES, LEGACY_ATTRIBUTES) : ATTRIBUTES);
addHandler = new LoggerOperations.LoggerAddOperationStepHandler(attributes);
writeHandler = new LoggerOperations.LoggerWriteAttributeHandler(attributes);
writeHandler = new LoggerOperations.LoggerWriteAttributeHandler();
}

@Override
Expand Down

0 comments on commit f9d6bcf

Please sign in to comment.