Java Code Examples for org.jboss.as.controller.PathElement#equals()

The following examples show how to use org.jboss.as.controller.PathElement#equals() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: AbstractOperationTestCase.java    From wildfly-core with GNU Lesser General Public License v2.1 5 votes vote down vote up
@Override
public void addResource(PathAddress relativeAddress, Resource toAdd) {
    Resource model = root;
    final Iterator<PathElement> i = operationAddress.append(relativeAddress).iterator();
    while (i.hasNext()) {
        final PathElement element = i.next();
        if (element.isMultiTarget()) {
            throw ControllerLogger.ROOT_LOGGER.cannotWriteTo("*");
        }
        if (!i.hasNext()) {
            if (model.hasChild(element)) {
                throw ControllerLogger.ROOT_LOGGER.duplicateResourceAddress(relativeAddress);
            } else {
                model.registerChild(element, toAdd);
                model = toAdd;
            }
        } else {
            model = model.getChild(element);
            if (model == null) {
                PathAddress ancestor = PathAddress.EMPTY_ADDRESS;
                for (PathElement pe : relativeAddress) {
                    ancestor = ancestor.append(pe);
                    if (element.equals(pe)) {
                        break;
                    }
                }
                throw ControllerLogger.ROOT_LOGGER.resourceNotFound(ancestor, relativeAddress);
            }
        }
    }
}
 
Example 2
Source File: RemotingExtension.java    From wildfly-core with GNU Lesser General Public License v2.1 5 votes vote down vote up
@Override
protected void describe(OrderedChildTypesAttachment orderedChildTypesAttachment, Resource resource,
                        ModelNode address, ModelNode result, ImmutableManagementResourceRegistration registration) {
    // Don't describe the configuration=endpoint resource. It's just an alias for
    // a set of attributes on its parent and the parent description covers those.

    PathElement pe = registration.getPathAddress().getLastElement();
    if (!pe.equals(RemotingEndpointResource.ENDPOINT_PATH)) {
        super.describe(orderedChildTypesAttachment, resource, address, result, registration);
    }
}
 
Example 3
Source File: SubsystemTestDelegate.java    From wildfly-core with GNU Lesser General Public License v2.1 5 votes vote down vote up
private void removeIgnoredChildren(final Collection<PathAddress> ignoredChildAddresses, final Collection<PathAddress> addresses) {
    // Remove all known ignored children
    addresses.removeAll(ignoredChildAddresses);
    // Checked for wildcards removals
    for (PathAddress ignoredChildAddress : ignoredChildAddresses) {
        final PathElement lastIgnoredElement = ignoredChildAddress.getLastElement();
        if (lastIgnoredElement.isWildcard()) {
            // Check each address
            for (final Iterator<PathAddress> iterator = addresses.iterator(); iterator.hasNext(); ) {
                final PathAddress childAddress = iterator.next();
                if (childAddress.size() == ignoredChildAddress.size()) {
                    // Check the last element key for a match
                    if (lastIgnoredElement.getKey().equals(childAddress.getLastElement().getKey())) {
                        boolean match = true;
                        // Check for matches on previous elements
                        for (int i = 0; i < ignoredChildAddress.size() - 1; i++) {
                            final PathElement e1 = ignoredChildAddress.getElement(i);
                            final PathElement e2 = childAddress.getElement(i);
                            if (!e1.equals(e2)) {
                                match = false;
                                break;
                            }
                        }
                        if (match) {
                            iterator.remove();
                        }
                    }
                }
            }
        }
    }
}
 
Example 4
Source File: ResourceTransformationContextImpl.java    From wildfly-core with GNU Lesser General Public License v2.1 4 votes vote down vote up
private ResourceTransformationContext addTransformedRecursiveResourceFromRoot(final PathAddress absoluteAddress, final PathAddress read, final Resource toAdd) {
    Resource model = this.root;
    Resource parent = null;
    if (absoluteAddress.size() > 0) {
        final Iterator<PathElement> i = absoluteAddress.iterator();
        while (i.hasNext()) {
            final PathElement element = i.next();
            if (element.isMultiTarget()) {
                throw ControllerLogger.ROOT_LOGGER.cannotWriteTo("*");
            }
            if (!i.hasNext()) {
                if (model.hasChild(element)) {
                    throw ControllerLogger.ROOT_LOGGER.duplicateResourceAddress(absoluteAddress);
                } else {
                    parent = model;
                    model.registerChild(element, toAdd);
                    model = toAdd;
                    if (read.size() > 0) {
                        //We might be able to deal with this better in the future, but for now
                        //throw an error if the address was renamed and it was an ordered child type.
                        Set<String> parentOrderedChildren = parent.getOrderedChildTypes();
                        String readType = read.getLastElement().getKey();
                        if (parentOrderedChildren.contains(readType)) {
                            if (absoluteAddress.size() == 0 || !absoluteAddress.getLastElement().getKey().equals(readType)) {
                                throw ControllerLogger.ROOT_LOGGER.orderedChildTypeRenamed(read, absoluteAddress, readType, parentOrderedChildren);
                            }
                        }
                    }
                }
            } else {
                model = model.getChild(element);
                if (model == null) {
                    PathAddress ancestor = PathAddress.EMPTY_ADDRESS;
                    for (PathElement pe : absoluteAddress) {
                        ancestor = ancestor.append(pe);
                        if (element.equals(pe)) {
                            break;
                        }
                    }
                    throw ControllerLogger.ROOT_LOGGER.resourceNotFound(ancestor, absoluteAddress);
                }
            }
        }
    } else {
        //If this was the root address, replace the resource model
        model.writeModel(toAdd.getModel());
    }
    return new ResourceTransformationContextImpl(root, absoluteAddress, read, originalModel,
            transformerOperationAttachment, ignoredTransformationRegistry);
}