当前位置: 首页>>代码示例>>Java>>正文


Java Resource.getChild方法代码示例

本文整理汇总了Java中org.jboss.as.controller.registry.Resource.getChild方法的典型用法代码示例。如果您正苦于以下问题:Java Resource.getChild方法的具体用法?Java Resource.getChild怎么用?Java Resource.getChild使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.jboss.as.controller.registry.Resource的用法示例。


在下文中一共展示了Resource.getChild方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getHostEffect

import org.jboss.as.controller.registry.Resource; //导入方法依赖的package包/类
/** Creates an appropriate HSGE for resources in the host tree, excluding the server and server-config subtrees */
private synchronized HostServerGroupEffect getHostEffect(PathAddress address, String host, Resource root)  {
    if (requiresMapping) {
        map(root);
        requiresMapping = false;
    }
    Set<String> mapped = hostsToGroups.get(host);
    if (mapped == null) {
        // Unassigned host. Treat like an unassigned profile or socket-binding-group;
        // i.e. available to all server group scoped roles.
        // Except -- WFLY-2085 -- the master HC is not open to all s-g-s-rs
        Resource hostResource = root.getChild(PathElement.pathElement(HOST, host));
        if (hostResource != null) {
            ModelNode dcModel = hostResource.getModel().get(DOMAIN_CONTROLLER);
            if (!dcModel.hasDefined(REMOTE)) {
                mapped = Collections.emptySet(); // prevents returning HostServerGroupEffect.forUnassignedHost(address, host)
            }
        }
    }
    return mapped == null ? HostServerGroupEffect.forUnassignedHost(address, host)
            : HostServerGroupEffect.forMappedHost(address, mapped, host);

}
 
开发者ID:wildfly,项目名称:wildfly-core,代码行数:24,代码来源:HostServerGroupTracker.java

示例2: getAuthorizationResource

import org.jboss.as.controller.registry.Resource; //导入方法依赖的package包/类
private Resource getAuthorizationResource(PathAddress address) {
    Resource model = this.managementModel.getRootResource();
    for (PathElement element : address) {
        // Allow wildcard navigation for the last element
        if (element.isWildcard()) {
            model = Resource.Factory.create();
            final Set<Resource.ResourceEntry> children = model.getChildren(element.getKey());
            for (final Resource.ResourceEntry entry : children) {
                model.registerChild(entry.getPathElement(), entry);
            }
        } else {
            model = model.getChild(element);
            if (model == null) {
                return Resource.Factory.create();
            }
        }
    }
    return model;
}
 
开发者ID:wildfly,项目名称:wildfly-core,代码行数:20,代码来源:OperationContextImpl.java

示例3: hasDeploymentSubModel

import org.jboss.as.controller.registry.Resource; //导入方法依赖的package包/类
/**
 * Checks to see if a resource has already been registered for the specified address on the subsystem.
 *
 * @param subsystemName the name of the subsystem
 * @param address       the address to check
 *
 * @return {@code true} if the address exists on the subsystem otherwise {@code false}
 */
public boolean hasDeploymentSubModel(final String subsystemName, final PathAddress address) {
    final Resource root = deploymentUnit.getAttachment(DEPLOYMENT_RESOURCE);
    final PathElement subsystem = PathElement.pathElement(SUBSYSTEM, subsystemName);
    boolean found = false;
    if (root.hasChild(subsystem)) {
        if (address == PathAddress.EMPTY_ADDRESS) {
            return true;
        }
        Resource parent = root.getChild(subsystem);
        for (PathElement child : address) {
            if (parent.hasChild(child)) {
                found = true;
                parent = parent.getChild(child);
            } else {
                found = false;
                break;
            }
        }
    }
    return found;
}
 
开发者ID:wildfly,项目名称:wildfly-core,代码行数:30,代码来源:DeploymentResourceSupport.java

示例4: processSocketBindingGroup

import org.jboss.as.controller.registry.Resource; //导入方法依赖的package包/类
private static void processSocketBindingGroup(final Resource domain, final String socketBindingGroup, final RequiredConfigurationHolder holder) {
    final Set<String> socketBindingGroups = holder.socketBindings;

    if (socketBindingGroups.contains(socketBindingGroup)) {
        return;
    }
    socketBindingGroups.add(socketBindingGroup);
    final PathElement socketBindingGroupElement = PathElement.pathElement(SOCKET_BINDING_GROUP, socketBindingGroup);
    if (domain.hasChild(socketBindingGroupElement)) {
        final Resource resource = domain.getChild(socketBindingGroupElement);

        if (resource.getModel().hasDefined(INCLUDES)) {
            for (final ModelNode include : resource.getModel().get(INCLUDES).asList()) {
                processSocketBindingGroup(domain, include.asString(), holder);
            }
        }
    }
    ControllerLogger.ROOT_LOGGER.tracef("Recorded need for socket-binding-group %s", socketBindingGroup);
}
 
开发者ID:wildfly,项目名称:wildfly-core,代码行数:20,代码来源:ReadMasterDomainModelUtil.java

示例5: execute

import org.jboss.as.controller.registry.Resource; //导入方法依赖的package包/类
@Override
public void execute(final OperationContext context, final ModelNode operation) throws OperationFailedException {
    final PathAddress address = PathAddress.pathAddress(operation.get(OP_ADDR));
    Resource resource = context.getOriginalRootResource();
    for (final PathElement element : address) {
        resource = resource.getChild(element);
    }
    byte[] contentHash = resource.getModel().get(CONTENT).asBytes();
    try {
        TypedInputStream inputStream = contentRepository.readContent(contentHash, "");
        String uuid = context.attachResultStream(inputStream.getContentType(), inputStream);
        context.getResult().get(UUID).set(uuid);
    } catch (ExplodedContentException ex) {
        throw new RuntimeException(ex.getMessage(), ex);
    }
}
 
开发者ID:wildfly,项目名称:wildfly-core,代码行数:17,代码来源:DeploymentOverlayContentDefinition.java

示例6: testSimpleAccept

import org.jboss.as.controller.registry.Resource; //导入方法依赖的package包/类
@Test
public void testSimpleAccept() throws Exception {
    //Set up the model
    resourceModel.get("reject").set(true);

    final ResourceTransformationDescriptionBuilder builder = TransformationDescriptionBuilder.Factory.createInstance(PATH);
    builder.getAttributeBuilder().addRejectCheck(new RejectAttributeChecker.SimpleAcceptAttributeChecker(new ModelNode(false)), "reject").end();
    TransformationDescription.Tools.register(builder.build(), transformersSubRegistration);

    final Resource resource = transformResource();
    Assert.assertNotNull(resource);
    final Resource toto = resource.getChild(PATH);
    Assert.assertNotNull(toto);
    final ModelNode model = toto.getModel();
    //The rejection does not trigger for resource transformation
    Assert.assertTrue(model.hasDefined("reject"));

    ModelNode add = Util.createAddOperation(PathAddress.pathAddress(PATH));
    add.get("reject").set(true);
    OperationTransformer.TransformedOperation transformedAdd = transformOperation(add);
    Assert.assertTrue(transformedAdd.rejectOperation(success()));

    ModelNode write = Util.getWriteAttributeOperation(PathAddress.pathAddress(PATH), "reject", new ModelNode().set(true));
    OperationTransformer.TransformedOperation transformedWrite = transformOperation(write);
    Assert.assertTrue(transformedWrite.rejectOperation(success()));
}
 
开发者ID:wildfly,项目名称:wildfly-core,代码行数:27,代码来源:AttributesTestCase.java

示例7: testResourceNoChildrenChainedTransformation

import org.jboss.as.controller.registry.Resource; //导入方法依赖的package包/类
@Test
public void testResourceNoChildrenChainedTransformation() throws Exception {
    ChainedTransformationDescriptionBuilder chainedBuilder = TransformationDescriptionBuilder.Factory.createChainedInstance(PATH, V4_0_0);
    chainedBuilder.createBuilder(V4_0_0, V3_0_0)
            .getAttributeBuilder()
                .setValueConverter(new SimpleAttributeConverter("test1", "test11"), "attr1")
            .end();
    chainedBuilder.createBuilder(V3_0_0, V2_0_0)
            .getAttributeBuilder()
                .setValueConverter(new SimpleAttributeConverter("test11", "test111"), "attr1")
            .end();
    chainedBuilder.createBuilder(V2_0_0, V1_0_0)
            .getAttributeBuilder()
                .setValueConverter(new SimpleAttributeConverter("test111", "test1111"), "attr1")
            .end();

    TransformationDescription.Tools.register(chainedBuilder.build(V1_0_0, V3_0_0, V2_0_0).get(V1_0_0), transformersSubRegistration);

    for(ModelVersion version : VALID_TESTED_VERSIONS) {
        //Set up the model
        resourceModel.get("attr1").set("test1");
        final Resource resource = transformResource(version);
        Assert.assertNotNull(resource);
        final Resource toto = resource.getChild(PATH);
        Assert.assertNotNull(toto);
        final ModelNode model = toto.getModel();
        Assert.assertEquals("test1111", model.get("attr1").asString());
    }
}
 
开发者ID:wildfly,项目名称:wildfly-core,代码行数:30,代码来源:ChainedResourceBuilderTestCase.java

示例8: testDiscardNotHappeningWithExpressions

import org.jboss.as.controller.registry.Resource; //导入方法依赖的package包/类
@Test
public void testDiscardNotHappeningWithExpressions() throws Exception {
    //Set up the model
    resourceModel.get("discard").set(new ValueExpression("${xxx}"));

    final ResourceTransformationDescriptionBuilder builder = TransformationDescriptionBuilder.Factory.createInstance(PATH);
        builder.getAttributeBuilder().setDiscard(new DefaultDiscardAttributeChecker(false, false) {
            @Override
            public boolean isValueDiscardable(PathAddress address, String attributeName, ModelNode attributeValue, TransformationContext context) {
                return true;
            }
        }, "discard").end();
    TransformationDescription.Tools.register(builder.build(), transformersSubRegistration);

    final Resource resource = transformResource();
    Assert.assertNotNull(resource);
    final Resource toto = resource.getChild(PATH);
    Assert.assertNotNull(toto);
    final ModelNode model = toto.getModel();
    Assert.assertEquals(new ModelNode().set(new ValueExpression("${xxx}")), model.get("discard"));

    ModelNode add = Util.createAddOperation(PathAddress.pathAddress(PATH));
    add.get("discard").set(new ValueExpression("${xxx}"));
    OperationTransformer.TransformedOperation transformedAdd = transformOperation(add);
    Assert.assertFalse(transformedAdd.rejectOperation(success()));
    Assert.assertEquals(add, transformedAdd.getTransformedOperation());

    checkWriteOp(Util.getWriteAttributeOperation(PathAddress.pathAddress(PATH), "discard", new ModelNode().set(new ValueExpression("${xxx}"))),
            "discard", new ModelNode().set(new ValueExpression("${xxx}")));
}
 
开发者ID:wildfly,项目名称:wildfly-core,代码行数:31,代码来源:AttributesTestCase.java

示例9: testDiscardUndefined

import org.jboss.as.controller.registry.Resource; //导入方法依赖的package包/类
@Test
public void testDiscardUndefined() throws Exception {
    //Set up the model
    resourceModel.get("discard");
    resourceModel.get("keep").set("here");

    final ResourceTransformationDescriptionBuilder builder = TransformationDescriptionBuilder.Factory.createInstance(PATH);
        builder.getAttributeBuilder().setDiscard(DiscardAttributeChecker.UNDEFINED, "discard", "keep").end();
    TransformationDescription.Tools.register(builder.build(), transformersSubRegistration);

    final Resource resource = transformResource();
    Assert.assertNotNull(resource);
    final Resource toto = resource.getChild(PATH);
    Assert.assertNotNull(toto);
    final ModelNode model = toto.getModel();
    Assert.assertTrue(model.hasDefined("keep"));
    Assert.assertFalse(model.has("discard"));

    ModelNode add = Util.createAddOperation(PathAddress.pathAddress(PATH));
    add.get("discard");
    add.get("keep").set("here");
    OperationTransformer.TransformedOperation transformedAdd = transformOperation(add);
    Assert.assertFalse(transformedAdd.rejectOperation(success()));
    Assert.assertTrue(transformedAdd.getTransformedOperation().hasDefined("keep"));
    Assert.assertFalse(transformedAdd.getTransformedOperation().has("discard"));

    checkOpDiscarded(Util.getWriteAttributeOperation(PathAddress.pathAddress(PATH), "discard", new ModelNode()));

    checkWriteOp(Util.getWriteAttributeOperation(PathAddress.pathAddress(PATH), "discard", new ModelNode("nothing")),
            "discard", new ModelNode("nothing"));
}
 
开发者ID:wildfly,项目名称:wildfly-core,代码行数:32,代码来源:AttributesTestCase.java

示例10: testAddValue

import org.jboss.as.controller.registry.Resource; //导入方法依赖的package包/类
@Test
public void testAddValue() throws Exception {
    resourceModel.get("old").set("existing");

    final ResourceTransformationDescriptionBuilder builder = TransformationDescriptionBuilder.Factory.createInstance(PATH);
    builder.getAttributeBuilder().setValueConverter(new DefaultAttributeConverter() {
        @Override
        public void convertAttribute(PathAddress address, String name, ModelNode attributeValue, TransformationContext context) {
            attributeValue.set("extra");
        }
    }, "added").end();
    TransformationDescription.Tools.register(builder.build(), transformersSubRegistration);

    final Resource resource = transformResource();
    Assert.assertNotNull(resource);
    final Resource toto = resource.getChild(PATH);
    Assert.assertNotNull(toto);
    final ModelNode model = toto.getModel();
    Assert.assertEquals(2, model.keys().size());
    Assert.assertEquals("existing", model.get("old").asString());
    Assert.assertEquals("extra", model.get("added").asString());

    ModelNode add = Util.createAddOperation(PathAddress.pathAddress(PATH));
    add.get("old").set("existing");
    OperationTransformer.TransformedOperation transformedAdd = transformOperation(add);
    Assert.assertFalse(transformedAdd.rejectOperation(success()));
    Assert.assertEquals("existing", transformedAdd.getTransformedOperation().get("old").asString());
    Assert.assertEquals("extra", transformedAdd.getTransformedOperation().get("added").asString());

    //Can't write to this added attribute
}
 
开发者ID:wildfly,项目名称:wildfly-core,代码行数:32,代码来源:AttributesTestCase.java

示例11: testResourceTransformation

import org.jboss.as.controller.registry.Resource; //导入方法依赖的package包/类
@Test
public void testResourceTransformation() throws Exception {
    //We probably test this elsewhere, but make sure that only real (i.e. non-alias resources get transformed)
    final Resource resource = transformResource();
    Assert.assertNotNull(resource);
    final Resource toto = resource.getChild(PATH);
    Assert.assertNotNull(toto);

    Set<String> types = toto.getChildTypes();
    Assert.assertEquals(1, types.size());
    Assert.assertTrue(types.contains(LEGACY_CHILD.getKey()));
    Set<Resource.ResourceEntry> entries = toto.getChildren(LEGACY_CHILD.getKey());
    Assert.assertEquals(1, entries.size());
    Assert.assertNotNull(toto.getChild(PathElement.pathElement(LEGACY_CHILD.getKey(), "one")));
}
 
开发者ID:wildfly,项目名称:wildfly-core,代码行数:16,代码来源:AliasTransformerTestCase.java

示例12: testDiscardAlways

import org.jboss.as.controller.registry.Resource; //导入方法依赖的package包/类
@Test
public void testDiscardAlways() throws Exception {
    //Set up the model
    resourceModel.get("discard").set("nothing");
    resourceModel.get("keep").set("here");

    final ResourceTransformationDescriptionBuilder builder = TransformationDescriptionBuilder.Factory.createInstance(PATH);
        builder.getAttributeBuilder().setDiscard(DiscardAttributeChecker.ALWAYS, "discard").end();
    TransformationDescription.Tools.register(builder.build(), transformersSubRegistration);

    final Resource resource = transformResource();
    Assert.assertNotNull(resource);
    final Resource toto = resource.getChild(PATH);
    Assert.assertNotNull(toto);
    final ModelNode model = toto.getModel();
    Assert.assertTrue(model.hasDefined("keep"));
    Assert.assertFalse(model.has("discard"));

    ModelNode add = Util.createAddOperation(PathAddress.pathAddress(PATH));
    add.get("discard").set("nothing");
    add.get("keep").set("here");
    OperationTransformer.TransformedOperation transformedAdd = transformOperation(add);
    Assert.assertFalse(transformedAdd.rejectOperation(success()));
    Assert.assertTrue(transformedAdd.getTransformedOperation().hasDefined("keep"));
    Assert.assertFalse(transformedAdd.getTransformedOperation().has("discard"));

    checkOpDiscarded(Util.getWriteAttributeOperation(PathAddress.pathAddress(PATH), "discard", new ModelNode("nothing")));
    checkOpDiscarded(Util.getUndefineAttributeOperation(PathAddress.pathAddress(PATH), "discard"));
}
 
开发者ID:wildfly,项目名称:wildfly-core,代码行数:30,代码来源:AttributesTestCase.java

示例13: testResourceTransformation

import org.jboss.as.controller.registry.Resource; //导入方法依赖的package包/类
@Test
public void testResourceTransformation() throws Exception {

    final ModelNode address = new ModelNode();
    address.add("toto", "testSubsystem");

    final ModelNode node = new ModelNode();
    node.get(ModelDescriptionConstants.OP).set("add");
    node.get(ModelDescriptionConstants.OP_ADDR).set(address);

    final OperationTransformer.TransformedOperation op = transformOperation(ModelVersion.create(1), node);
    Assert.assertNotNull(op);

    final Resource resource = transformResource(ModelVersion.create(1));

    Assert.assertNotNull(resource);
    final Resource toto = resource.getChild(PATH);
    final ModelNode model = toto.getModel();
    Assert.assertNotNull(toto);
    Assert.assertFalse(toto.hasChild(PathElement.pathElement("discard", "one")));
    Assert.assertFalse(toto.hasChild(CONFIGURATION_TEST));

    Assert.assertFalse(toto.hasChild(PathElement.pathElement("dynamic", "discard")));
    Assert.assertFalse(toto.hasChild(PathElement.pathElement("dynamic", "reject")));
    Resource dynamicKeep = toto.getChild(PathElement.pathElement("dynamic", "keep"));
    Assert.assertEquals("KEEP", dynamicKeep.getModel().get("attribute").asString());

    Assert.assertFalse(toto.hasChildren("dynamic-redirect-original")); //Make sure that we didn't keep the originals
    Assert.assertFalse(toto.hasChild(PathElement.pathElement("dynamic-redirect-new", "discard")));
    Assert.assertFalse(toto.hasChild(PathElement.pathElement("dynamic-redirect-new", "reject")));
    Resource dynamicRedirectKeep = toto.getChild(PathElement.pathElement("dynamic-redirect-new", "keep"));
    Assert.assertEquals("KEEP", dynamicRedirectKeep.getModel().get("attribute").asString());

    final Resource attResource = toto.getChild(PathElement.pathElement("attribute-resource", "test"));
    Assert.assertNotNull(attResource);
    final ModelNode attResourceModel = attResource.getModel();
    Assert.assertFalse(attResourceModel.get("test-resource").isDefined());  // check that the resource got removed
    Assert.assertTrue(attResourceModel.hasDefined("test-attribute"));
    Assert.assertTrue(attResource.hasChild(PathElement.pathElement("resource", "test")));
}
 
开发者ID:wildfly,项目名称:wildfly-core,代码行数:41,代码来源:BasicResourceTestCase.java

示例14: testDiscardDefaultValue

import org.jboss.as.controller.registry.Resource; //导入方法依赖的package包/类
@Test
public void testDiscardDefaultValue() throws Exception {
    //Set up the model
    resourceModel.get("discard").set("default");
    resourceModel.get("keep").set("non-default");

    final ResourceTransformationDescriptionBuilder builder = TransformationDescriptionBuilder.Factory.createInstance(PATH);
        builder.getAttributeBuilder().setDiscard(new DefaultDiscardAttributeChecker(false, true) {
            @Override
            public boolean isValueDiscardable(PathAddress address, String attributeName, ModelNode attributeValue, TransformationContext context) {
                if (attributeName.equals("discard") || attributeName.equals("keep")) {
                    if (attributeValue.asString().equals("default")) {
                        return true;
                    }
                }
                return false;
            }
        }, "discard", "keep").end();
    TransformationDescription.Tools.register(builder.build(), transformersSubRegistration);

    final Resource resource = transformResource();
    Assert.assertNotNull(resource);
    final Resource toto = resource.getChild(PATH);
    Assert.assertNotNull(toto);
    final ModelNode model = toto.getModel();
    Assert.assertTrue(model.hasDefined("keep"));
    Assert.assertFalse(model.has("discard"));

    ModelNode add = Util.createAddOperation(PathAddress.pathAddress(PATH));
    add.get("discard");
    add.get("keep").set("here");
    OperationTransformer.TransformedOperation transformedAdd = transformOperation(add);
    Assert.assertFalse(transformedAdd.rejectOperation(success()));
    Assert.assertTrue(transformedAdd.getTransformedOperation().hasDefined("keep"));
    Assert.assertFalse(transformedAdd.getTransformedOperation().has("discard"));

    checkOpDiscarded(Util.getWriteAttributeOperation(PathAddress.pathAddress(PATH), "discard", new ModelNode("default")));
    checkWriteOp(Util.getWriteAttributeOperation(PathAddress.pathAddress(PATH), "discard", new ModelNode("something")),
            "discard", new ModelNode("something"));
}
 
开发者ID:wildfly,项目名称:wildfly-core,代码行数:41,代码来源:AttributesTestCase.java

示例15: addResource

import org.jboss.as.controller.registry.Resource; //导入方法依赖的package包/类
@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);
            }
        }
    }
}
 
开发者ID:wildfly,项目名称:wildfly-core,代码行数:32,代码来源:AbstractOperationTestCase.java


注:本文中的org.jboss.as.controller.registry.Resource.getChild方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。