@Override protected void describe(OrderedChildTypesAttachment orderedChildTypesAttachment, Resource resource, ModelNode addressModel, ModelNode result, ImmutableManagementResourceRegistration registration) { if (resource == null || registration.isRemote() || registration.isRuntimeOnly() || resource.isProxy() || resource.isRuntime() || registration.isAlias()) return; result.add(createAddOperation(orderedChildTypesAttachment, addressModel, resource, registration.getChildAddresses(PathAddress.EMPTY_ADDRESS))); PathAddress address = PathAddress.pathAddress(addressModel); for (String type : resource.getChildTypes()) { for (Resource.ResourceEntry entry : resource.getChildren(type)) { PathElement path = entry.getPathElement(); ImmutableManagementResourceRegistration childRegistration = Optional.ofNullable(registration.getSubModel(PathAddress.pathAddress(path))).orElse(registration.getSubModel(PathAddress.pathAddress(PathElement.pathElement(path.getKey())))); PathAddress childAddress = address.append(path); this.describe(orderedChildTypesAttachment, entry, childAddress.toModelNode(), result, childRegistration); } } }
/** * @return contextual discard policy if any resource attributes are undefined and has no children; {@link DiscardPolicy#SILENT} otherwise. */ @Override public DiscardPolicy checkResource(TransformationContext context, PathAddress address) { Resource resource = context.readResource(PathAddress.EMPTY_ADDRESS); ImmutableManagementResourceRegistration registration = context.getResourceRegistration(PathAddress.EMPTY_ADDRESS); ModelNode model = resource.getModel(); if (model.isDefined()) { for (String attribute : registration.getAttributeNames(PathAddress.EMPTY_ADDRESS)) { if (model.hasDefined(attribute)) { return this.policy; } } } for (PathElement path : registration.getChildAddresses(PathAddress.EMPTY_ADDRESS)) { if (path.isWildcard() ? resource.hasChildren(path.getKey()) : resource.hasChild(path)) { return this.policy; } } return DiscardPolicy.SILENT; } }
@Override public Set<PathElement> getChildAddresses(PathAddress address) { return delegate.getChildAddresses(address); }
@Override public Set<PathElement> getChildAddresses(PathAddress address) { return delegate.getChildAddresses(address); }
@Override public Set<PathElement> getChildAddresses(PathAddress address) { return delegate.getChildAddresses(address); }
@Override public Set<PathElement> getChildAddresses(PathAddress address) { return delegate.getChildAddresses(address); }
public static ModelNode readFullModelDescription(PathAddress address, ImmutableManagementResourceRegistration reg) { ModelNode node = new ModelNode(); node.get(ModelDescriptionConstants.MODEL_DESCRIPTION).set(reg.getModelDescription(PathAddress.EMPTY_ADDRESS).getModelDescription(Locale.getDefault())); node.get(ModelDescriptionConstants.ADDRESS).set(address.toModelNode()); for (PathElement pe : reg.getChildAddresses(PathAddress.EMPTY_ADDRESS)) { ModelNode children = node.get(ModelDescriptionConstants.CHILDREN); ImmutableManagementResourceRegistration sub = reg.getSubModel(PathAddress.pathAddress(pe)); children.add(readFullModelDescription(address.append(pe), sub)); } return node; }
static Map<PathElement, ChildAddOperationEntry> findAddChildOperations(ImmutableManagementResourceRegistration resourceRegistration){ Map<PathElement, ChildAddOperationEntry> operations = new HashMap<PathElement, ChildAddOperationEntry>(); for(PathElement childElement : resourceRegistration.getChildAddresses(PathAddress.EMPTY_ADDRESS)) { final ImmutableManagementResourceRegistration childReg = resourceRegistration.getSubModel(PathAddress.pathAddress(childElement)); final Map<String, OperationEntry> registeredOps = childReg.getOperationDescriptions(PathAddress.EMPTY_ADDRESS, false); final OperationEntry childAdd = registeredOps.get(ADD); if (childAdd != null) { operations.put(childElement, new ChildAddOperationEntry(childAdd, childElement)); } } return operations; }
public static ModelNode readFullModelDescription(PathAddress address, ImmutableManagementResourceRegistration reg) { ModelNode node = new ModelNode(); node.get(ModelDescriptionConstants.MODEL_DESCRIPTION).set(reg.getModelDescription(PathAddress.EMPTY_ADDRESS).getModelDescription(Locale.getDefault())); node.get(ModelDescriptionConstants.ADDRESS).set(address.toModelNode()); for (PathElement pe : reg.getChildAddresses(PathAddress.EMPTY_ADDRESS)) { ModelNode children = node.get(ModelDescriptionConstants.CHILDREN); ImmutableManagementResourceRegistration sub = reg.getSubModel(PathAddress.pathAddress(pe)); children.add(readFullModelDescription(address.append(pe), sub)); } return node; }
public static ModelNode readFullModelDescription(PathAddress address, ImmutableManagementResourceRegistration reg) { ModelNode node = new ModelNode(); node.get(ModelDescriptionConstants.MODEL_DESCRIPTION).set(reg.getModelDescription(PathAddress.EMPTY_ADDRESS).getModelDescription(Locale.getDefault())); node.get(ModelDescriptionConstants.ADDRESS).set(address.toModelNode()); for (PathElement pe : reg.getChildAddresses(PathAddress.EMPTY_ADDRESS)) { ModelNode children = node.get(ModelDescriptionConstants.CHILDREN); ImmutableManagementResourceRegistration sub = reg.getSubModel(PathAddress.pathAddress(pe)); children.add(readFullModelDescription(address.append(pe), sub)); } return node; }
static Map<PathElement, ChildAddOperationEntry> findAddChildOperations(ImmutableManagementResourceRegistration resourceRegistration){ Map<PathElement, ChildAddOperationEntry> operations = new HashMap<PathElement, ChildAddOperationEntry>(); for(PathElement childElement : resourceRegistration.getChildAddresses(PathAddress.EMPTY_ADDRESS)) { final ImmutableManagementResourceRegistration childReg = resourceRegistration.getSubModel(PathAddress.pathAddress(childElement)); final Map<String, OperationEntry> registeredOps = childReg.getOperationDescriptions(PathAddress.EMPTY_ADDRESS, false); final OperationEntry childAdd = registeredOps.get(ADD); if (childAdd != null) { operations.put(childElement, new ChildAddOperationEntry(childAdd, childElement)); } } return operations; }
public static ModelNode readFullModelDescription(PathAddress address, ImmutableManagementResourceRegistration reg) { ModelNode node = new ModelNode(); node.get(ModelDescriptionConstants.MODEL_DESCRIPTION).set(reg.getModelDescription(PathAddress.EMPTY_ADDRESS).getModelDescription(Locale.getDefault())); node.get(ModelDescriptionConstants.ADDRESS).set(address.toModelNode()); for (PathElement pe : reg.getChildAddresses(PathAddress.EMPTY_ADDRESS)) { ModelNode children = node.get(ModelDescriptionConstants.CHILDREN); ImmutableManagementResourceRegistration sub = reg.getSubModel(PathAddress.pathAddress(pe)); children.add(readFullModelDescription(address.append(pe), sub)); } return node; }
private static Set<String> getNonIgnoredChildTypes(ImmutableManagementResourceRegistration mrr) { Set<String> result = new HashSet<>(); for (PathElement pe : mrr.getChildAddresses(PathAddress.EMPTY_ADDRESS)) { ImmutableManagementResourceRegistration childMrr = mrr.getSubModel(PathAddress.pathAddress(pe)); if (childMrr != null && !childMrr.isRemote() && !childMrr.isRuntimeOnly()) { result.add(pe.getKey()); } } return result; }
private static Set<String> getNonIgnoredChildTypes(ImmutableManagementResourceRegistration mrr) { Set<String> result = new HashSet<>(); for (PathElement pe : mrr.getChildAddresses(PathAddress.EMPTY_ADDRESS)) { ImmutableManagementResourceRegistration childMrr = mrr.getSubModel(PathAddress.pathAddress(pe)); if (childMrr != null && !childMrr.isRemote() && !childMrr.isRuntimeOnly()) { result.add(pe.getKey()); } } return result; }
static ChildAddOperationEntry findAddChildOperation(ImmutableManagementResourceRegistration resourceRegistration, String addName){ for(PathElement childElement : resourceRegistration.getChildAddresses(PathAddress.EMPTY_ADDRESS)) { final ImmutableManagementResourceRegistration childReg = resourceRegistration.getSubModel(PathAddress.pathAddress(childElement)); final Map<String, OperationEntry> registeredOps = childReg.getOperationDescriptions(PathAddress.EMPTY_ADDRESS, false); final OperationEntry childAdd = registeredOps.get(ADD); if (childAdd != null) { if (NameConverter.createValidAddOperationName(childElement).equals(addName)) { return new ChildAddOperationEntry(childAdd, childElement); } } } return null; }
static ChildAddOperationEntry findAddChildOperation(ImmutableManagementResourceRegistration resourceRegistration, String addName){ for(PathElement childElement : resourceRegistration.getChildAddresses(PathAddress.EMPTY_ADDRESS)) { final ImmutableManagementResourceRegistration childReg = resourceRegistration.getSubModel(PathAddress.pathAddress(childElement)); final Map<String, OperationEntry> registeredOps = childReg.getOperationDescriptions(PathAddress.EMPTY_ADDRESS, false); final OperationEntry childAdd = registeredOps.get(ADD); if (childAdd != null) { if (NameConverter.createValidAddOperationName(childElement).equals(addName)) { return new ChildAddOperationEntry(childAdd, childElement); } } } return null; }
private boolean isGlobalAlias(final ImmutableManagementResourceRegistration registry, final String childName) { if(isSingletonResource(registry, childName)) { Set<PathElement> childrenPath = registry.getChildAddresses(PathAddress.EMPTY_ADDRESS); boolean found = false; boolean alias = true; for(PathElement childPath : childrenPath) { if(childPath.getKey().equals(childName)) { found = true; ImmutableManagementResourceRegistration squatterRegistration = registry.getSubModel(PathAddress.pathAddress(childPath)); alias = alias && (squatterRegistration != null && squatterRegistration.isAlias()); } } return (found && alias); } return registry.getSubModel(PathAddress.pathAddress(PathElement.pathElement(childName))).isAlias(); }
public static Model readModel(final ImmutableManagementResourceRegistration def, final PathAddress address) { Model res = new Model(address); Set<String> attributesList = def.getAttributeNames(PathAddress.EMPTY_ADDRESS); for (String name : attributesList) { res.addAttribute(name); } for (PathElement element : def.getChildAddresses(PathAddress.EMPTY_ADDRESS)) { final ImmutableManagementResourceRegistration child = def.getSubModel(PathAddress.pathAddress(element)); if (child != null) { res.addChild(readModel(child, address.append(element))); } } return res; }
public static Model readModel(final ImmutableManagementResourceRegistration def, final PathAddress address) { Model res = new Model(address); Set<String> attributesList = def.getAttributeNames(PathAddress.EMPTY_ADDRESS); for (String name : attributesList) { res.addAttribute(name); } for (PathElement element : def.getChildAddresses(PathAddress.EMPTY_ADDRESS)) { final ImmutableManagementResourceRegistration child = def.getSubModel(PathAddress.pathAddress(element)); if (child != null) { res.addChild(readModel(child, address.append(element))); } } return res; }
@Override protected void describe(OrderedChildTypesAttachment orderedChildTypesAttachment, Resource resource, ModelNode addressModel, ModelNode result, ImmutableManagementResourceRegistration registration) { if (resource == null || registration.isRemote() || registration.isRuntimeOnly() || resource.isProxy() || resource.isRuntime() || registration.isAlias()) return; result.add(createAddOperation(orderedChildTypesAttachment, addressModel, resource, registration.getChildAddresses(PathAddress.EMPTY_ADDRESS))); PathAddress address = PathAddress.pathAddress(addressModel); for (String type : resource.getChildTypes()) { for (Resource.ResourceEntry entry : resource.getChildren(type)) { PathElement path = entry.getPathElement(); ImmutableManagementResourceRegistration childRegistration = Optional.ofNullable(registration.getSubModel(PathAddress.pathAddress(path))).orElse(registration.getSubModel(PathAddress.pathAddress(PathElement.pathElement(path.getKey())))); PathAddress childAddress = address.append(path); this.describe(orderedChildTypesAttachment, entry, childAddress.toModelNode(), result, childRegistration); } } }