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


Java Resource.writeModel方法代码示例

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


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

示例1: getHCResource

import org.jboss.as.controller.registry.Resource; //导入方法依赖的package包/类
private static Resource getHCResource(boolean domainRollout) {
    Resource host = Resource.Factory.create(true);
    ModelNode model = new ModelNode();
    model.get(EXCLUSIVE_RUNNING_TIME).set(100);
    model.get(DOMAIN_ROLLOUT).set(domainRollout);
    model.get(EXECUTION_STATUS).set(OperationContext.ExecutionStatus.COMPLETING.toString());
    model.get(DOMAIN_UUID).set("uuid");
    host.writeModel(model);
    return host;
}
 
开发者ID:wildfly,项目名称:wildfly-core,代码行数:11,代码来源:FindNonProgressingOpUnitTestCase.java

示例2: getServerResource

import org.jboss.as.controller.registry.Resource; //导入方法依赖的package包/类
private static Resource getServerResource(long runningTime) {
    Resource server = Resource.Factory.create(true);
    ModelNode model = new ModelNode();
    model.get(RUNNING_TIME).set(runningTime);
    model.get(DOMAIN_ROLLOUT).set(true);
    model.get(EXECUTION_STATUS).set(OperationContext.ExecutionStatus.EXECUTING.toString());
    model.get(DOMAIN_UUID).set("uuid");
    server.writeModel(model);
    return server;
}
 
开发者ID:wildfly,项目名称:wildfly-core,代码行数:11,代码来源:FindNonProgressingOpUnitTestCase.java

示例3: addTransformedResourceFromRoot

import org.jboss.as.controller.registry.Resource; //导入方法依赖的package包/类
private ResourceTransformationContext addTransformedResourceFromRoot(PathAddress absoluteAddress, PathAddress read, Resource toAdd) {
    // Only keep the mode, drop all children
    final Resource copy;
    if (toAdd != null) {
        copy = Resource.Factory.create(false, toAdd.getOrderedChildTypes());
        copy.writeModel(toAdd.getModel());
    } else {
        copy = Resource.Factory.create();
    }
    return addTransformedRecursiveResourceFromRoot(absoluteAddress, read, copy);
}
 
开发者ID:wildfly,项目名称:wildfly-core,代码行数:12,代码来源:ResourceTransformationContextImpl.java

示例4: execute

import org.jboss.as.controller.registry.Resource; //导入方法依赖的package包/类
@Override
public void execute(OperationContext context, ModelNode operation) throws OperationFailedException {

    final Resource resource = context.readResourceForUpdate(PathAddress.EMPTY_ADDRESS);
    final byte[] oldHash = ManagedDMRContentResourceDefinition.HASH.validateOperation(operation).asBytes();
    final byte[] currentHash = resource.getModel().get(ManagedDMRContentResourceDefinition.HASH.getName()).asBytes();
    if (!Arrays.equals(oldHash, currentHash)) {
        throw ManagedDMRContentLogger.ROOT_LOGGER.invalidHash(HashUtil.bytesToHexString(oldHash), PathAddress.pathAddress(operation.require(ModelDescriptionConstants.OP_ADDR)), HashUtil.bytesToHexString(currentHash));
    }
    ModelNode model = new ModelNode();
    contentAttribute.validateAndSet(operation, model);

    // IMPORTANT: Use writeModel, as this is what causes the content to be flushed to the content repo!
    resource.writeModel(model);
}
 
开发者ID:wildfly,项目名称:wildfly-core,代码行数:16,代码来源:ManagedDMRContentStoreHandler.java

示例5: execute

import org.jboss.as.controller.registry.Resource; //导入方法依赖的package包/类
@Override
public void execute(OperationContext context, ModelNode operation) throws OperationFailedException {

    ModelNode model = new ModelNode();
    ModelNode synthOp = new ModelNode();
    synthOp.get(contentAttribute.getName()).set(operation.get(ModelDescriptionConstants.VALUE));
    contentAttribute.validateAndSet(synthOp, model);

    final Resource resource = context.readResourceForUpdate(PathAddress.EMPTY_ADDRESS);
    // IMPORTANT: Use writeModel, as this is what causes the content to be flushed to the content repo!
    resource.writeModel(model);
}
 
开发者ID:wildfly,项目名称:wildfly-core,代码行数:13,代码来源:ManagedDMRContentWriteAttributeHandler.java

示例6: populateModel

import org.jboss.as.controller.registry.Resource; //导入方法依赖的package包/类
@Override
public void populateModel(Resource rootResource) {
    Resource host = Resource.Factory.create();
    rootResource.registerChild(HOST_ELEMENT, host);
    ModelNode serverConfig = new ModelNode();
    serverConfig.get(GROUP).set("test");
    Resource server1 = Resource.Factory.create();
    server1.writeModel(serverConfig);
    Resource server2 = Resource.Factory.create();
    server2.writeModel(serverConfig);
    host.registerChild(SERVER_ONE_ELEMENT, server1);
    host.registerChild(SERVER_TWO_ELEMENT, server2);
}
 
开发者ID:wildfly,项目名称:wildfly-core,代码行数:14,代码来源:HostServerJvmModelTestCase.java

示例7: createEmptyModelInitalizer

import org.jboss.as.controller.registry.Resource; //导入方法依赖的package包/类
@Override
protected ModelInitializer createEmptyModelInitalizer() {
    return new ModelInitializer() {
        @Override
        public void populateModel(Resource rootResource) {
            Resource host = Resource.Factory.create();
            rootResource.registerChild(PARENT.getLastElement(), host);
            ModelNode serverConfig = new ModelNode();
            serverConfig.get(GROUP).set("test");
            Resource server1 = Resource.Factory.create();
            server1.writeModel(serverConfig);
            host.registerChild(getPathsParent().getLastElement(), server1);
        }
    };
}
 
开发者ID:wildfly,项目名称:wildfly-core,代码行数:16,代码来源:HostServerSpecifiedPathsTestCase.java

示例8: initModel

import org.jboss.as.controller.registry.Resource; //导入方法依赖的package包/类
protected Resource initModel(final ManagementModel managementModel) {
    this.managementModel = managementModel;
    ManagementResourceRegistration rootRegistration = managementModel.getRootResourceRegistration();
    //Use the saved hostResourceDefinition
    hostRegistration = rootRegistration.registerSubModel(hostResourceDefinition);

    rootRegistration.registerOperationHandler(TRIGGER_SYNC, new TriggerSyncHandler());
    GlobalOperationHandlers.registerGlobalOperations(rootRegistration, processType);
    rootRegistration.registerOperationHandler(CompositeOperationHandler.DEFINITION, CompositeOperationHandler.INSTANCE);


    Resource rootResource = managementModel.getRootResource();
    CoreManagementResourceDefinition.registerDomainResource(rootResource, null);

    final Resource host = Resource.Factory.create();
    final Resource serverOneConfig = Resource.Factory.create();
    final ModelNode serverOneModel = new ModelNode();
    serverOneModel.get(GROUP).set("group-one");
    serverOneModel.get(SOCKET_BINDING_GROUP).set("binding-one");
    serverOneConfig.writeModel(serverOneModel);
    host.registerChild(PathElement.pathElement(SERVER_CONFIG, "server-one"), serverOneConfig);

    final Resource serverTwoConfig = Resource.Factory.create();
    final ModelNode serverTwoModel = new ModelNode();
    serverTwoModel.get(GROUP).set("group-one");
    serverTwoConfig.writeModel(serverTwoModel);
    host.registerChild(PathElement.pathElement(SERVER_CONFIG, "server-two"), serverTwoConfig);

    final Resource serverThreeConfig = Resource.Factory.create();
    final ModelNode serverThreeModel = new ModelNode();
    serverThreeModel.get(GROUP).set("group-two");
    serverThreeConfig.writeModel(serverThreeModel);
    host.registerChild(PathElement.pathElement(SERVER_CONFIG, "server-three"), serverThreeConfig);

    rootResource.registerChild(PathElement.pathElement(HOST, hostName), host);
    final Resource serverGroup1 = Resource.Factory.create();
    serverGroup1.getModel().get(PROFILE).set("profile-one");
    serverGroup1.getModel().get(SOCKET_BINDING_GROUP).set("binding-one");
    rootResource.registerChild(PathElement.pathElement(SERVER_GROUP, "group-one"), serverGroup1);

    final Resource serverGroup2 = Resource.Factory.create();
    serverGroup2.getModel().get(PROFILE).set("profile-two");
    serverGroup2.getModel().get(SOCKET_BINDING_GROUP).set("binding-two");
    rootResource.registerChild(PathElement.pathElement(SERVER_GROUP, "group-two"), serverGroup2);

    final Resource profile1 = Resource.Factory.create();
    profile1.getModel().setEmptyObject();
    rootResource.registerChild(PathElement.pathElement(PROFILE, "profile-one"), profile1);
    final Resource profile2 = Resource.Factory.create();
    profile2.getModel().setEmptyObject();
    rootResource.registerChild(PathElement.pathElement(PROFILE, "profile-two"), profile2);

    final Resource binding1 = Resource.Factory.create();
    binding1.getModel().setEmptyObject();
    rootResource.registerChild(PathElement.pathElement(SOCKET_BINDING_GROUP, "binding-one"), binding1);
    final Resource binding2 = Resource.Factory.create();
    binding2.getModel().setEmptyObject();
    rootResource.registerChild(PathElement.pathElement(SOCKET_BINDING_GROUP, "binding-two"), binding2);

    registerServer("server-one");
    registerServer("server-two");
    registerServer("server-three");
    return rootResource;
}
 
开发者ID:wildfly,项目名称:wildfly-core,代码行数:65,代码来源:SyncModelServerStateTestCase.java

示例9: createRootResource

import org.jboss.as.controller.registry.Resource; //导入方法依赖的package包/类
static Resource createRootResource() {
    final Resource rootResource = Resource.Factory.create();

    CoreManagementResourceDefinition.registerDomainResource(rootResource, null);

    final Resource host = Resource.Factory.create();
    final Resource serverOneConfig = Resource.Factory.create();
    final ModelNode serverOneModel = new ModelNode();
    serverOneModel.get(GROUP).set("group-one");
    serverOneModel.get(SOCKET_BINDING_GROUP).set("binding-one");
    serverOneConfig.writeModel(serverOneModel);
    host.registerChild(PathElement.pathElement(SERVER_CONFIG, "server-one"), serverOneConfig);

    final Resource serverTwoConfig = Resource.Factory.create();
    final ModelNode serverTwoModel = new ModelNode();
    serverTwoModel.get(GROUP).set("group-one");
    serverTwoConfig.writeModel(serverTwoModel);
    host.registerChild(PathElement.pathElement(SERVER_CONFIG, "server-two"), serverTwoConfig);

    final Resource serverThreeConfig = Resource.Factory.create();
    final ModelNode serverThreeModel = new ModelNode();
    serverThreeModel.get(GROUP).set("group-two");
    serverThreeConfig.writeModel(serverThreeModel);
    host.registerChild(PathElement.pathElement(SERVER_CONFIG, "server-three"), serverThreeConfig);

    rootResource.registerChild(PathElement.pathElement(HOST, "localhost"), host);

    final Resource serverGroup1 = Resource.Factory.create();
    serverGroup1.getModel().get(PROFILE).set("profile-one");
    serverGroup1.getModel().get(SOCKET_BINDING_GROUP).set("binding-one");
    rootResource.registerChild(PathElement.pathElement(SERVER_GROUP, "group-one"), serverGroup1);

    final Resource serverGroup2 = Resource.Factory.create();
    serverGroup2.getModel().get(PROFILE).set("profile-two");
    serverGroup2.getModel().get(SOCKET_BINDING_GROUP).set("binding-two");
    rootResource.registerChild(PathElement.pathElement(SERVER_GROUP, "group-two"), serverGroup2);

    final Resource profile1 = Resource.Factory.create();
    profile1.getModel().setEmptyObject();
    rootResource.registerChild(PathElement.pathElement(PROFILE, "profile-one"), profile1);
    final Resource profile2 = Resource.Factory.create();
    profile2.getModel().setEmptyObject();
    rootResource.registerChild(PathElement.pathElement(PROFILE, "profile-two"), profile2);

    final Resource binding1 = Resource.Factory.create();
    binding1.getModel().setEmptyObject();
    rootResource.registerChild(PathElement.pathElement(SOCKET_BINDING_GROUP, "binding-one"), binding1);
    final Resource binding2 = Resource.Factory.create();
    binding2.getModel().setEmptyObject();
    rootResource.registerChild(PathElement.pathElement(SOCKET_BINDING_GROUP, "binding-two"), binding2);

    final Resource management = rootResource.getChild(PathElement.pathElement(CORE_SERVICE, MANAGEMENT));
    final Resource accessControl = management.getChild(AccessAuthorizationResourceDefinition.PATH_ELEMENT);

    final Resource superUser = Resource.Factory.create();
    accessControl.registerChild(PathElement.pathElement(ROLE_MAPPING, "SuperUser"), superUser);
    final Resource include = Resource.Factory.create();
    superUser.registerChild(PathElement.pathElement(INCLUDE, "user-$local"), include);
    include.getModel().get("name").set("local");

    hack(rootResource, EXTENSION);
    hack(rootResource, PATH);
    hack(rootResource, SYSTEM_PROPERTY);
    hack(rootResource, INTERFACE);
    hack(rootResource, DEPLOYMENT);
    return rootResource;
}
 
开发者ID:wildfly,项目名称:wildfly-core,代码行数:68,代码来源:AbstractOperationTestCase.java

示例10: addTransformedRecursiveResourceFromRoot

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


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