Java Code Examples for org.jboss.as.controller.registry.ManagementResourceRegistration#getChildAddresses()

The following examples show how to use org.jboss.as.controller.registry.ManagementResourceRegistration#getChildAddresses() . 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: ModelControllerImpl.java    From wildfly-core with GNU Lesser General Public License v2.1 5 votes vote down vote up
private OperationEntry resolveOperationHandler(final PathAddress address, final String operationName) {
    ManagementResourceRegistration rootRegistration = managementModel.get().getRootResourceRegistration();
    OperationEntry result = rootRegistration.getOperationEntry(address, operationName);
    if (result == null && address.size() > 0) {
        // For wildcard elements, check specific registrations where the same OSH is used
        // for all such registrations
        PathElement pe = address.getLastElement();
        if (pe.isWildcard()) {
            String type = pe.getKey();
            PathAddress parent = address.subAddress(0, address.size() - 1);
            Set<PathElement> children = rootRegistration.getChildAddresses(parent);
            if (children != null) {
                OperationEntry found = null;
                for (PathElement child : children) {
                    if (type.equals(child.getKey())) {
                        OperationEntry oe = rootRegistration.getOperationEntry(parent.append(child), operationName);
                        OperationStepHandler osh = oe == null ? null : oe.getOperationHandler();
                        if (osh == null || (found != null && !osh.equals(found.getOperationHandler()))) {
                            // Not all children have the same handler; give up
                            found = null;
                            break;
                        }
                        // We have a candidate OSH
                        found = oe;
                    }
                }
                if (found != null) {
                    result = found;
                }
            }
        }
    }
    return result;
}
 
Example 2
Source File: ModelDescriptionTestCase.java    From wildfly-core with GNU Lesser General Public License v2.1 5 votes vote down vote up
private static void validate(ManagementResourceRegistration orig, ManagementResourceRegistration loaded) {
    Assert.assertEquals(orig.getChildAddresses(PathAddress.EMPTY_ADDRESS).size(), loaded.getChildAddresses(PathAddress.EMPTY_ADDRESS).size());

    Assert.assertEquals(orig.getAttributeNames(PathAddress.EMPTY_ADDRESS).size(), loaded.getAttributeNames(PathAddress.EMPTY_ADDRESS).size());
    for (String name : orig.getAttributeNames(PathAddress.EMPTY_ADDRESS)) {
        AttributeDefinition attr1 = orig.getAttributeAccess(PathAddress.EMPTY_ADDRESS, name).getAttributeDefinition();
        AttributeDefinition attr2 = loaded.getAttributeAccess(PathAddress.EMPTY_ADDRESS, name).getAttributeDefinition();
        Assert.assertEquals(1d, SimilarityIndex.compareAttributes(attr1, attr2), 0.0d);
    }
    for (PathElement pe : orig.getChildAddresses(PathAddress.EMPTY_ADDRESS)) {
        ManagementResourceRegistration origSub = orig.getSubModel(PathAddress.pathAddress(pe));
        ManagementResourceRegistration loadedSub = loaded.getSubModel(PathAddress.pathAddress(pe));
        validate(origSub, loadedSub);
    }
}