Source:
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()); } context.addStep(addOperation, context.getRootResourceRegistration().getOperationHandler(newAddress, ModelDescriptionConstants.ADD), context.getCurrentStage()); } }; registration.registerReadWriteAttribute(TYPE, typeReadHandler, typeWriteHandler); }

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); }