PathAddressConfigRegistry getOrCreateConfig(PathElement element) { if (element.isWildcard()) { PathAddressConfigRegistry reg = wildcardChildren.get(element.getKey()); if (reg == null) { reg = new PathAddressConfigRegistry(); wildcardChildren.put(element.getKey(), reg); } return reg; } else { PathAddressConfigRegistry reg = children.get(element); if (reg == null) { reg = new PathAddressConfigRegistry(); children.put(element, reg); } return reg; } }
void addConfig(Iterator<PathElement> address, PathAddressConfig config) { if (address.hasNext()) { PathAddressConfigRegistry child = getOrCreateConfig(address.next()); child.addConfig(address, config); } else { this.config = config; } }
PathAddressConfig getConfig(Iterator<PathElement> address) { if (address.hasNext()) { PathElement element = address.next(); PathAddressConfigRegistry child = children.get(element); if (child == null) { child = wildcardChildren.get(element.getKey()); } if (child != null) { return child.getConfig(address); } return null; } else { return config; } }
PathAddressConfig getConfig(ModelNode operation) { return getConfig(PathAddress.pathAddress(operation.get(OP_ADDR)).iterator()); }
ModelNode correctOperation(ModelNode operation) { PathAddressConfig cfg = registry.getConfig(operation); if (cfg == null) { throw new IllegalStateException("No path address config found for " + PathAddress.pathAddress(operation.get(OP_ADDR))); } operation = cfg.correctOperation(operation); return operation; }
boolean expectFailed(ModelNode operation) { PathAddressConfig cfg = registry.getConfig(operation); if (cfg == null) { return false; } if (cfg.expectFailed(operation)) { return true; } return false; }
boolean canCorrectMore(ModelNode operation) { PathAddressConfig cfg = registry.getConfig(operation); if (cfg == null) { return false; } if (cfg.canCorrectMore(operation)) { return true; } return false; }
boolean expectDiscarded(ModelNode operation) { PathAddressConfig cfg = registry.getConfig(operation); if (cfg == null) { return false; } if (cfg.expectDiscarded(operation)) { return true; } return false; }
/** * Add a handler for failed operation transformers at a resource address * * @param pathAddress the path address * @param config the config * @return this config */ public FailedOperationTransformationConfig addFailedAttribute(PathAddress pathAddress, PathAddressConfig config) { registry.addConfig(pathAddress.iterator(), config); return this; }
ModelNode correctWriteAttributeOperation(ModelNode operation) { PathAddressConfig cfg = registry.getConfig(operation); if (cfg == null) { return operation; } return cfg.correctWriteAttributeOperation(operation); }
public void operationDone(ModelNode operation) { PathAddressConfig cfg = registry.getConfig(operation); if (cfg == null) { return; } cfg.operationDone(operation); }
List<ModelNode> createWriteAttributeOperations(ModelNode operation) { PathAddressConfig cfg = registry.getConfig(operation); if (cfg == null || !operation.get(OP).asString().equals(ADD)) { return Collections.emptyList(); } return cfg.createWriteAttributeOperations(operation); }
boolean expectFailedWriteAttributeOperation(ModelNode operation) { PathAddressConfig cfg = registry.getConfig(operation); if (cfg == null) { return false; } return cfg.expectFailedWriteAttributeOperation(operation); }