private static class DataSourcesSubsystemDescribeHandler implements OperationStepHandler, DescriptionProvider {
static final DataSourcesSubsystemDescribeHandler INSTANCE = new DataSourcesSubsystemDescribeHandler();
public void execute(OperationContext context, ModelNode operation) throws OperationFailedException {
final ModelNode result = context.getResult();
final PathAddress rootAddress = PathAddress.pathAddress(PathAddress.pathAddress(operation.require(OP_ADDR))
.getLastElement());
final ModelNode subModel = context.readModel(PathAddress.EMPTY_ADDRESS);
final ModelNode subsystemAdd = new ModelNode();
subsystemAdd.get(OP).set(ADD);
subsystemAdd.get(OP_ADDR).set(rootAddress.toModelNode());
result.add(subsystemAdd);
if (subModel.hasDefined(JDBC_DRIVER)) {
for (final Property jdbcDriver : subModel.get(Constants.JDBC_DRIVER).asPropertyList()) {
final ModelNode address = rootAddress.toModelNode();
address.add(Constants.JDBC_DRIVER, jdbcDriver.getName());
final ModelNode addOperation = Util.getEmptyOperation(ADD, address);
addOperation.get(DRIVER_NAME).set(jdbcDriver.getValue().get(DRIVER_NAME));
addOperation.get(DRIVER_MODULE_NAME).set(jdbcDriver.getValue().get(DRIVER_MODULE_NAME));
addOperation.get(DRIVER_MAJOR_VERSION).set(jdbcDriver.getValue().get(DRIVER_MAJOR_VERSION));
addOperation.get(DRIVER_MINOR_VERSION).set(jdbcDriver.getValue().get(DRIVER_MINOR_VERSION));
addOperation.get(DRIVER_CLASS_NAME).set(jdbcDriver.getValue().get(DRIVER_CLASS_NAME));
addOperation.get(DRIVER_XA_DATASOURCE_CLASS_NAME).set(
jdbcDriver.getValue().get(DRIVER_XA_DATASOURCE_CLASS_NAME));
result.add(addOperation);
}
}
if (subModel.hasDefined(DATA_SOURCE)) {
for (final Property dataSourceProp : subModel.get(Constants.DATA_SOURCE).asPropertyList()) {
final ModelNode address = rootAddress.toModelNode();
address.add(Constants.DATA_SOURCE, dataSourceProp.getName());
final ModelNode addOperation = Util.getEmptyOperation(ADD, address);
final ModelNode dataSource = dataSourceProp.getValue();
populateAddModel(dataSource, addOperation, CONNECTION_PROPERTIES, DATASOURCE_ATTRIBUTE);
addOperation.get(DATASOURCE_DRIVER).set(dataSourceProp.getValue().get(DATASOURCE_DRIVER));
result.add(addOperation);
}
}
if (subModel.hasDefined(XA_DATA_SOURCE)) {
for (final Property dataSourceProp : subModel.get(Constants.XA_DATA_SOURCE).asPropertyList()) {
final ModelNode address = rootAddress.toModelNode();
address.add(Constants.XA_DATA_SOURCE, dataSourceProp.getName());
final ModelNode addOperation = Util.getEmptyOperation(ADD, address);
final ModelNode dataSource = dataSourceProp.getValue();
populateAddModel(dataSource, addOperation, XADATASOURCEPROPERTIES, XA_DATASOURCE_ATTRIBUTE);