use of org.jboss.as.controller.AbstractRemoveStepHandler in project wildfly by wildfly.
the class PropertyResourceDefinition method register.
@Override
public void register(ManagementResourceRegistration parentRegistration) {
ManagementResourceRegistration registration = parentRegistration.registerSubModel(this);
// Delegate add of property to "properties" attribute of parent protocol
AbstractAddStepHandler addHandler = new AbstractAddStepHandler() {
@Override
public void execute(OperationContext context, ModelNode operation) {
this.createResource(context);
String name = context.getCurrentAddressValue();
String value = operation.get(VALUE.getName()).asString();
PathAddress storeAddress = context.getCurrentAddress().getParent();
ModelNode putOperation = Operations.createMapPutOperation(storeAddress, AbstractProtocolResourceDefinition.Attribute.PROPERTIES, name, value);
context.addStep(putOperation, MapOperations.MAP_PUT_HANDLER, context.getCurrentStage());
}
};
this.registerAddOperation(registration, addHandler);
// Delegate remove of property to "properties" attribute of parent protocol
AbstractRemoveStepHandler removeHandler = new AbstractRemoveStepHandler() {
@Override
public void execute(OperationContext context, ModelNode operation) {
context.removeResource(PathAddress.EMPTY_ADDRESS);
String name = context.getCurrentAddressValue();
PathAddress storeAddress = context.getCurrentAddress().getParent();
ModelNode putOperation = Operations.createMapRemoveOperation(storeAddress, AbstractProtocolResourceDefinition.Attribute.PROPERTIES, name);
context.addStep(putOperation, MapOperations.MAP_REMOVE_HANDLER, context.getCurrentStage());
}
};
this.registerRemoveOperation(registration, removeHandler);
// Delegate read of property value to "properties" attribute of parent protocol
OperationStepHandler readHandler = new OperationStepHandler() {
@Override
public void execute(OperationContext context, ModelNode operation) {
PathAddress address = context.getCurrentAddress().getParent();
String key = context.getCurrentAddressValue();
ModelNode getOperation = Operations.createMapGetOperation(address, AbstractProtocolResourceDefinition.Attribute.PROPERTIES, key);
context.addStep(getOperation, MapOperations.MAP_GET_HANDLER, context.getCurrentStage());
}
};
// Delegate write of property value to "properties" attribute of parent protocol
OperationStepHandler writeHandler = new OperationStepHandler() {
@Override
public void execute(OperationContext context, ModelNode operation) {
PathAddress address = context.getCurrentAddress().getParent();
String key = context.getCurrentAddressValue();
String value = Operations.getAttributeValue(operation).asString();
ModelNode putOperation = Operations.createMapPutOperation(address, AbstractProtocolResourceDefinition.Attribute.PROPERTIES, key, value);
context.addStep(putOperation, MapOperations.MAP_PUT_HANDLER, context.getCurrentStage());
}
};
registration.registerReadWriteAttribute(VALUE, readHandler, writeHandler);
}
use of org.jboss.as.controller.AbstractRemoveStepHandler in project wildfly by wildfly.
the class StorePropertyResourceDefinition method register.
@Override
public void register(ManagementResourceRegistration parentRegistration) {
ManagementResourceRegistration registration = parentRegistration.registerSubModel(this);
AbstractAddStepHandler addHandler = new AbstractAddStepHandler() {
@Override
public void execute(OperationContext context, ModelNode operation) {
context.createResource(PathAddress.EMPTY_ADDRESS);
String name = context.getCurrentAddressValue();
String value = operation.get(VALUE.getName()).asString();
PathAddress storeAddress = context.getCurrentAddress().getParent();
ModelNode putOperation = Operations.createMapPutOperation(storeAddress, StoreResourceDefinition.Attribute.PROPERTIES, name, value);
context.addStep(putOperation, MapOperations.MAP_PUT_HANDLER, context.getCurrentStage());
}
};
this.registerAddOperation(registration, addHandler);
AbstractRemoveStepHandler removeHandler = new AbstractRemoveStepHandler() {
@Override
public void execute(OperationContext context, ModelNode operation) {
context.removeResource(PathAddress.EMPTY_ADDRESS);
String name = context.getCurrentAddressValue();
PathAddress storeAddress = context.getCurrentAddress().getParent();
ModelNode putOperation = Operations.createMapRemoveOperation(storeAddress, StoreResourceDefinition.Attribute.PROPERTIES, name);
context.addStep(putOperation, MapOperations.MAP_REMOVE_HANDLER, context.getCurrentStage());
}
};
this.registerRemoveOperation(registration, removeHandler);
OperationStepHandler readHandler = new OperationStepHandler() {
@Override
public void execute(OperationContext context, ModelNode operation) {
PathAddress address = context.getCurrentAddress().getParent();
String key = context.getCurrentAddressValue();
ModelNode getOperation = Operations.createMapGetOperation(address, StoreResourceDefinition.Attribute.PROPERTIES, key);
context.addStep(getOperation, MapOperations.MAP_GET_HANDLER, context.getCurrentStage());
}
};
OperationStepHandler writeHandler = new OperationStepHandler() {
@Override
public void execute(OperationContext context, ModelNode operation) {
PathAddress address = context.getCurrentAddress().getParent();
String key = context.getCurrentAddressValue();
String value = Operations.getAttributeValue(operation).asString();
ModelNode putOperation = Operations.createMapPutOperation(address, StoreResourceDefinition.Attribute.PROPERTIES, key, value);
context.addStep(putOperation, MapOperations.MAP_PUT_HANDLER, context.getCurrentStage());
}
};
registration.registerReadWriteAttribute(VALUE, readHandler, writeHandler);
}
Aggregations