Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WFCORE-6930 Remove usage of deprecated AbstractWriteAttributeHandler constructors in testsuite #6109

Merged
merged 1 commit into from
Jul 22, 2024
Merged
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 @@ -167,7 +167,7 @@ protected TestResourceDefinition() {

@Override
public void registerAttributes(ManagementResourceRegistration resourceRegistration) {
resourceRegistration.registerReadWriteAttribute(TEST, null, new ModelOnlyWriteAttributeHandler());
resourceRegistration.registerReadWriteAttribute(TEST, null, ModelOnlyWriteAttributeHandler.INSTANCE);
//Custom write handler to attach the old value
resourceRegistration.registerReadWriteAttribute(PROPERTIES, null, new ModelOnlyWriteAttributeHandler(){
@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ private TestResourceDefinition() {

@Override
public void registerAttributes(ManagementResourceRegistration resourceRegistration) {
resourceRegistration.registerReadWriteAttribute(TEST, null, new ModelOnlyWriteAttributeHandler());
resourceRegistration.registerReadWriteAttribute(TEST, null, ModelOnlyWriteAttributeHandler.INSTANCE);
}

@Override
Expand All @@ -94,7 +94,7 @@ private PropertyResourceDefinition() {

@Override
public void registerAttributes(ManagementResourceRegistration resourceRegistration) {
resourceRegistration.registerReadWriteAttribute(VALUE, null, new ModelOnlyWriteAttributeHandler());
resourceRegistration.registerReadWriteAttribute(VALUE, null, ModelOnlyWriteAttributeHandler.INSTANCE);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ private SessionDefinition() {
@Override
public void registerAttributes(final ManagementResourceRegistration registry) {
for (AttributeDefinition attr : ATTRIBUTES) {
registry.registerReadWriteAttribute(attr, null, new ReloadRequiredWriteAttributeHandler(attr));
registry.registerReadWriteAttribute(attr, null, ReloadRequiredWriteAttributeHandler.INSTANCE);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ protected ManagementResourceRegistration initializeSubsystem(final SubsystemRegi
final ManagementResourceRegistration reg = registration.registerSubsystemModel(new TestResourceDefinition(SUBSYSTEM_PATH, new TestModelOnlyAddHandler(TEST_ATTRIBUTE)) {
@Override
public void registerAttributes(ManagementResourceRegistration resourceRegistration) {
resourceRegistration.registerReadWriteAttribute(TEST_ATTRIBUTE, null, new BasicAttributeWriteHandler(TEST_ATTRIBUTE));
resourceRegistration.registerReadWriteAttribute(TEST_ATTRIBUTE, null, new BasicAttributeWriteHandler());
}
});
reg.registerOperationHandler(GenericSubsystemDescribeHandler.DEFINITION, GenericSubsystemDescribeHandler.INSTANCE);
Expand Down Expand Up @@ -128,6 +128,10 @@ protected void performRuntime(OperationContext context, ModelNode operation, Mod

private static class BasicAttributeWriteHandler extends AbstractWriteAttributeHandler<Void> {

protected BasicAttributeWriteHandler() {
super(List.of());
}

Copy link
Contributor

Choose a reason for hiding this comment

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

@pferraro This class seems wrong; it seems to be adding a new call to a deprecated c'tor instead of removing the existing one.

Copy link
Contributor Author

@pferraro pferraro Jul 20, 2024

Choose a reason for hiding this comment

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

Hmm - not sure what I was thinking here. Will fix.

Now I remember...
This operation handler is used for transformer tests. The purpose of the additional no-arg constructor is to migrate the calling code.
However, the no-arg super constructor does not exist on the legacy version of AbstractWriteAttributeHandler, hence the need to delegate to a super constructor that does exist.

protected BasicAttributeWriteHandler(AttributeDefinition def) {
super(def);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,6 @@ public class OrderedChildResourceExtension implements Extension {
private static final String NAMESPACE = "urn:jboss:test:extension:ordered:child:resource:1.0";
public static final PathElement CHILD = PathElement.pathElement("child");
private static final AttributeDefinition ATTR = new SimpleAttributeDefinitionBuilder("attr", ModelType.STRING, true).build();
private static final AttributeDefinition[] REQUEST_ATTRIBUTES = new AttributeDefinition[]{ATTR};


@Override
public void initialize(ExtensionContext context) {
Expand All @@ -83,7 +81,7 @@ public SubsystemResourceDefinition() {

@Override
public void registerAttributes(ManagementResourceRegistration resourceRegistration) {
resourceRegistration.registerReadWriteAttribute(ATTR, null, new ModelOnlyWriteAttributeHandler(REQUEST_ATTRIBUTES));
resourceRegistration.registerReadWriteAttribute(ATTR, null, ModelOnlyWriteAttributeHandler.INSTANCE);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ public RootResourceDefinition(String name) {
@Override
public void registerAttributes(ManagementResourceRegistration resourceRegistration) {
super.registerAttributes(resourceRegistration);
resourceRegistration.registerReadWriteAttribute(NAME, null, new ReloadRequiredWriteAttributeHandler(NAME));
resourceRegistration.registerReadWriteAttribute(NAME, null, ReloadRequiredWriteAttributeHandler.INSTANCE);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,13 +64,13 @@ protected RegistrationResult initializeSubsystem(final ExtensionContext context,
final ManagementResourceRegistration registration = subsystem.registerSubsystemModel(definition);

// Test attribute
registration.registerReadWriteAttribute(TEST_ATTRIBUTE, null, new BasicAttributeWriteHandler(TEST_ATTRIBUTE));
registration.registerReadWriteAttribute(TEST_ATTRIBUTE, null, new BasicAttributeWriteHandler());

// Other basic handlers
final AttributeDefinition integer = SimpleAttributeDefinitionBuilder.create("int", ModelType.INT, true).setAllowExpression(allowExpressions).build();
final AttributeDefinition string = SimpleAttributeDefinitionBuilder.create("string", ModelType.STRING, true).setAllowExpression(allowExpressions).build();
registration.registerReadWriteAttribute(integer, null, new BasicAttributeWriteHandler(integer));
registration.registerReadWriteAttribute(string, null, new BasicAttributeWriteHandler(string));
registration.registerReadWriteAttribute(integer, null, new BasicAttributeWriteHandler());
registration.registerReadWriteAttribute(string, null, new BasicAttributeWriteHandler());
registration.registerOperationHandler(GenericSubsystemDescribeHandler.DEFINITION, GenericSubsystemDescribeHandler.INSTANCE);

return new RegistrationResult() {
Expand All @@ -96,10 +96,6 @@ protected ResourceDefinition createResourceDefinition(final PathElement element)

private static class BasicAttributeWriteHandler extends AbstractWriteAttributeHandler<Void> {

protected BasicAttributeWriteHandler(AttributeDefinition def) {
super(def);
}

@Override
protected boolean applyUpdateToRuntime(OperationContext context, ModelNode operation, String attributeName, ModelNode resolvedValue, ModelNode currentValue, HandbackHolder<Void> voidHandbackHolder) throws OperationFailedException {
return false;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ public RootResourceDefinition(String name) {
@Override
public void registerAttributes(ManagementResourceRegistration resourceRegistration) {
super.registerAttributes(resourceRegistration);
OperationStepHandler writeHandler = new ReloadRequiredWriteAttributeHandler(NAME, SOCKET_BINDING);
OperationStepHandler writeHandler = ReloadRequiredWriteAttributeHandler.INSTANCE;
resourceRegistration.registerReadWriteAttribute(NAME, null, writeHandler);
resourceRegistration.registerReadWriteAttribute(SOCKET_BINDING, null, writeHandler);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ public void registerOperations(ManagementResourceRegistration resourceRegistrati
@Override
public void registerAttributes(ManagementResourceRegistration resourceRegistration) {
super.registerAttributes(resourceRegistration);
resourceRegistration.registerReadWriteAttribute(FOO, null, new ModelOnlyWriteAttributeHandler(FOO));
resourceRegistration.registerReadWriteAttribute(FOO, null, ModelOnlyWriteAttributeHandler.INSTANCE);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ private RootResourceDefinition() {

@Override
public void registerAttributes(ManagementResourceRegistration resourceRegistration) {
OperationStepHandler write = new AbstractWriteAttributeHandler<Void>(ATTRIBUTE) {
OperationStepHandler write = new AbstractWriteAttributeHandler<Void>() {

@Override
protected boolean applyUpdateToRuntime(OperationContext context, ModelNode operation, String attributeName, ModelNode resolvedValue, ModelNode currentValue, HandbackHolder<Void> handbackHolder) throws OperationFailedException {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ public class ChildResourceDefinition extends SimpleResourceDefinition {
@Override
public void registerAttributes(ManagementResourceRegistration resourceRegistration) {
super.registerAttributes(resourceRegistration);
resourceRegistration.registerReadWriteAttribute(CHILD_ATTRIBUTE, null, new ReloadRequiredWriteAttributeHandler(CHILD_ATTRIBUTE));
resourceRegistration.registerReadWriteAttribute(CHILD_ATTRIBUTE, null, ReloadRequiredWriteAttributeHandler.INSTANCE);
}

private static class AddChildHandler extends AbstractAddStepHandler {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ public class RootResourceDefinition extends SimpleResourceDefinition {
@Override
public void registerAttributes(ManagementResourceRegistration resourceRegistration) {
super.registerAttributes(resourceRegistration);
resourceRegistration.registerReadWriteAttribute(ATTRIBUTE, null, new ReloadRequiredWriteAttributeHandler(ATTRIBUTE));
resourceRegistration.registerReadWriteAttribute(ATTRIBUTE, null, ReloadRequiredWriteAttributeHandler.INSTANCE);
}


Expand Down