Source:
<code>public void registerAttributes(ManagementResourceRegistration registration) { final OperationStepHandler writeHandler = new ReloadRequiredWriteAttributeHandler(ATTRIBUTES); for (AttributeDefinition attr : ATTRIBUTES) { registration.registerReadWriteAttribute(attr, null, writeHandler); } OperationStepHandler typeReadHandler = new OperationStepHandler() { @Override public void execute(OperationContext context, ModelNode operation) throws OperationFailedException { context.getResult().set(context.getCurrentAddressValue()); } }; OperationStepHandler typeWriteHandler = new OperationStepHandler() { @Override public void execute(OperationContext context, ModelNode operation) throws OperationFailedException { String type = Operations.getAttributeValue(operation).asString(); PathAddress address = context.getCurrentAddress(); ModelNode removeOperation = Util.createRemoveOperation(address); context.addStep(removeOperation, context.getResourceRegistration().getOperationHandler(PathAddress.EMPTY_ADDRESS, ModelDescriptionConstants.REMOVE), context.getCurrentStage()); PathAddress newAddress = address.getParent().append(PathElement.pathElement(address.getLastElement().getKey(), type)); ModelNode addOperation = Util.createAddOperation(newAddress); for (Property property : context.readResource(PathAddress.EMPTY_ADDRESS, false).getModel().asPropertyList()) { addOperation.get(property.getName()).set(property.getValue()); } <START> context.addStep(addOperation, context.getRootResourceRegistration().getOperationHandler(newAddress, ModelDescriptionConstants.ADD), context.getCurrentStage()); <END> } }; registration.registerReadWriteAttribute(TYPE, typeReadHandler, typeWriteHandler); }</code><technical_language>I recommend include "addFirst" param context.addStep calls, a of "true". This ensure if this op is part of a composite op, remove + add execute next step in composite, maintaining logical sequence of composite. is now, new steps happen steps in composite. Note switch order in add steps, i.e. add remove. "addFirst=true" call is effectively putting steps front of queue, end of a queue</technical_language>

Target:
public void registerAttributes(ManagementResourceRegistration registration) { final OperationStepHandler writeHandler = new ReloadRequiredWriteAttributeHandler(ATTRIBUTES); for (AttributeDefinition attr : ATTRIBUTES) { registration.registerReadWriteAttribute(attr, null, writeHandler); } OperationStepHandler typeReadHandler = new OperationStepHandler() { @Override public void execute(OperationContext context, ModelNode operation) throws OperationFailedException { context.getResult().set(context.getCurrentAddressValue()); } }; OperationStepHandler typeWriteHandler = new OperationStepHandler() { @Override public void execute(OperationContext context, ModelNode operation) throws OperationFailedException { String type = Operations.getAttributeValue(operation).asString(); PathAddress address = context.getCurrentAddress(); PathAddress newAddress = address.getParent().append(PathElement.pathElement(address.getLastElement().getKey(), type)); ModelNode addOperation = Util.createAddOperation(newAddress); for (Property property : context.readResource(PathAddress.EMPTY_ADDRESS, false).getModel().asPropertyList()) { addOperation.get(property.getName()).set(property.getValue()); } context.addStep(addOperation, context.getRootResourceRegistration().getOperationHandler(newAddress, ModelDescriptionConstants.ADD), context.getCurrentStage(), true); ModelNode removeOperation = Util.createRemoveOperation(address); context.addStep(removeOperation, context.getResourceRegistration().getOperationHandler(PathAddress.EMPTY_ADDRESS, ModelDescriptionConstants.REMOVE), context.getCurrentStage(), true); } }; registration.registerReadWriteAttribute(TYPE, typeReadHandler, typeWriteHandler); }