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


Java AttributeDefinition.validateOperation方法代码示例

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


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

示例1: validate

import org.jboss.as.controller.AttributeDefinition; //导入方法依赖的package包/类
@Override
public void validate(ModelNode operation) throws OperationFailedException {
    super.validate(operation);
    for (AttributeDefinition def : DEFINITION.getParameters()) {
        def.validateOperation(operation);
    }
    if (operation.hasDefined(ModelDescriptionConstants.ATTRIBUTES_ONLY)) {
        if (operation.hasDefined(ModelDescriptionConstants.RECURSIVE)) {
            throw ControllerLogger.ROOT_LOGGER.cannotHaveBothParameters(ModelDescriptionConstants.ATTRIBUTES_ONLY, ModelDescriptionConstants.RECURSIVE);
        }
        if (operation.hasDefined(ModelDescriptionConstants.RECURSIVE_DEPTH)) {
            throw ControllerLogger.ROOT_LOGGER.cannotHaveBothParameters(ModelDescriptionConstants.ATTRIBUTES_ONLY, ModelDescriptionConstants.RECURSIVE_DEPTH);
        }
    }
    if( operation.hasDefined(ModelDescriptionConstants.RESOLVE_EXPRESSIONS)){
        if(operation.get(ModelDescriptionConstants.RESOLVE_EXPRESSIONS).asBoolean(false) && !resolvable){
            throw ControllerLogger.ROOT_LOGGER.unableToResolveExpressions();
        }
    }
}
 
开发者ID:wildfly,项目名称:wildfly-core,代码行数:21,代码来源:ReadResourceHandler.java

示例2: execute

import org.jboss.as.controller.AttributeDefinition; //导入方法依赖的package包/类
@Override
public void execute(final OperationContext context, final ModelNode operation) throws OperationFailedException {
    final String fileName = LoggingOperations.getAddressName(operation);
    final String logDir = pathManager.getPathEntry(ServerEnvironment.SERVER_LOG_DIR).resolvePath();
    validateFile(context, logDir, fileName);
    // Validate the operation
    for (AttributeDefinition attribute : READ_LOG_FILE.getParameters()) {
        attribute.validateOperation(operation);
    }
    final int numberOfLines = LINES.resolveModelAttribute(context, operation).asInt();
    final int skip = SKIP.resolveModelAttribute(context, operation).asInt();
    final boolean tail = TAIL.resolveModelAttribute(context, operation).asBoolean();
    final ModelNode encodingModel = ENCODING.resolveModelAttribute(context, operation);
    final String encoding = (encodingModel.isDefined() ? encodingModel.asString() : null);
    final File path = new File(pathManager.resolveRelativePathEntry(fileName, ServerEnvironment.SERVER_LOG_DIR));

    // The file must exist
    if (!path.exists()) {
        throw LoggingLogger.ROOT_LOGGER.logFileNotFound(fileName, ServerEnvironment.SERVER_LOG_DIR);
    }

    // Read the contents of the log file
    try {
        final List<String> lines;
        if (numberOfLines == 0) {
            lines = Collections.emptyList();
        } else {
            lines = readLines(path, encoding, tail, skip, numberOfLines);
        }
        final ModelNode result = context.getResult().setEmptyList();
        for (String line : lines) {
            result.add(line);
        }
    } catch (IOException e) {
        throw LoggingLogger.ROOT_LOGGER.failedToReadLogFile(e, fileName);
    }
    context.completeStep(ResultHandler.NOOP_RESULT_HANDLER);
}
 
开发者ID:wildfly,项目名称:wildfly-core,代码行数:39,代码来源:LogFileResourceDefinition.java

示例3: validate

import org.jboss.as.controller.AttributeDefinition; //导入方法依赖的package包/类
@Override
public void validate(ModelNode operation) throws OperationFailedException {
    super.validate(operation);
    for (AttributeDefinition def : DEFINITION.getParameters()) {
        def.validateOperation(operation);
    }
    if( operation.hasDefined(ModelDescriptionConstants.RESOLVE_EXPRESSIONS)){
        if(operation.get(ModelDescriptionConstants.RESOLVE_EXPRESSIONS).asBoolean(false) && !resolvable){
            throw ControllerLogger.ROOT_LOGGER.unableToResolveExpressions();
        }
    }
}
 
开发者ID:wildfly,项目名称:wildfly-core,代码行数:13,代码来源:ReadAttributeGroupHandler.java

示例4: validateParameter

import org.jboss.as.controller.AttributeDefinition; //导入方法依赖的package包/类
@Override
public void validateParameter(String parameterName, ModelNode contentItemNode) throws OperationFailedException {
    for (String key : contentItemNode.keys()) {
        if (ignoredParameters.contains(key)) {
            continue;
        }
        AttributeDefinition def = MANAGED_CONTENT_ATTRIBUTES.get(key);
        if (def == null) {
            throw ServerLogger.ROOT_LOGGER.unknownContentItemKey(key);
        }
        def.validateOperation(contentItemNode);
        if (contentItemNode.hasDefined(key)) {
            String[] alts = def.getAlternatives();
            if (alts != null && alts.length > 0) {
                for (String alt : alts) {
                    if (contentItemNode.hasDefined(alt)) {
                        throw ServerLogger.ROOT_LOGGER.cannotHaveMoreThanOneManagedContentItem(MANAGED_CONTENT_ATTRIBUTES.keySet());
                    }
                }
            }
            String[] reqs = def.getRequires();
            if (reqs != null && reqs.length > 0) {
                boolean hasReq = false;
                for (String req : reqs) {
                    if (contentItemNode.hasDefined(req)) {
                        hasReq = true;
                        break;
                    }
                }
                if (!hasReq) {
                    throw ServerLogger.ROOT_LOGGER.nullParameter(reqs[0]);
                }
            }
        }
    }
}
 
开发者ID:wildfly,项目名称:wildfly-core,代码行数:37,代码来源:DeploymentAttributes.java

示例5: execute

import org.jboss.as.controller.AttributeDefinition; //导入方法依赖的package包/类
public void execute(OperationContext context, ModelNode operation) throws OperationFailedException {
    for (AttributeDefinition def : DeploymentAttributes.REPLACE_DEPLOYMENT_ATTRIBUTES.values()) {
        def.validateOperation(operation);
    }
    String name = DeploymentAttributes.REPLACE_DEPLOYMENT_ATTRIBUTES.get(NAME).resolveModelAttribute(context, operation).asString();
    String toReplace = DeploymentAttributes.REPLACE_DEPLOYMENT_ATTRIBUTES.get(TO_REPLACE).resolveModelAttribute(context, operation).asString();

    if (name.equals(toReplace)) {
        throw ServerLogger.ROOT_LOGGER.cannotReplaceDeployment(OPERATION_NAME, NAME, TO_REPLACE,
                DeploymentRedeployHandler.OPERATION_NAME, DeploymentFullReplaceHandler.OPERATION_NAME);
    }

    final PathElement deployPath = PathElement.pathElement(DEPLOYMENT, name);
    final PathElement replacePath = PathElement.pathElement(DEPLOYMENT, toReplace);

    final Resource root = context.readResource(PathAddress.EMPTY_ADDRESS);
    if (! root.hasChild(replacePath)) {
        throw ServerLogger.ROOT_LOGGER.noSuchDeployment(toReplace);
    }

    final ModelNode replaceNode = context.readResourceForUpdate(PathAddress.pathAddress(replacePath)).getModel();
    final String replacedName = DeploymentAttributes.REPLACE_DEPLOYMENT_ATTRIBUTES.get(RUNTIME_NAME).resolveModelAttribute(context, replaceNode).asString();

    ModelNode deployNode;
    String runtimeName;
    if (!root.hasChild(deployPath)) {
        if (!operation.hasDefined(CONTENT)) {
            throw ServerLogger.ROOT_LOGGER.noSuchDeployment(name);
        }
        // else -- the HostController handles a server group replace-deployment like an add, so we do too

        final ModelNode content = operation.require(CONTENT);
        // TODO: JBAS-9020: for the moment overlays are not supported, so there is a single content item
        final ModelNode contentItemNode = content.require(0);
        if (contentItemNode.hasDefined(HASH)) {
            byte[] hash = contentItemNode.require(HASH).asBytes();
            addFromHash(ModelContentReference.fromDeploymentName(name, hash));
        } else {
        }
        runtimeName = operation.hasDefined(RUNTIME_NAME) ? DeploymentAttributes.REPLACE_DEPLOYMENT_ATTRIBUTES.get(RUNTIME_NAME).resolveModelAttribute(context, operation).asString() : replacedName;

        // Create the resource
        final Resource deployResource = context.createResource(PathAddress.pathAddress(deployPath));
        deployNode = deployResource.getModel();
        deployNode.get(RUNTIME_NAME).set(runtimeName);

        //TODO Assumes this can only be set by client
        deployNode.get(ModelDescriptionConstants.PERSISTENT).set(true);

        deployNode.get(CONTENT).set(content);

    } else {
        deployNode = context.readResourceForUpdate(PathAddress.pathAddress(deployPath)).getModel();
        if (ENABLED.resolveModelAttribute(context, deployNode).asBoolean()) {
            throw ServerLogger.ROOT_LOGGER.deploymentAlreadyStarted(toReplace);
        }
        runtimeName = deployNode.require(RUNTIME_NAME).asString();
    }

    deployNode.get(ENABLED.getName()).set(true);
    replaceNode.get(ENABLED.getName()).set(false);

    final DeploymentHandlerUtil.ContentItem[] contents = getContents(deployNode.require(CONTENT));
    DeploymentHandlerUtil.replace(context, replaceNode, runtimeName, name, replacedName, vaultReader, contents);
}
 
开发者ID:wildfly,项目名称:wildfly-core,代码行数:66,代码来源:DeploymentReplaceHandler.java


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