Java Code Examples for org.jboss.as.controller.registry.Resource#navigate()

The following examples show how to use org.jboss.as.controller.registry.Resource#navigate() . 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: ServerGroupDeploymentAddHandler.java    From wildfly-core with GNU Lesser General Public License v2.1 6 votes vote down vote up
static void validateRuntimeNames(String deploymentName, OperationContext context, PathAddress address) throws OperationFailedException {
    ModelNode deployment = context.readResource(PathAddress.EMPTY_ADDRESS).getModel();

    if (ENABLED.resolveModelAttribute(context, deployment).asBoolean()) {
        Resource root = context.readResourceFromRoot(PathAddress.EMPTY_ADDRESS);
        ModelNode domainDeployment = root.getChild(PathElement.pathElement(DEPLOYMENT, deploymentName)).getModel();
        String runtimeName = getRuntimeName(deploymentName, deployment, domainDeployment);
        PathAddress sgAddress = address.subAddress(0, address.size() - 1);
        Resource serverGroup = root.navigate(sgAddress);
        for (Resource.ResourceEntry re : serverGroup.getChildren(DEPLOYMENT)) {
            String reName = re.getName();
            if (!deploymentName.equals(reName)) {
                ModelNode otherDepl = re.getModel();
                if (ENABLED.resolveModelAttribute(context, otherDepl).asBoolean()) {
                    domainDeployment = root.getChild(PathElement.pathElement(DEPLOYMENT, reName)).getModel();
                    String otherRuntimeName = getRuntimeName(reName, otherDepl, domainDeployment);
                    if (runtimeName.equals(otherRuntimeName)) {
                        throw DomainControllerLogger.ROOT_LOGGER.runtimeNameMustBeUnique(reName, runtimeName, sgAddress.getLastElement().getValue());
                    }
                }
            }
        }
    }
}
 
Example 2
Source File: ManagementUtil.java    From wildfly-core with GNU Lesser General Public License v2.1 5 votes vote down vote up
static void updateUserDomainCallbackHandler(final OperationContext context, final ModelNode operation, final boolean forRollback) {
    UserDomainCallbackHandler cbh = getUserDomainCallbackHandler(context, operation);
    if (cbh != null) {
        PathAddress authAddress = getXmlAuthenticationAddress(operation);
        Resource root = forRollback ? context.getOriginalRootResource() : context.readResourceFromRoot(PathAddress.EMPTY_ADDRESS);
        ModelNode userMap;
        try {
            Resource authResource = root.navigate(authAddress);
            userMap = context.resolveExpressions(Resource.Tools.readModel(authResource));
        } catch (Exception e) {
            userMap = new ModelNode().setEmptyObject();
        }
        cbh.setUserDomain(userMap);
    }
}
 
Example 3
Source File: AbstractClassificationResource.java    From wildfly-core with GNU Lesser General Public License v2.1 5 votes vote down vote up
@Override
public Resource navigate(PathAddress address) {
    if (address.size() == 0) {
        return this;
    } else {
        Resource child = requireChild(address.getElement(0));
        return address.size() == 1 ? child : child.navigate(address.subAddress(1));
    }
}
 
Example 4
Source File: ExtensionResource.java    From wildfly-core with GNU Lesser General Public License v2.1 5 votes vote down vote up
@Override
public Resource navigate(PathAddress address) {
    int size = address.size();
    if (size == 0) {
        return this;
    }
    PathElement pe = address.getElement(0);
    Resource child = getChild(pe);
    if (child != null) {
        return size == 1 ? child : child.navigate(address.subAddress(1));
    } else {
        throw new NoSuchResourceException(pe);
    }
}
 
Example 5
Source File: ChainedTransformingDescription.java    From wildfly-core with GNU Lesser General Public License v2.1 5 votes vote down vote up
private void copy(Resource src, Resource dest, PathAddress address) {
    PathAddress parentAddress = address.size() > 1 ? address.subAddress(0, address.size() - 1) : PathAddress.EMPTY_ADDRESS;
    PathElement childElement = address.getLastElement();
    Resource source = src.navigate(parentAddress);
    Resource destination = dest.navigate(parentAddress);
    Resource sourceChild = source.getChild(childElement);
    if (sourceChild != null) {
        Resource destChild = Resource.Factory.create();
        destination.registerChild(childElement, destChild);
        copy(sourceChild, destChild);
    }
    //copy(src, dest);
}
 
Example 6
Source File: ManagedDMRContentTypeResource.java    From wildfly-core with GNU Lesser General Public License v2.1 5 votes vote down vote up
@Override
public Resource navigate(PathAddress address) {
    if (address.size() == 0) {
        return this;
    } else {
        Resource child = requireChild(address.getElement(0));
        return address.size() == 1 ? child : child.navigate(address.subAddress(1));
    }
}
 
Example 7
Source File: AbstractPlatformMBeanResource.java    From wildfly-core with GNU Lesser General Public License v2.1 5 votes vote down vote up
@Override
public Resource navigate(PathAddress address) {
    if (address.size() == 0) {
        return this;
    } else {
        Resource child = requireChild(address.getElement(0));
        return address.size() == 1 ? child : child.navigate(address.subAddress(1));
    }
}