diff --git a/clustering/common/src/main/java/org/jboss/as/clustering/controller/transform/ChainedOperationTransformer.java b/clustering/common/src/main/java/org/jboss/as/clustering/controller/transform/ChainedOperationTransformer.java index 75a363941526..9d4e3072c5e5 100644 --- a/clustering/common/src/main/java/org/jboss/as/clustering/controller/transform/ChainedOperationTransformer.java +++ b/clustering/common/src/main/java/org/jboss/as/clustering/controller/transform/ChainedOperationTransformer.java @@ -70,21 +70,21 @@ public ChainedOperationTransformer(List transformers, bool */ @Override public TransformedOperation transformOperation(TransformationContext context, PathAddress address, ModelNode originalOperation) throws OperationFailedException { - String originalName = originalOperation.get(ModelDescriptionConstants.OP).asString(); - ModelNode originalAddress = originalOperation.get(ModelDescriptionConstants.OP_ADDR); + String originalName = Operations.getName(originalOperation); + PathAddress originalAddress = Operations.getPathAddress(originalOperation); Deque preSteps = new LinkedList<>(); Deque postSteps = new LinkedList<>(); ModelNode operation = originalOperation; for (OperationTransformer transformer: this.transformers) { operation = transformer.transformOperation(context, address, operation).getTransformedOperation(); // If the transformed operation is a composite operation, locate the modified operation and record any pre/post operations - if (collate && operation.get(ModelDescriptionConstants.OP).asString().equals(ModelDescriptionConstants.COMPOSITE)) { + if (this.collate && operation.get(ModelDescriptionConstants.OP).asString().equals(ModelDescriptionConstants.COMPOSITE)) { List stepList = operation.get(ModelDescriptionConstants.STEPS).asList(); ListIterator steps = stepList.listIterator(); while (steps.hasNext()) { ModelNode step = steps.next(); - String operationName = step.get(ModelDescriptionConstants.OP).asString(); - ModelNode operationAddress = step.get(ModelDescriptionConstants.OP_ADDR); + String operationName = Operations.getName(step); + PathAddress operationAddress = Operations.getPathAddress(step); if (operationName.equals(originalName) && operationAddress.equals(originalAddress)) { operation = step; break; @@ -94,8 +94,8 @@ public TransformedOperation transformOperation(TransformationContext context, Pa steps = stepList.listIterator(stepList.size()); while (steps.hasPrevious()) { ModelNode step = steps.previous(); - String operationName = step.get(ModelDescriptionConstants.OP).asString(); - ModelNode operationAddress = step.get(ModelDescriptionConstants.OP_ADDR); + String operationName = Operations.getName(step); + PathAddress operationAddress = Operations.getPathAddress(step); if (operationName.equals(originalName) && operationAddress.equals(originalAddress)) { break; } @@ -103,7 +103,7 @@ public TransformedOperation transformOperation(TransformationContext context, Pa } } } - if (collate) { + if (this.collate) { int count = preSteps.size() + postSteps.size() + 1; // If there are any pre or post steps, we need a composite operation if (count > 1) { diff --git a/clustering/common/src/main/java/org/jboss/as/clustering/controller/transform/InitialAttributeValueOperationContextAttachment.java b/clustering/common/src/main/java/org/jboss/as/clustering/controller/transform/InitialAttributeValueOperationContextAttachment.java index 2e86689fd9d9..9c0ce93ed7a2 100644 --- a/clustering/common/src/main/java/org/jboss/as/clustering/controller/transform/InitialAttributeValueOperationContextAttachment.java +++ b/clustering/common/src/main/java/org/jboss/as/clustering/controller/transform/InitialAttributeValueOperationContextAttachment.java @@ -40,18 +40,17 @@ public class InitialAttributeValueOperationContextAttachment { public static final OperationContext.AttachmentKey INITIAL_VALUES_ATTACHMENT = OperationContext.AttachmentKey.create(InitialAttributeValueOperationContextAttachment.class); - private volatile Map initialValues = new HashMap<>(); + private final Map initialValues = new HashMap<>(); public ModelNode putIfAbsentInitialValue(PathAddress address, String attributeName, ModelNode initialValue) { - return initialValues.putIfAbsent(this.keyFor(address, attributeName), initialValue.clone()); + return this.initialValues.putIfAbsent(keyFor(address, attributeName), initialValue.clone()); } public ModelNode getInitialValue(PathAddress address, String attributeName) { - return initialValues.get(this.keyFor(address, attributeName)); + return this.initialValues.get(keyFor(address, attributeName)); } - - private String keyFor(PathAddress address, String attributeName) { - return address.toString() + attributeName; + private static PathAddress keyFor(PathAddress address, String attributeName) { + return address.append(attributeName); } } diff --git a/clustering/common/src/main/java/org/jboss/as/clustering/controller/transform/SimplePathOperationTransformer.java b/clustering/common/src/main/java/org/jboss/as/clustering/controller/transform/SimplePathOperationTransformer.java index 5b458c0f8b01..b02e9beef1f0 100644 --- a/clustering/common/src/main/java/org/jboss/as/clustering/controller/transform/SimplePathOperationTransformer.java +++ b/clustering/common/src/main/java/org/jboss/as/clustering/controller/transform/SimplePathOperationTransformer.java @@ -51,7 +51,7 @@ public TransformedOperation transformOperation(TransformationContext context, Pa if (attachment != null) { ModelNode value = attachment.getInitialValue(address, Operations.getAttributeName(operation)); if (value != null) { - attachment.putIfAbsentInitialValue(addressTransformer.transform(address), Operations.getAttributeName(operation), value); + attachment.putIfAbsentInitialValue(this.addressTransformer.transform(address), Operations.getAttributeName(operation), value); } } diff --git a/clustering/common/src/main/java/org/jboss/as/clustering/controller/transform/UndefinedAttributesDiscardPolicy.java b/clustering/common/src/main/java/org/jboss/as/clustering/controller/transform/UndefinedAttributesDiscardPolicy.java index e27413581054..974e5f8c5f77 100644 --- a/clustering/common/src/main/java/org/jboss/as/clustering/controller/transform/UndefinedAttributesDiscardPolicy.java +++ b/clustering/common/src/main/java/org/jboss/as/clustering/controller/transform/UndefinedAttributesDiscardPolicy.java @@ -22,6 +22,8 @@ package org.jboss.as.clustering.controller.transform; +import java.util.Collection; + import org.jboss.as.clustering.controller.Attribute; import org.jboss.as.controller.PathAddress; import org.jboss.as.controller.registry.Resource; @@ -39,16 +41,16 @@ */ public class UndefinedAttributesDiscardPolicy implements DynamicDiscardPolicy { - private final Iterable attributes; + private final Collection attributes; - public UndefinedAttributesDiscardPolicy(Iterable attributes) { + public UndefinedAttributesDiscardPolicy(Collection attributes) { this.attributes = attributes; } @Override public DiscardPolicy checkResource(TransformationContext context, PathAddress address) { ModelNode model = Resource.Tools.readModel(context.readResourceFromRoot(address)); - for (Attribute attribute : attributes) { + for (Attribute attribute : this.attributes) { if (model.hasDefined(attribute.getDefinition().getName())) { return DiscardPolicy.REJECT_AND_WARN; }