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


Java Resource.getModel方法代码示例

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


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

示例1: readModelDescriptionWithAccessControlParameter

import org.jboss.as.controller.registry.Resource; //导入方法依赖的package包/类
private ModelNode readModelDescriptionWithAccessControlParameter(ReadResourceDescriptionHandler.AccessControl accessControl) throws Exception {
    ChildResourceDefinition oneChild = new ChildResourceDefinition(ONE);
    oneChild.addAttribute(ATTR_NONE);
    oneChild.addOperation(OP_CONFIG_RW_NONE, false, false);
    ManagementResourceRegistration oneReg = rootRegistration.registerSubModel(oneChild);
    Resource resourceOneA = Resource.Factory.create();
    ModelNode modelOneA = resourceOneA.getModel();
    modelOneA.get(ATTR_NONE).set("uno");
    rootResource.registerChild(ONE_A, resourceOneA);

    ChildResourceDefinition twoChild = new ChildResourceDefinition(TWO);
    twoChild.addAttribute(ATTR_NONE);
    twoChild.addOperation(OP_CONFIG_RW_NONE, false, false);
    oneReg.registerSubModel(twoChild);
    Resource resourceTwoA = Resource.Factory.create();
    ModelNode modelTwoA = resourceOneA.getModel();
    modelTwoA.get(ATTR_NONE).set("dos");
    resourceOneA.registerChild(TWO_A, resourceTwoA);

    ModelNode op = createReadResourceDescriptionOperation(PathAddress.EMPTY_ADDRESS, StandardRole.ADMINISTRATOR, true);
    op.get(ACCESS_CONTROL).set(accessControl.toString());
    ModelNode desc = executeForResult(op);
    return getChildDescription(desc, ONE);
}
 
开发者ID:wildfly,项目名称:wildfly-core,代码行数:25,代码来源:ReadResourceDescriptionAccessControlTestCase.java

示例2: registerReadOnlyAttributeResource

import org.jboss.as.controller.registry.Resource; //导入方法依赖的package包/类
private void registerReadOnlyAttributeResource(String testName) {
    ChildResourceDefinition oneChild = new ChildResourceDefinition(ONE);
    oneChild.addReadOnlyAttribute(ATTR_ACCESS_READ_WRITE, createSensitivityConstraint(testName + "-access-read-write", true, true, true));
    oneChild.addReadOnlyAttribute(ATTR_READ_WRITE, createSensitivityConstraint(testName + "-read-write", false, true, true));
    oneChild.addReadOnlyAttribute(ATTR_WRITE, createSensitivityConstraint(testName + "-write", false, false, true));
    oneChild.addReadOnlyAttribute(ATTR_READ, createSensitivityConstraint(testName + "-read", false, true, false));
    oneChild.addReadOnlyAttribute(ATTR_NONE);
    rootRegistration.registerSubModel(oneChild);
    Resource resourceA = Resource.Factory.create();
    ModelNode modelA = resourceA.getModel();
    modelA.get(ATTR_ACCESS_READ_WRITE).set("test1");
    modelA.get(ATTR_READ_WRITE).set("test2");
    modelA.get(ATTR_WRITE).set("test3");
    modelA.get(ATTR_READ).set("test4");
    modelA.get(ATTR_NONE).set("test5");
    rootResource.registerChild(ONE_A, resourceA);
    rootResource.registerChild(ONE_B, Resource.Factory.create());
}
 
开发者ID:wildfly,项目名称:wildfly-core,代码行数:19,代码来源:ReadResourceDescriptionAccessControlTestCase.java

示例3: recordCapabilitiesAndRequirements

import org.jboss.as.controller.registry.Resource; //导入方法依赖的package包/类
protected void recordCapabilitiesAndRequirements(OperationContext context, ModelNode operation, Resource resource) throws OperationFailedException {
    Set<RuntimeCapability> capabilitySet = capabilities.isEmpty() ? context.getResourceRegistration().getCapabilities() : capabilities;
    for (RuntimeCapability capability : capabilitySet) {
        if (capability.isDynamicallyNamed()) {
            context.deregisterCapability(capability.getDynamicName(context.getCurrentAddress()));
        } else {
            context.deregisterCapability(capability.getName());
        }
    }
    ModelNode model = resource.getModel();
    ImmutableManagementResourceRegistration mrr = context.getResourceRegistration();
    for (String attr : mrr.getAttributeNames(PathAddress.EMPTY_ADDRESS)) {
        AttributeAccess aa = mrr.getAttributeAccess(PathAddress.EMPTY_ADDRESS, attr);
        if (aa != null) {
            AttributeDefinition ad = aa.getAttributeDefinition();
            if (ad != null && (model.hasDefined(ad.getName()) || ad.hasCapabilityRequirements())) {
                ad.removeCapabilityRequirements(context, resource, model.get(ad.getName()));
            }
        }
    }
}
 
开发者ID:wildfly,项目名称:wildfly-core,代码行数:22,代码来源:SecurityRealmChildRemoveHandler.java

示例4: recordCapabilitiesAndRequirements

import org.jboss.as.controller.registry.Resource; //导入方法依赖的package包/类
protected void recordCapabilitiesAndRequirements(OperationContext context, ModelNode operation, Resource resource) throws OperationFailedException {
    Set<RuntimeCapability> capabilitySet = capabilities.isEmpty() ? context.getResourceRegistration().getCapabilities() : capabilities;

    for (RuntimeCapability capability : capabilitySet) {
        if (capability.isDynamicallyNamed()) {
            context.deregisterCapability(capability.getDynamicName(context.getCurrentAddress()));
        } else {
            context.deregisterCapability(capability.getName());
        }
    }
    ModelNode model = resource.getModel();
    ImmutableManagementResourceRegistration mrr = context.getResourceRegistration();
    for (String attr : mrr.getAttributeNames(PathAddress.EMPTY_ADDRESS)) {
        AttributeAccess aa = mrr.getAttributeAccess(PathAddress.EMPTY_ADDRESS, attr);
        if (aa != null) {
            AttributeDefinition ad = aa.getAttributeDefinition();
            if (ad != null && (model.hasDefined(ad.getName()) || ad.hasCapabilityRequirements())) {
                ad.removeCapabilityRequirements(context, resource, model.get(ad.getName()));
            }
        }
    }
}
 
开发者ID:wildfly,项目名称:wildfly-core,代码行数:23,代码来源:RestartParentResourceRemoveHandler.java

示例5: execute

import org.jboss.as.controller.registry.Resource; //导入方法依赖的package包/类
@Override
public void execute(OperationContext context, ModelNode operation) throws OperationFailedException {
    Resource resource = context.readResource(PathAddress.EMPTY_ADDRESS);
    ModelNode model = resource.getModel();
    boolean hasLegacy = false;
    if (forDomain) {
        for (final AttributeDefinition attribute : RemotingSubsystemRootResource.LEGACY_ATTRIBUTES) {
            if (model.hasDefined(attribute.getName())) {
                hasLegacy = true;
                break;
            }
        }
    }

    if (!hasLegacy && !resource.hasChild(RemotingEndpointResource.ENDPOINT_PATH)) {
        // User didn't configure either worker-thread-pool or endpoint. Add a default endpoint resource so
        // users can read the default config attribute values
        context.addResource(PathAddress.pathAddress(RemotingEndpointResource.ENDPOINT_PATH), Resource.Factory.create());
    }
}
 
开发者ID:wildfly,项目名称:wildfly-core,代码行数:21,代码来源:WorkerThreadPoolVsEndpointHandler.java

示例6: processServerGroup

import org.jboss.as.controller.registry.Resource; //导入方法依赖的package包/类
private static void processServerGroup(final RequiredConfigurationHolder holder, final String group, final Resource domain, ExtensionRegistry extensionRegistry) {

        final PathElement groupElement = PathElement.pathElement(SERVER_GROUP, group);
        if (!domain.hasChild(groupElement)) {
            return;
        }
        final Resource serverGroup = domain.getChild(groupElement);
        final ModelNode model = serverGroup.getModel();

        if (model.hasDefined(SOCKET_BINDING_GROUP)) {
            final String socketBindingGroup = model.get(SOCKET_BINDING_GROUP).asString();
            processSocketBindingGroup(domain, socketBindingGroup, holder);
        }

        final String profile = model.get(PROFILE).asString();
        processProfile(domain, profile, holder, extensionRegistry);

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

示例7: readAttributeValue

import org.jboss.as.controller.registry.Resource; //导入方法依赖的package包/类
private ModelNode readAttributeValue(OperationContext context, AttributeDefinition attribute) throws OperationFailedException {
    final Resource resource = context.readResource(PathAddress.EMPTY_ADDRESS);
    ModelNode model = resource.getModel();
    if(this.parentAttribute != null && !this.parentAttribute.equals(attribute)) {
        model = readAttributeValue(context, this.parentAttribute);
    }
    final String attributeName = attribute.getName();
    if(model.hasDefined(attributeName)) {
        return attribute.resolveModelAttribute(context, model);
    }
    AttributeAccess access = context.getResourceRegistration().getAttributeAccess(PathAddress.EMPTY_ADDRESS, attributeName);
    if(access == null) {
        return new ModelNode();
    }
    OperationStepHandler handler = access.getReadHandler();
    ModelNode path;
    if(handler != null) {
        ClassLoader oldTccl = WildFlySecurityManager.setCurrentContextClassLoaderPrivileged(handler.getClass());
        try {
            handler.execute(context, Util.getReadAttributeOperation(context.getCurrentAddress(), attributeName));
        } finally {
            WildFlySecurityManager.setCurrentContextClassLoaderPrivileged(oldTccl);
        }
        path = context.getResult().clone();
        context.getResult().setEmptyObject();
    } else {
        path = new ModelNode();
    }
    return path;
}
 
开发者ID:wildfly,项目名称:wildfly-core,代码行数:31,代码来源:PathInfoHandler.java

示例8: testRenameAttribute

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

    final ResourceTransformationDescriptionBuilder builder = TransformationDescriptionBuilder.Factory.createInstance(PATH);
        builder.getAttributeBuilder().addRename("old", "new").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(1, model.keys().size());
    Assert.assertEquals("value", model.get("new").asString());

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


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

示例9: transformResource

import org.jboss.as.controller.registry.Resource; //导入方法依赖的package包/类
@Override
void transformResource(final Resource resource, final PathAddress address, final ChainedResourceContext context) throws OperationFailedException {
    final ModelNode model = resource.getModel();
    RejectedAttributesLogContext rejectedAttributes = new RejectedAttributesLogContext(context, address, null);
    doTransform(address, model, null, context, rejectedAttributes);
    if (rejectedAttributes.hasRejections()) {
        rejectedAttributes.errorOrWarnOnResourceTransformation();
    }
    context.invokeNext(resource);
}
 
开发者ID:wildfly,项目名称:wildfly-core,代码行数:11,代码来源:AttributeTransformationRule.java

示例10: transformResource

import org.jboss.as.controller.registry.Resource; //导入方法依赖的package包/类
@Override
public void transformResource(final ResourceTransformationContext context, final PathAddress address, final Resource resource) throws OperationFailedException {
    // Remote the test-resource attribute
    final ModelNode model = resource.getModel();
    final ModelNode testResource = model.remove("test-resource");
    // Add the current resource
    context.addTransformedResource(PathAddress.EMPTY_ADDRESS, resource);
    // Use the test-resource attribute to create a child
    final Resource child = Resource.Factory.create();
    child.getModel().get("attribute").set(testResource);
    context.addTransformedResource(PathAddress.EMPTY_ADDRESS.append(PathElement.pathElement("resource", "test")), child);
    context.processChildren(resource);
}
 
开发者ID:wildfly,项目名称:wildfly-core,代码行数:14,代码来源:BasicResourceTestCase.java

示例11: validateUpdatedModel

import org.jboss.as.controller.registry.Resource; //导入方法依赖的package包/类
@Override
protected void validateUpdatedModel(final OperationContext context, final Resource resource)
        throws OperationFailedException {
    final ModelNode model = resource.getModel();
    final ModelNode relativeTo = DeploymentScannerDefinition.RELATIVE_TO.resolveModelAttribute(context, model);
    if (relativeTo.isDefined()) {
        try {
            PathEntry pathEntry = pathManager.getPathEntry(relativeTo.asString());
        } catch (IllegalArgumentException e) {
            throw DeploymentScannerLogger.ROOT_LOGGER.pathEntryNotFound(relativeTo.asString());
        }
    }
}
 
开发者ID:wildfly,项目名称:wildfly-core,代码行数:14,代码来源:WriteRelativeToAttributeHandler.java

示例12: processProfiles

import org.jboss.as.controller.registry.Resource; //导入方法依赖的package包/类
private void processProfiles(final Resource domain, final String profile, final Set<String> profiles) {
    if (!profiles.contains(profile)) {
        profiles.add(profile);
        final PathElement pathElement = PathElement.pathElement(PROFILE, profile);
        if (domain.hasChild(pathElement)) {
            final Resource resource = domain.getChild(pathElement);
            final ModelNode model = resource.getModel();
            if (model.hasDefined(INCLUDES)) {
                for (final ModelNode include : model.get(INCLUDES).asList()) {
                    processProfiles(domain, include.asString(), profiles);
                }
            }
        }
    }
}
 
开发者ID:wildfly,项目名称:wildfly-core,代码行数:16,代码来源:IgnoredNonAffectedServerGroupsUtil.java

示例13: 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

示例14: 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

示例15: processProfile

import org.jboss.as.controller.registry.Resource; //导入方法依赖的package包/类
static void processProfile(final Resource domain, String profile, Set<String> profiles) {
    if (!profiles.contains(profile)) {
        profiles.add(profile);
        final PathElement pathElement = PathElement.pathElement(PROFILE, profile);
        if (domain.hasChild(pathElement)) {
            final Resource resource = domain.getChild(pathElement);
            final ModelNode model = resource.getModel();
            if (model.hasDefined(INCLUDES)) {
                for (final ModelNode include : model.get(INCLUDES).asList()) {
                    processProfile(domain, include.asString(), profiles);
                }
            }
        }
    }
}
 
开发者ID:wildfly,项目名称:wildfly-core,代码行数:16,代码来源:SyncModelOperationHandlerWrapper.java


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