Skip to content

Commit

Permalink
Update remoting subsystem to remove use of deprecated AbstractAddStep…
Browse files Browse the repository at this point in the history
…Handler and ReloadRequiredWriteAttributeHandler constructors.
  • Loading branch information
pferraro committed Sep 25, 2023
1 parent f1d67c6 commit 11a9840
Show file tree
Hide file tree
Showing 15 changed files with 21 additions and 69 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -52,20 +52,14 @@
*/
public class ConnectorAdd extends AbstractAddStepHandler {

static final ConnectorAdd INSTANCE = new ConnectorAdd();

private ConnectorAdd() {
super(ConnectorResource.ATTRIBUTES);
}

@Override
protected void performRuntime(OperationContext context, ModelNode operation, ModelNode model) throws OperationFailedException {
final ModelNode fullModel = Resource.Tools.readModel(context.readResource(PathAddress.EMPTY_ADDRESS));

launchServices(context, fullModel);
}

void launchServices(OperationContext context, ModelNode fullModel) throws OperationFailedException {
static void launchServices(OperationContext context, ModelNode fullModel) throws OperationFailedException {
final String connectorName = context.getCurrentAddressValue();
OptionMap optionMap = ConnectorUtils.getFullOptions(context, fullModel);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ public ConnectorChildResource(Parameters parameters) {
super(parameters);
}
static void recreateParentService(OperationContext context, ModelNode parentModel) throws OperationFailedException {
ConnectorAdd.INSTANCE.launchServices(context, parentModel);
ConnectorAdd.launchServices(context, parentModel);
}

static ServiceName getParentServiceName(PathAddress parentAddress) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@

import org.jboss.as.controller.AbstractRemoveStepHandler;
import org.jboss.as.controller.OperationContext;
import org.jboss.as.controller.OperationFailedException;
import org.jboss.dmr.ModelNode;

/**
Expand All @@ -34,17 +35,14 @@
*/
public class ConnectorRemove extends AbstractRemoveStepHandler {

static final ConnectorRemove INSTANCE = new ConnectorRemove();

private ConnectorRemove() {
}

@Override
protected void performRuntime(OperationContext context, ModelNode operation, ModelNode model) {
final String name = context.getCurrentAddressValue();
RemotingServices.removeConnectorServices(context, name);
}

protected void recoverServices(OperationContext context, ModelNode operation, ModelNode model) {
// TODO: RE-ADD SERVICES
@Override
protected void recoverServices(OperationContext context, ModelNode operation, ModelNode model) throws OperationFailedException {
ConnectorAdd.launchServices(context, model);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@
import java.util.List;

import org.jboss.as.controller.AttributeDefinition;
import org.jboss.as.controller.OperationStepHandler;
import org.jboss.as.controller.PathElement;
import org.jboss.as.controller.ReloadRequiredWriteAttributeHandler;
import org.jboss.as.controller.SimpleAttributeDefinition;
Expand Down Expand Up @@ -102,17 +101,15 @@ public class ConnectorResource extends SimpleResourceDefinition {

ConnectorResource() {
super(new Parameters(PATH, RemotingExtension.getResourceDescriptionResolver(CONNECTOR))
.setAddHandler(ConnectorAdd.INSTANCE)
.setRemoveHandler(ConnectorRemove.INSTANCE)
.setAddHandler(new ConnectorAdd())
.setRemoveHandler(new ConnectorRemove())
.setCapabilities(CONNECTOR_CAPABILITY));
}

@Override
public void registerAttributes(ManagementResourceRegistration resourceRegistration) {
final OperationStepHandler writeHandler = new ReloadRequiredWriteAttributeHandler(ATTRIBUTES);
for (AttributeDefinition ad : ATTRIBUTES) {
resourceRegistration.registerReadWriteAttribute(ad, null, writeHandler);
resourceRegistration.registerReadWriteAttribute(ad, null, ReloadRequiredWriteAttributeHandler.INSTANCE);
}
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -45,10 +45,6 @@
*/
class GenericOutboundConnectionAdd extends AbstractAddStepHandler {

GenericOutboundConnectionAdd() {
super(GenericOutboundConnectionResourceDefinition.ATTRIBUTES);
}

@Override
protected void performRuntime(OperationContext context, ModelNode operation, Resource resource)
throws OperationFailedException {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@
import java.util.List;

import org.jboss.as.controller.AttributeDefinition;
import org.jboss.as.controller.OperationStepHandler;
import org.jboss.as.controller.PathElement;
import org.jboss.as.controller.ReloadRequiredWriteAttributeHandler;
import org.jboss.as.controller.ServiceRemoveStepHandler;
Expand Down Expand Up @@ -70,9 +69,8 @@ public void registerChildren(ManagementResourceRegistration resourceRegistration

@Override
public void registerAttributes(ManagementResourceRegistration resourceRegistration) {
OperationStepHandler writeHandler = new ReloadRequiredWriteAttributeHandler(ATTRIBUTES);
for (AttributeDefinition attribute : ATTRIBUTES) {
resourceRegistration.registerReadWriteAttribute(attribute, null, writeHandler);
resourceRegistration.registerReadWriteAttribute(attribute, null, ReloadRequiredWriteAttributeHandler.INSTANCE);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -47,13 +47,6 @@
*/
public class HttpConnectorAdd extends AbstractAddStepHandler {

static final HttpConnectorAdd INSTANCE = new HttpConnectorAdd();

private HttpConnectorAdd() {
super(HttpConnectorResource.CONNECTOR_REF, HttpConnectorResource.AUTHENTICATION_PROVIDER, HttpConnectorResource.SECURITY_REALM,
HttpConnectorResource.SASL_AUTHENTICATION_FACTORY, ConnectorCommon.SASL_PROTOCOL, ConnectorCommon.SERVER_NAME);
}

@Override
protected void populateModel(OperationContext context, ModelNode operation, Resource resource) throws OperationFailedException {
super.populateModel(context, operation, resource);
Expand All @@ -68,7 +61,7 @@ protected void performRuntime(OperationContext context, ModelNode operation, Res
launchServices(context, connectorName, fullModel);
}

void launchServices(OperationContext context, String connectorName, ModelNode model) throws OperationFailedException {
static void launchServices(OperationContext context, String connectorName, ModelNode model) throws OperationFailedException {
OptionMap optionMap = ConnectorUtils.getFullOptions(context, model);

final String connectorRef = HttpConnectorResource.CONNECTOR_REF.resolveModelAttribute(context, model).asString();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,17 +38,17 @@
*/
public class HttpConnectorRemove extends AbstractRemoveStepHandler {

static final HttpConnectorRemove INSTANCE = new HttpConnectorRemove();

@Override
protected void performRuntime(OperationContext context, ModelNode operation, ModelNode model) {
final PathAddress address = PathAddress.pathAddress(operation.require(OP_ADDR));
final String name = address.getLastElement().getValue();
context.removeService(RemotingHttpUpgradeService.UPGRADE_SERVICE_NAME.append(name));
}

@Override
protected void recoverServices(OperationContext context, ModelNode operation, ModelNode model) throws OperationFailedException {
final PathAddress address = PathAddress.pathAddress(operation.require(OP_ADDR));
final String name = address.getLastElement().getValue();
HttpConnectorAdd.INSTANCE.launchServices(context, name, model);
HttpConnectorAdd.launchServices(context, name, model);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@
import java.util.List;

import org.jboss.as.controller.AttributeDefinition;
import org.jboss.as.controller.OperationStepHandler;
import org.jboss.as.controller.PathElement;
import org.jboss.as.controller.ReloadRequiredWriteAttributeHandler;
import org.jboss.as.controller.SimpleAttributeDefinition;
Expand Down Expand Up @@ -88,17 +87,16 @@ public class HttpConnectorResource extends SimpleResourceDefinition {

HttpConnectorResource() {
super(new Parameters(PATH, RemotingExtension.getResourceDescriptionResolver(HTTP_CONNECTOR))
.setAddHandler(HttpConnectorAdd.INSTANCE)
.setRemoveHandler(HttpConnectorRemove.INSTANCE)
.setAddHandler(new HttpConnectorAdd())
.setRemoveHandler(new HttpConnectorRemove())
// expose a common connector capability (WFCORE-4875)
.setCapabilities(CONNECTOR_CAPABILITY, HTTP_CONNECTOR_CAPABILITY));
}

@Override
public void registerAttributes(ManagementResourceRegistration resourceRegistration) {
final OperationStepHandler writeHandler = new ReloadRequiredWriteAttributeHandler(ATTRIBUTES);
for (AttributeDefinition 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 @@ -43,10 +43,6 @@
*/
class LocalOutboundConnectionAdd extends AbstractAddStepHandler {

LocalOutboundConnectionAdd() {
super(LocalOutboundConnectionResourceDefinition.ATTRIBUTES);
}

@Override
protected void performRuntime(OperationContext context, ModelNode operation, Resource resource) throws OperationFailedException {
installRuntimeService(context, resource.getModel());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@
import java.util.List;

import org.jboss.as.controller.AttributeDefinition;
import org.jboss.as.controller.OperationStepHandler;
import org.jboss.as.controller.PathElement;
import org.jboss.as.controller.ReloadRequiredWriteAttributeHandler;
import org.jboss.as.controller.ServiceRemoveStepHandler;
Expand Down Expand Up @@ -74,9 +73,8 @@ public void registerChildren(ManagementResourceRegistration resourceRegistration

@Override
public void registerAttributes(ManagementResourceRegistration resourceRegistration) {
OperationStepHandler writeHandler = new ReloadRequiredWriteAttributeHandler(ATTRIBUTES);
for (AttributeDefinition attribute : ATTRIBUTES) {
resourceRegistration.registerReadWriteAttribute(attribute, null, writeHandler);
resourceRegistration.registerReadWriteAttribute(attribute, null, ReloadRequiredWriteAttributeHandler.INSTANCE);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -46,10 +46,6 @@
*/
class RemoteOutboundConnectionAdd extends AbstractAddStepHandler {

RemoteOutboundConnectionAdd() {
super(RemoteOutboundConnectionResourceDefinition.ATTRIBUTES);
}

@Override
protected void performRuntime(OperationContext context, ModelNode operation, Resource resource) throws OperationFailedException {
final ModelNode fullModel = Resource.Tools.readModel(resource);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@
import java.util.List;

import org.jboss.as.controller.AttributeDefinition;
import org.jboss.as.controller.OperationStepHandler;
import org.jboss.as.controller.PathElement;
import org.jboss.as.controller.ReloadRequiredWriteAttributeHandler;
import org.jboss.as.controller.ServiceRemoveStepHandler;
Expand Down Expand Up @@ -108,9 +107,8 @@ public void registerChildren(ManagementResourceRegistration resourceRegistration

@Override
public void registerAttributes(ManagementResourceRegistration resourceRegistration) {
OperationStepHandler writeHandler = new ReloadRequiredWriteAttributeHandler(ATTRIBUTES);
for (AttributeDefinition attribute : ATTRIBUTES) {
resourceRegistration.registerReadWriteAttribute(attribute, null, writeHandler);
resourceRegistration.registerReadWriteAttribute(attribute, null, ReloadRequiredWriteAttributeHandler.INSTANCE);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -49,10 +49,6 @@
*/
class RemotingSubsystemAdd extends AbstractAddStepHandler {

RemotingSubsystemAdd() {
super(RemotingSubsystemRootResource.ATTRIBUTES);
}

@Override
protected void performRuntime(OperationContext context, ModelNode operation, Resource resource) throws OperationFailedException {
// DomainServerCommunicationServices will already have created this service if the server group has {@link org.jboss.as.controller.descriptions.ModelDescriptionConstants#MANAGEMENT_SUBSYSTEM_ENDPOINT} enabled.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@
import org.jboss.as.controller.AttributeDefinition;
import org.jboss.as.controller.OperationContext;
import org.jboss.as.controller.OperationFailedException;
import org.jboss.as.controller.OperationStepHandler;
import org.jboss.as.controller.PathElement;
import org.jboss.as.controller.ReloadRequiredRemoveStepHandler;
import org.jboss.as.controller.ReloadRequiredWriteAttributeHandler;
Expand Down Expand Up @@ -119,9 +118,8 @@ public class RemotingSubsystemRootResource extends SimpleResourceDefinition {
public void registerAttributes(ManagementResourceRegistration resourceRegistration) {
resourceRegistration.registerReadWriteAttribute(WORKER, null, new WorkerAttributeWriteHandler());

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

Expand All @@ -138,10 +136,6 @@ private static OptionAttributeDefinition createOptionAttribute(String name, Opti

private static class WorkerAttributeWriteHandler extends ReloadRequiredWriteAttributeHandler {

WorkerAttributeWriteHandler() {
super(WORKER);
}

@Override
protected void finishModelStage(OperationContext context, ModelNode operation, String attributeName, ModelNode newValue,
ModelNode oldValue, Resource model) throws OperationFailedException {
Expand Down

0 comments on commit 11a9840

Please sign in to comment.