@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); } } }
@Override public boolean isAlias() { return delegate.isAlias(); }
@Override public boolean isAlias() { return delegate.isAlias(); }
@Override public boolean isAlias() { return delegate.isAlias(); }
@Override public boolean isAlias() { return delegate.isAlias(); }
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(); }
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(); }
found = true; ImmutableManagementResourceRegistration squatterRegistration = registry.getSubModel(PathAddress.pathAddress(childPath)); alias = alias && (squatterRegistration != null && squatterRegistration.isAlias()); return squatterRegistration != null && squatterRegistration.isAlias(); boolean isAlias = wildCardChildRegistration.isAlias(); Set<String> registredNames = registry.getChildNames(PathAddress.pathAddress(PathElement.pathElement(key))); if (registredNames != null && !registredNames.isEmpty() && isAlias) { for (String value : registredNames) { ImmutableManagementResourceRegistration childRegistration = registry.getSubModel(PathAddress.pathAddress(PathElement.pathElement(key, value))); isAlias = isAlias && childRegistration != null && childRegistration.isAlias(); if(!isAlias) { return false;
protected void describe(final OrderedChildTypesAttachment orderedChildTypesAttachment, final Resource resource, final ModelNode address, ModelNode result, final ImmutableManagementResourceRegistration registration) { if(resource == null || registration.isRemote() || registration.isRuntimeOnly() || resource.isProxy() || resource.isRuntime() || registration.isAlias()) { return;
protected void describe(final OrderedChildTypesAttachment orderedChildTypesAttachment, final Resource resource, final ModelNode address, ModelNode result, final ImmutableManagementResourceRegistration registration) { if(resource == null || registration.isRemote() || registration.isRuntimeOnly() || resource.isProxy() || resource.isRuntime() || registration.isAlias()) { return;
@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); } } }
@Override public void execute(OperationContext context, ModelNode operation) throws OperationFailedException { final ImmutableManagementResourceRegistration registry = context.getResourceRegistration(); if (registry == null) { throw new OperationFailedException(ControllerLogger.ROOT_LOGGER.noSuchResourceType(context.getCurrentAddress())); } final boolean aliases = INCLUDE_ALIASES.resolveModelAttribute(context, operation).asBoolean(false); final boolean singletons = INCLUDE_SINGLETONS.resolveModelAttribute(context, operation).asBoolean(false); Set<PathElement> childTypes = registry.getChildAddresses(PathAddress.EMPTY_ADDRESS); Set<String> children = new TreeSet<String>(); for (final PathElement child : childTypes) { PathAddress relativeAddr = PathAddress.pathAddress(child); ImmutableManagementResourceRegistration childReg = registry.getSubModel(relativeAddr); boolean isSingletonResource = childReg == null || !child.isWildcard(); if (childReg.isAlias() && !aliases) { continue; } if(singletons && isSingletonResource) { children.add(child.getKey() + '=' + child.getValue()); } else { children.add(child.getKey()); } } final ModelNode result = context.getResult(); result.setEmptyList(); for(String child : children) { result.add(child); } } }
@Override public OperationTransformer.TransformedOperation transformOperation(final TransformationContext context, final ModelNode operation) throws OperationFailedException { final PathAddress address = PathAddress.pathAddress(operation.require(OP_ADDR)); //If this is an alias, get the real address before transforming ImmutableManagementResourceRegistration reg = context.getResourceRegistration(address); final PathAddress useAddress; if (reg != null && reg.isAlias()) { useAddress = reg.getAliasEntry().convertToTargetAddress(address, AliasEntry.AliasContext.create(operation, context)); } else { useAddress = address; } final String operationName = operation.require(OP).asString(); TransformationContext opCtx = ResourceTransformationContextImpl.wrapForOperation(context, operation); final OperationTransformer transformer = target.resolveTransformer(opCtx, useAddress, operationName); if (transformer == null) { ControllerLogger.ROOT_LOGGER.tracef("operation %s does not need transformation", operation); return new OperationTransformer.TransformedOperation(operation, OperationResultTransformer.ORIGINAL_RESULT); } // Transform the path address final PathAddress transformed = transformAddress(useAddress, target); // Update the operation using the new path address operation.get(OP_ADDR).set(transformed.toModelNode()); // TODO should this happen by default? OperationTransformer.TransformedOperation res = transformer.transformOperation(opCtx, transformed, operation); context.getLogger().flushLogQueue(); return res; }
@Override public OperationTransformer.TransformedOperation transformOperation(final TransformationContext context, final ModelNode operation) throws OperationFailedException { final PathAddress address = PathAddress.pathAddress(operation.require(OP_ADDR)); //If this is an alias, get the real address before transforming ImmutableManagementResourceRegistration reg = context.getResourceRegistration(address); final PathAddress useAddress; if (reg != null && reg.isAlias()) { useAddress = reg.getAliasEntry().convertToTargetAddress(address, AliasEntry.AliasContext.create(operation, context)); } else { useAddress = address; } final String operationName = operation.require(OP).asString(); TransformationContext opCtx = ResourceTransformationContextImpl.wrapForOperation(context, operation); final OperationTransformer transformer = target.resolveTransformer(opCtx, useAddress, operationName); if (transformer == null) { ControllerLogger.ROOT_LOGGER.tracef("operation %s does not need transformation", operation); return new OperationTransformer.TransformedOperation(operation, OperationResultTransformer.ORIGINAL_RESULT); } // Transform the path address final PathAddress transformed = transformAddress(useAddress, target); // Update the operation using the new path address operation.get(OP_ADDR).set(transformed.toModelNode()); // TODO should this happen by default? OperationTransformer.TransformedOperation res = transformer.transformOperation(opCtx, transformed, operation); context.getLogger().flushLogQueue(); return res; }
@Override public OperationTransformer.TransformedOperation transformOperation(final TransformationInputs transformationInputs, final ModelNode operation) throws OperationFailedException { final PathAddress original = PathAddress.pathAddress(operation.require(OP_ADDR)); //If this is an alias, get the real address before transforming ImmutableManagementResourceRegistration reg = transformationInputs.getRootRegistration().getSubModel(original); final PathAddress useAddress; if (reg != null && reg.isAlias()) { useAddress = reg.getAliasEntry().convertToTargetAddress(original, AliasEntry.AliasContext.create(operation, transformationInputs)); } else { useAddress = original; } final String operationName = operation.require(OP).asString(); // Transform the path address final PathAddress transformed = transformAddress(useAddress, target); // Update the operation using the new path address operation.get(OP_ADDR).set(transformed.toModelNode()); // TODO should this happen by default? final TransformationContext context = ResourceTransformationContextImpl.create(transformationInputs, target, transformed, original, Transformers.DEFAULT); final OperationTransformer transformer = target.resolveTransformer(context, useAddress, operationName); if (transformer == null) { ControllerLogger.ROOT_LOGGER.tracef("operation %s does not need transformation", operation); return new OperationTransformer.TransformedOperation(operation, OperationResultTransformer.ORIGINAL_RESULT); } final OperationTransformer.TransformedOperation op = transformer.transformOperation(context, transformed, operation); context.getLogger().flushLogQueue(); return op; }
@Override public OperationTransformer.TransformedOperation transformOperation(final TransformationInputs transformationInputs, final ModelNode operation) throws OperationFailedException { final PathAddress original = PathAddress.pathAddress(operation.require(OP_ADDR)); //If this is an alias, get the real address before transforming ImmutableManagementResourceRegistration reg = transformationInputs.getRootRegistration().getSubModel(original); final PathAddress useAddress; if (reg != null && reg.isAlias()) { useAddress = reg.getAliasEntry().convertToTargetAddress(original, AliasEntry.AliasContext.create(operation, transformationInputs)); } else { useAddress = original; } final String operationName = operation.require(OP).asString(); // Transform the path address final PathAddress transformed = transformAddress(useAddress, target); // Update the operation using the new path address operation.get(OP_ADDR).set(transformed.toModelNode()); // TODO should this happen by default? final TransformationContext context = ResourceTransformationContextImpl.create(transformationInputs, target, transformed, original, Transformers.DEFAULT); final OperationTransformer transformer = target.resolveTransformer(context, useAddress, operationName); if (transformer == null) { ControllerLogger.ROOT_LOGGER.tracef("operation %s does not need transformation", operation); return new OperationTransformer.TransformedOperation(operation, OperationResultTransformer.ORIGINAL_RESULT); } final OperationTransformer.TransformedOperation op = transformer.transformOperation(context, transformed, operation); context.getLogger().flushLogQueue(); return op; }
protected void describe(final Resource resource, final ModelNode address, ModelNode result, final ImmutableManagementResourceRegistration registration) { if(resource == null || registration.isRemote() || registration.isRuntimeOnly() || resource.isProxy() || resource.isRuntime() || registration.isAlias()) { return; } final Set<PathElement> children; if (comparator == null) { children = registration.getChildAddresses(PathAddress.EMPTY_ADDRESS); } else { children = new TreeSet<PathElement>(comparator); children.addAll(registration.getChildAddresses(PathAddress.EMPTY_ADDRESS)); } result.add(createAddOperation(address, resource.getModel(), children)); for(final PathElement element : children) { if(element.isMultiTarget()) { final String childType = element.getKey(); for(final Resource.ResourceEntry entry : resource.getChildren(childType)) { final ImmutableManagementResourceRegistration childRegistration = registration.getSubModel(PathAddress.pathAddress(PathElement.pathElement(childType, entry.getName()))); final ModelNode childAddress = address.clone(); childAddress.add(childType, entry.getName()); describe(entry, childAddress, result, childRegistration); } } else { final Resource child = resource.getChild(element); final ImmutableManagementResourceRegistration childRegistration = registration.getSubModel(PathAddress.pathAddress(element)); final ModelNode childAddress = address.clone(); childAddress.add(element.getKey(), element.getValue()); describe(child, childAddress, result, childRegistration); } } }
protected void describe(final Resource resource, final ModelNode address, ModelNode result, final ImmutableManagementResourceRegistration registration) { if(resource == null || registration.isRemote() || registration.isRuntimeOnly() || resource.isProxy() || resource.isRuntime() || registration.isAlias()) { return; } final Set<PathElement> children; if (comparator == null) { children = registration.getChildAddresses(PathAddress.EMPTY_ADDRESS); } else { children = new TreeSet<PathElement>(comparator); children.addAll(registration.getChildAddresses(PathAddress.EMPTY_ADDRESS)); } result.add(createAddOperation(address, resource.getModel(), children)); for(final PathElement element : children) { if(element.isMultiTarget()) { final String childType = element.getKey(); for(final Resource.ResourceEntry entry : resource.getChildren(childType)) { final ImmutableManagementResourceRegistration childRegistration = registration.getSubModel(PathAddress.pathAddress(PathElement.pathElement(childType, entry.getName()))); final ModelNode childAddress = address.clone(); childAddress.add(childType, entry.getName()); describe(entry, childAddress, result, childRegistration); } } else { final Resource child = resource.getChild(element); final ImmutableManagementResourceRegistration childRegistration = registration.getSubModel(PathAddress.pathAddress(element)); final ModelNode childAddress = address.clone(); childAddress.add(element.getKey(), element.getValue()); describe(child, childAddress, result, childRegistration); } } }
private void describeChildren(final Resource resource, final ImmutableManagementResourceRegistration registration, final PathAddress address, OperationContext context, final AtomicReference<ModelNode> failureRef, final ModelNode results, ModelNode operation, Boolean nest) { for(String childType : resource.getChildTypes()) { for(Resource.ResourceEntry entry : resource.getChildren(childType)) { if(addressFilter != null && !addressFilter.accepts(address.append(entry.getPathElement()))) { continue; } final ImmutableManagementResourceRegistration childRegistration = registration.getSubModel(PathAddress.EMPTY_ADDRESS.append(entry.getPathElement())); if(childRegistration == null) { ControllerLogger.ROOT_LOGGER.debugf("Couldn't find a registration for %s at %s for resource %s at %s", entry.getPathElement().toString(), registration.getPathAddress().toCLIStyleString(), resource, address.toCLIStyleString()); continue; } if(childRegistration.isRuntimeOnly() || childRegistration.isRemote() || childRegistration.isAlias()) { continue; } describeChildResource(entry, registration, address, context, failureRef, results, operation, nest); } } }
private void describeChildren(final Resource resource, final ImmutableManagementResourceRegistration registration, final PathAddress address, OperationContext context, final AtomicReference<ModelNode> failureRef, final ModelNode results, ModelNode operation, Boolean nest) { for(String childType : resource.getChildTypes()) { for(Resource.ResourceEntry entry : resource.getChildren(childType)) { if(addressFilter != null && !addressFilter.accepts(address.append(entry.getPathElement()))) { continue; } final ImmutableManagementResourceRegistration childRegistration = registration.getSubModel(PathAddress.EMPTY_ADDRESS.append(entry.getPathElement())); if(childRegistration == null) { ControllerLogger.ROOT_LOGGER.debugf("Couldn't find a registration for %s at %s for resource %s at %s", entry.getPathElement().toString(), registration.getPathAddress().toCLIStyleString(), resource, address.toCLIStyleString()); continue; } if(childRegistration.isRuntimeOnly() || childRegistration.isRemote() || childRegistration.isAlias()) { continue; } describeChildResource(entry, registration, address, context, failureRef, results, operation, nest); } } }