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


Java ParseUtils.duplicateAttribute方法代码示例

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


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

示例1: parseSystemProperties

import org.jboss.as.controller.parsing.ParseUtils; //导入方法依赖的package包/类
void parseSystemProperties(final XMLExtendedStreamReader reader, final ModelNode address,
        final Namespace expectedNs, final List<ModelNode> updates, boolean standalone) throws XMLStreamException {

    while (reader.nextTag() != END_ELEMENT) {
        requireNamespace(reader, expectedNs);
        final Element element = Element.forName(reader.getLocalName());
        if (element != Element.PROPERTY) {
            throw unexpectedElement(reader);
        }

        boolean setName = false;
        boolean setValue = false;
        boolean setBoottime = false;
        // Will set OP_ADDR after parsing the NAME attribute
        ModelNode op = Util.getEmptyOperation(SystemPropertyAddHandler.OPERATION_NAME, new ModelNode());
        final int count = reader.getAttributeCount();
        String name = null;
        for (int i = 0; i < count; i++) {
            final String val = reader.getAttributeValue(i);
            if (!isNoNamespaceAttribute(reader, i)) {
                throw unexpectedAttribute(reader, i);
            } else {
                final String attribute = reader.getAttributeLocalName(i);

                switch (attribute) {
                    case NAME: {
                        if (setName) {
                            throw ParseUtils.duplicateAttribute(reader, NAME);
                        }
                        setName = true;
                        ModelNode addr = new ModelNode().set(address).add(SYSTEM_PROPERTY, val);
                        op.get(OP_ADDR).set(addr);
                        name = val;
                        break;
                    }
                    case VALUE: {
                        if (setValue) {
                            throw ParseUtils.duplicateAttribute(reader, VALUE);
                        }
                        setValue = true;
                        SystemPropertyResourceDefinition.VALUE.parseAndSetParameter(val, op, reader);
                        break;
                    }
                    case BOOT_TIME: {
                        if (standalone) {
                            throw unexpectedAttribute(reader, i);
                        }
                        if (setBoottime) {
                            throw ParseUtils.duplicateAttribute(reader, BOOT_TIME);
                        }
                        setBoottime = true;
                        SystemPropertyResourceDefinition.BOOT_TIME.parseAndSetParameter(val, op, reader);
                        break;
                    }
                    default: {
                        throw unexpectedAttribute(reader, i);
                    }
                }
            }
        }
        requireNoContent(reader);
        if (!setName) {
            throw ParseUtils.missingRequired(reader, Collections.singleton(NAME));
        }
        if(standalone) {
            //eagerly set the property so it can potentially be used by jboss modules
            //only do this for standalone servers
            try {
                System.setProperty(name, SystemPropertyResourceDefinition.VALUE.resolveValue(ExpressionResolver.SIMPLE, op.get(VALUE)).asString());
            } catch (OperationFailedException e) {
                ServerLogger.AS_ROOT_LOGGER.tracef(e, "Failed to set property %s at parse time, it will be set later in the boot process", name);
            }
        }

        updates.add(op);
    }
}
 
开发者ID:wildfly,项目名称:wildfly-core,代码行数:78,代码来源:SystemPropertiesXml.java

示例2: parseJvmAttributes

import org.jboss.as.controller.parsing.ParseUtils; //导入方法依赖的package包/类
private static String parseJvmAttributes(XMLExtendedStreamReader reader, ModelNode addOp, Set<String> jvmNames, boolean server) throws XMLStreamException {
    // Handle attributes
    String name = null;
    Boolean debugEnabled = null;
    String debugOptions = null;
    final int count = reader.getAttributeCount();
    for (int i = 0; i < count; i++) {
        final String value = reader.getAttributeValue(i);
        if (!isNoNamespaceAttribute(reader, i)) {
            throw ParseUtils.unexpectedAttribute(reader, i);
        } else {
            final Attribute attribute = Attribute.forName(reader.getAttributeLocalName(i));
            switch (attribute) {
                case NAME: {
                    if (name != null)
                        throw ParseUtils.duplicateAttribute(reader, attribute.getLocalName());

                    if (!jvmNames.add(value)) {
                        throw ControllerLogger.ROOT_LOGGER.duplicateDeclaration("JVM", value, reader.getLocation());
                    }
                    name = value;
                    break;
                }
                case JAVA_HOME: {
                    JvmAttributes.JAVA_HOME.parseAndSetParameter(value, addOp, reader);
                    break;
                }
                case TYPE: {
                    try {
                        // Validate the type against the enum
                        JvmAttributes.TYPE.parseAndSetParameter(value, addOp, reader);
                    } catch (final IllegalArgumentException e) {
                        throw ParseUtils.invalidAttributeValue(reader, i);
                    }
                    break;
                }
                case DEBUG_ENABLED: {
                    if (!server) {
                        throw ParseUtils.unexpectedAttribute(reader, i);
                    }
                    debugEnabled = Boolean.valueOf(value);
                    JvmAttributes.DEBUG_ENABLED.parseAndSetParameter(value, addOp, reader);
                    break;
                }
                case DEBUG_OPTIONS: {
                    if (!server) {
                        throw ParseUtils.unexpectedAttribute(reader, i);
                    }
                    debugOptions = value;
                    JvmAttributes.DEBUG_OPTIONS.parseAndSetParameter(value, addOp, reader);
                    break;
                }
                case ENV_CLASSPATH_IGNORED: {
                    JvmAttributes.ENV_CLASSPATH_IGNORED.parseAndSetParameter(value, addOp, reader);
                    break;
                }
                default:
                    throw ParseUtils.unexpectedAttribute(reader, i);
            }
        }
    }
    if (name == null) {
        // FIXME and fix xsd. A name is only required at domain and host
        // level (i.e. when wrapped in <jvms/>). At server-group and server
        // levels it can be unnamed, in which case configuration from
        // domain and host levels aren't mixed in. OR make name required in xsd always
        throw ParseUtils.missingRequired(reader, Collections.singleton(Attribute.NAME));
    }
    if (debugEnabled != null && debugOptions == null && debugEnabled) {
        throw ParseUtils.missingRequired(reader, EnumSet.of(Attribute.DEBUG_OPTIONS));
    }

    return name;
}
 
开发者ID:wildfly,项目名称:wildfly-core,代码行数:75,代码来源:JvmXml.java


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