Java Code Examples for org.jboss.as.controller.parsing.ParseUtils#duplicateNamedElement()

The following examples show how to use org.jboss.as.controller.parsing.ParseUtils#duplicateNamedElement() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: JMXExtension.java    From wildfly-core with GNU Lesser General Public License v2.1 6 votes vote down vote up
/**
 * {@inheritDoc}
 */
@Override
public void readElement(XMLExtendedStreamReader reader, List<ModelNode> list) throws XMLStreamException {
    ParseUtils.requireNoAttributes(reader);
    list.add(createAddOperation());

    boolean gotConnector = false;

    while (reader.hasNext() && reader.nextTag() != END_ELEMENT) {
        final String element = reader.getLocalName();
        switch (element) {
            case CommonAttributes.JMX_CONNECTOR: {
                if (gotConnector) {
                    throw ParseUtils.duplicateNamedElement(reader, CommonAttributes.JMX_CONNECTOR);
                }
                parseConnector(reader);
                gotConnector = true;
                break;
            }
            default: {
                throw ParseUtils.unexpectedElement(reader);
            }
        }
    }
}
 
Example 2
Source File: JvmXml.java    From wildfly-core with GNU Lesser General Public License v2.1 5 votes vote down vote up
private static void parsePermgen(final XMLExtendedStreamReader reader, ModelNode addOp)
        throws XMLStreamException {

    // Handle attributes
    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 SIZE: {
                    if (checkParseAndSetParameter(JvmAttributes.PERMGEN_SIZE, value, addOp, reader)) {
                        throw ParseUtils.duplicateNamedElement(reader, reader.getLocalName());
                    }
                    break;
                }
                case MAX_SIZE: {
                    if (checkParseAndSetParameter(JvmAttributes.MAX_PERMGEN_SIZE, value, addOp, reader)) {
                        throw ParseUtils.duplicateNamedElement(reader, reader.getLocalName());
                    }
                    break;
                }
                default:
                    throw ParseUtils.unexpectedAttribute(reader, i);
            }
        }
    }

    // Handle elements
    requireNoContent(reader);
}
 
Example 3
Source File: JvmXml.java    From wildfly-core with GNU Lesser General Public License v2.1 5 votes vote down vote up
private static void parseJavaagent(final XMLExtendedStreamReader reader, ModelNode addOp)
        throws XMLStreamException {

    // Handle attributes
    boolean valueSet = false;
    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 VALUE: {
                    if (checkParseAndSetParameter(JvmAttributes.JAVA_AGENT, value, addOp, reader)) {
                        throw ParseUtils.duplicateNamedElement(reader, reader.getLocalName());
                    }
                    valueSet = true;
                    break;
                }
                default:
                    throw ParseUtils.unexpectedAttribute(reader, i);
            }
        }
    }
    if (!valueSet) {
        throw ParseUtils.missingRequired(reader, Collections.singleton(Attribute.VALUE));
    }
    // Handle elements
    requireNoContent(reader);
}
 
Example 4
Source File: JvmXml.java    From wildfly-core with GNU Lesser General Public License v2.1 5 votes vote down vote up
private static void parseAgentPath(final XMLExtendedStreamReader reader, ModelNode addOp)
        throws XMLStreamException {

    // Handle attributes
    boolean valueSet = false;
    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 VALUE: {
                    if (checkParseAndSetParameter(JvmAttributes.AGENT_PATH, value, addOp, reader)){
                        throw ParseUtils.duplicateNamedElement(reader, reader.getLocalName());
                    }
                    valueSet = true;
                    break;
                }
                default:
                    throw ParseUtils.unexpectedAttribute(reader, i);
            }
        }
    }
    if (!valueSet) {
        throw ParseUtils.missingRequired(reader, Collections.singleton(Attribute.VALUE));
    }
    // Handle elements
    requireNoContent(reader);
}
 
Example 5
Source File: JMXExtension.java    From wildfly-core with GNU Lesser General Public License v2.1 5 votes vote down vote up
@Override
public void readElement(XMLExtendedStreamReader reader, List<ModelNode> list) throws XMLStreamException {
    boolean showResolvedModel = false;
    boolean showExpressionModel = false;
    boolean connectorAdd = false;

    ParseUtils.requireNoAttributes(reader);

    list.add(createAddOperation());

    while (reader.hasNext() && reader.nextTag() != END_ELEMENT) {
        final String element = reader.getLocalName();
        switch (element) {
            case CommonAttributes.EXPOSE_RESOLVED_MODEL:
                if (showResolvedModel) {
                    throw ParseUtils.duplicateNamedElement(reader, CommonAttributes.EXPOSE_RESOLVED_MODEL);
                }
                showResolvedModel = true;
                list.add(parseShowModelElement(reader, CommonAttributes.RESOLVED));
                break;
            case CommonAttributes.EXPOSE_EXPRESSION_MODEL:
                if (showExpressionModel) {
                    throw ParseUtils.duplicateNamedElement(reader, CommonAttributes.EXPOSE_EXPRESSION_MODEL);
                }
                showExpressionModel = true;
                list.add(parseShowModelElement(reader, CommonAttributes.EXPRESSION));
                break;
            case REMOTING_CONNECTOR:
                if (connectorAdd) {
                    throw ParseUtils.duplicateNamedElement(reader, CommonAttributes.REMOTING_CONNECTOR);
                }
                connectorAdd = true;
                list.add(parseRemoteConnector(reader));
                break;
            default: {
                throw ParseUtils.unexpectedElement(reader);
            }
        }
    }
}
 
Example 6
Source File: HostXml_10.java    From wildfly-core with GNU Lesser General Public License v2.1 4 votes vote down vote up
private ModelNode parseDiscoveryOptionAttributes(final XMLExtendedStreamReader reader, final ModelNode address,
                                                 final List<ModelNode> list, final Set<String> discoveryOptionNames) throws XMLStreamException {

    // OP_ADDR will be set after parsing the NAME attribute
    final ModelNode discoveryOptionAddress = address.clone();
    discoveryOptionAddress.add(CORE_SERVICE, DISCOVERY_OPTIONS);
    final ModelNode addOp = Util.getEmptyOperation(ADD, new ModelNode());
    list.add(addOp);

    final Set<Attribute> required = EnumSet.of(Attribute.NAME, Attribute.CODE);
    final int count = reader.getAttributeCount();
    for (int i = 0; i < count; i++) {
        requireNoNamespaceAttribute(reader, i);
        final String value = reader.getAttributeValue(i);
        final Attribute attribute = Attribute.forName(reader.getAttributeLocalName(i));
        required.remove(attribute);
        switch (attribute) {
            case NAME: {
                if (!discoveryOptionNames.add(value)) {
                    throw ParseUtils.duplicateNamedElement(reader, value);
                }
                addOp.get(OP_ADDR).set(discoveryOptionAddress).add(DISCOVERY_OPTION, value);
                break;
            }
            case CODE: {
                DiscoveryOptionResourceDefinition.CODE.parseAndSetParameter(value, addOp, reader);
                break;
            }
            case MODULE: {
                DiscoveryOptionResourceDefinition.MODULE.parseAndSetParameter(value, addOp, reader);
                break;
            }
            default:
                throw unexpectedAttribute(reader, i);
        }
    }

    if (required.size() > 0) {
        throw missingRequired(reader, required);
    }

    return addOp;
}
 
Example 7
Source File: RemotingSubsystem20Parser.java    From wildfly-core with GNU Lesser General Public License v2.1 4 votes vote down vote up
@Override
public void readElement(XMLExtendedStreamReader reader, List<ModelNode> list) throws XMLStreamException {

    final PathAddress address = PathAddress.pathAddress(SUBSYSTEM, RemotingExtension.SUBSYSTEM_NAME);
    final ModelNode subsystem = Util.createAddOperation(address);
    list.add(subsystem);

    requireAttributes(reader);
    boolean foundEndpoint = false;
    // Handle elements
    boolean doneWorkerThreadPool = false;
    while (reader.hasNext() && reader.nextTag() != END_ELEMENT) {
        final Element element = Element.forName(reader.getLocalName());
        switch (element) {
            case WORKER_THREAD_POOL:
                if (doneWorkerThreadPool) {
                    throw ParseUtils.duplicateNamedElement(reader, Element.WORKER_THREAD_POOL.getLocalName());
                }
                if (foundEndpoint) {
                    throw workerThreadPoolEndpointChoiceRequired(reader);
                }
                doneWorkerThreadPool = true;
                parseWorkerThreadPool(reader, subsystem);
                break;
            case ENDPOINT:
                if (doneWorkerThreadPool) {
                    throw workerThreadPoolEndpointChoiceRequired(reader);
                }
                parseEndpoint(reader, subsystem);
                foundEndpoint = true;
                break;
            case CONNECTOR: {
                // Add connector updates
                parseConnector(reader, address.toModelNode(), list);
                break;
            }
            case HTTP_CONNECTOR: {
                // Add http connector updates
                parseHttpConnector(reader, address.toModelNode(), list);
                break;
            }
            case OUTBOUND_CONNECTIONS: {
                // parse the outbound-connections
                this.parseOutboundConnections(reader, address.toModelNode(), list);
                break;
            }
            default: {
                throw unexpectedElement(reader);
            }
        }
    }
}
 
Example 8
Source File: HostXml_12.java    From wildfly-core with GNU Lesser General Public License v2.1 4 votes vote down vote up
protected void parseStaticDiscoveryOption(final XMLExtendedStreamReader reader, final ModelNode address, final List<ModelNode> list, final Set<String> staticDiscoveryOptionNames) throws XMLStreamException {

        // OP_ADDR will be set after parsing the NAME attribute
        final ModelNode staticDiscoveryOptionAddress = address.clone();
        staticDiscoveryOptionAddress.add(CORE_SERVICE, DISCOVERY_OPTIONS);
        final ModelNode addOp = Util.getEmptyOperation(ADD, new ModelNode());
        list.add(addOp);

        // Handle attributes
        final Set<Attribute> required = EnumSet.of(Attribute.NAME, Attribute.HOST, Attribute.PORT);
        final int count = reader.getAttributeCount();
        for (int i = 0; i < count; i++) {
            requireNoNamespaceAttribute(reader, i);
            final String value = reader.getAttributeValue(i);
            final Attribute attribute = Attribute.forName(reader.getAttributeLocalName(i));
            required.remove(attribute);
            switch (attribute) {
                case NAME: {
                    if (!staticDiscoveryOptionNames.add(value)) {
                        throw ParseUtils.duplicateNamedElement(reader, value);
                    }
                    addOp.get(OP_ADDR).set(staticDiscoveryOptionAddress).add(STATIC_DISCOVERY, value);
                    break;
                }
                case HOST: {
                    StaticDiscoveryResourceDefinition.HOST.parseAndSetParameter(value, addOp, reader);
                    break;
                }
                case PROTOCOL: {
                    StaticDiscoveryResourceDefinition.PROTOCOL.parseAndSetParameter(value, addOp, reader);
                    break;
                }
                case PORT: {
                    StaticDiscoveryResourceDefinition.PORT.parseAndSetParameter(value, addOp, reader);
                    break;
                }
                default:
                    throw unexpectedAttribute(reader, i);
            }
        }

        if (required.size() > 0) {
            throw missingRequired(reader, required);
        }

        requireNoContent(reader);
    }
 
Example 9
Source File: HostXml_11.java    From wildfly-core with GNU Lesser General Public License v2.1 4 votes vote down vote up
private ModelNode parseDiscoveryOptionAttributes(final XMLExtendedStreamReader reader, final ModelNode address,
                                                 final List<ModelNode> list, final Set<String> discoveryOptionNames) throws XMLStreamException {

    // OP_ADDR will be set after parsing the NAME attribute
    final ModelNode discoveryOptionAddress = address.clone();
    discoveryOptionAddress.add(CORE_SERVICE, DISCOVERY_OPTIONS);
    final ModelNode addOp = Util.getEmptyOperation(ADD, new ModelNode());
    list.add(addOp);

    final Set<Attribute> required = EnumSet.of(Attribute.NAME, Attribute.CODE);
    final int count = reader.getAttributeCount();
    for (int i = 0; i < count; i++) {
        requireNoNamespaceAttribute(reader, i);
        final String value = reader.getAttributeValue(i);
        final Attribute attribute = Attribute.forName(reader.getAttributeLocalName(i));
        required.remove(attribute);
        switch (attribute) {
            case NAME: {
                if (!discoveryOptionNames.add(value)) {
                    throw ParseUtils.duplicateNamedElement(reader, value);
                }
                addOp.get(OP_ADDR).set(discoveryOptionAddress).add(DISCOVERY_OPTION, value);
                break;
            }
            case CODE: {
                DiscoveryOptionResourceDefinition.CODE.parseAndSetParameter(value, addOp, reader);
                break;
            }
            case MODULE: {
                DiscoveryOptionResourceDefinition.MODULE.parseAndSetParameter(value, addOp, reader);
                break;
            }
            default:
                throw unexpectedAttribute(reader, i);
        }
    }

    if (required.size() > 0) {
        throw missingRequired(reader, required);
    }

    return addOp;
}
 
Example 10
Source File: HostXml_14.java    From wildfly-core with GNU Lesser General Public License v2.1 4 votes vote down vote up
protected void parseStaticDiscoveryOption(final XMLExtendedStreamReader reader, final ModelNode address, final List<ModelNode> list, final Set<String> staticDiscoveryOptionNames) throws XMLStreamException {

        // OP_ADDR will be set after parsing the NAME attribute
        final ModelNode staticDiscoveryOptionAddress = address.clone();
        staticDiscoveryOptionAddress.add(CORE_SERVICE, DISCOVERY_OPTIONS);
        final ModelNode addOp = Util.getEmptyOperation(ADD, new ModelNode());
        list.add(addOp);

        // Handle attributes
        final Set<Attribute> required = EnumSet.of(Attribute.NAME, Attribute.HOST, Attribute.PORT);
        final int count = reader.getAttributeCount();
        for (int i = 0; i < count; i++) {
            requireNoNamespaceAttribute(reader, i);
            final String value = reader.getAttributeValue(i);
            final Attribute attribute = Attribute.forName(reader.getAttributeLocalName(i));
            required.remove(attribute);
            switch (attribute) {
                case NAME: {
                    if (!staticDiscoveryOptionNames.add(value)) {
                        throw ParseUtils.duplicateNamedElement(reader, value);
                    }
                    addOp.get(OP_ADDR).set(staticDiscoveryOptionAddress).add(STATIC_DISCOVERY, value);
                    break;
                }
                case HOST: {
                    StaticDiscoveryResourceDefinition.HOST.parseAndSetParameter(value, addOp, reader);
                    break;
                }
                case PROTOCOL: {
                    StaticDiscoveryResourceDefinition.PROTOCOL.parseAndSetParameter(value, addOp, reader);
                    break;
                }
                case PORT: {
                    StaticDiscoveryResourceDefinition.PORT.parseAndSetParameter(value, addOp, reader);
                    break;
                }
                default:
                    throw unexpectedAttribute(reader, i);
            }
        }

        if (required.size() > 0) {
            throw missingRequired(reader, required);
        }

        requireNoContent(reader);
    }
 
Example 11
Source File: HostXml_14.java    From wildfly-core with GNU Lesser General Public License v2.1 4 votes vote down vote up
private ModelNode parseDiscoveryOptionAttributes(final XMLExtendedStreamReader reader, final ModelNode address,
                                                 final List<ModelNode> list, final Set<String> discoveryOptionNames) throws XMLStreamException {

    // OP_ADDR will be set after parsing the NAME attribute
    final ModelNode discoveryOptionAddress = address.clone();
    discoveryOptionAddress.add(CORE_SERVICE, DISCOVERY_OPTIONS);
    final ModelNode addOp = Util.getEmptyOperation(ADD, new ModelNode());
    list.add(addOp);

    final Set<Attribute> required = EnumSet.of(Attribute.NAME, Attribute.CODE);
    final int count = reader.getAttributeCount();
    for (int i = 0; i < count; i++) {
        requireNoNamespaceAttribute(reader, i);
        final String value = reader.getAttributeValue(i);
        final Attribute attribute = Attribute.forName(reader.getAttributeLocalName(i));
        required.remove(attribute);
        switch (attribute) {
            case NAME: {
                if (!discoveryOptionNames.add(value)) {
                    throw ParseUtils.duplicateNamedElement(reader, value);
                }
                addOp.get(OP_ADDR).set(discoveryOptionAddress).add(DISCOVERY_OPTION, value);
                break;
            }
            case CODE: {
                DiscoveryOptionResourceDefinition.CODE.parseAndSetParameter(value, addOp, reader);
                break;
            }
            case MODULE: {
                DiscoveryOptionResourceDefinition.MODULE.parseAndSetParameter(value, addOp, reader);
                break;
            }
            default:
                throw unexpectedAttribute(reader, i);
        }
    }

    if (required.size() > 0) {
        throw missingRequired(reader, required);
    }

    return addOp;
}
 
Example 12
Source File: HostXml_7.java    From wildfly-core with GNU Lesser General Public License v2.1 4 votes vote down vote up
protected void parseStaticDiscoveryOption(final XMLExtendedStreamReader reader, final ModelNode address, final List<ModelNode> list, final Set<String> staticDiscoveryOptionNames) throws XMLStreamException {

        // OP_ADDR will be set after parsing the NAME attribute
        final ModelNode staticDiscoveryOptionAddress = address.clone();
        staticDiscoveryOptionAddress.add(CORE_SERVICE, DISCOVERY_OPTIONS);
        final ModelNode addOp = Util.getEmptyOperation(ADD, new ModelNode());
        list.add(addOp);

        // Handle attributes
        final Set<Attribute> required = EnumSet.of(Attribute.NAME, Attribute.HOST, Attribute.PORT);
        final int count = reader.getAttributeCount();
        for (int i = 0; i < count; i++) {
            requireNoNamespaceAttribute(reader, i);
            final String value = reader.getAttributeValue(i);
            final Attribute attribute = Attribute.forName(reader.getAttributeLocalName(i));
            required.remove(attribute);
            switch (attribute) {
                case NAME: {
                    if (!staticDiscoveryOptionNames.add(value)) {
                        throw ParseUtils.duplicateNamedElement(reader, value);
                    }
                    addOp.get(OP_ADDR).set(staticDiscoveryOptionAddress).add(STATIC_DISCOVERY, value);
                    break;
                }
                case HOST: {
                    StaticDiscoveryResourceDefinition.HOST.parseAndSetParameter(value, addOp, reader);
                    break;
                }
                case PROTOCOL: {
                    StaticDiscoveryResourceDefinition.PROTOCOL.parseAndSetParameter(value, addOp, reader);
                    break;
                }
                case PORT: {
                    StaticDiscoveryResourceDefinition.PORT.parseAndSetParameter(value, addOp, reader);
                    break;
                }
                default:
                    throw unexpectedAttribute(reader, i);
            }
        }

        if (required.size() > 0) {
            throw missingRequired(reader, required);
        }

        requireNoContent(reader);
    }
 
Example 13
Source File: HostXml_7.java    From wildfly-core with GNU Lesser General Public License v2.1 4 votes vote down vote up
private ModelNode parseDiscoveryOptionAttributes(final XMLExtendedStreamReader reader, final ModelNode address,
                                                 final List<ModelNode> list, final Set<String> discoveryOptionNames) throws XMLStreamException {

    // OP_ADDR will be set after parsing the NAME attribute
    final ModelNode discoveryOptionAddress = address.clone();
    discoveryOptionAddress.add(CORE_SERVICE, DISCOVERY_OPTIONS);
    final ModelNode addOp = Util.getEmptyOperation(ADD, new ModelNode());
    list.add(addOp);

    final Set<Attribute> required = EnumSet.of(Attribute.NAME, Attribute.CODE);
    final int count = reader.getAttributeCount();
    for (int i = 0; i < count; i++) {
        requireNoNamespaceAttribute(reader, i);
        final String value = reader.getAttributeValue(i);
        final Attribute attribute = Attribute.forName(reader.getAttributeLocalName(i));
        required.remove(attribute);
        switch (attribute) {
            case NAME: {
                if (!discoveryOptionNames.add(value)) {
                    throw ParseUtils.duplicateNamedElement(reader, value);
                }
                addOp.get(OP_ADDR).set(discoveryOptionAddress).add(DISCOVERY_OPTION, value);
                break;
            }
            case CODE: {
                DiscoveryOptionResourceDefinition.CODE.parseAndSetParameter(value, addOp, reader);
                break;
            }
            case MODULE: {
                DiscoveryOptionResourceDefinition.MODULE.parseAndSetParameter(value, addOp, reader);
                break;
            }
            default:
                throw unexpectedAttribute(reader, i);
        }
    }

    if (required.size() > 0) {
        throw missingRequired(reader, required);
    }

    return addOp;
}
 
Example 14
Source File: HostXml_13.java    From wildfly-core with GNU Lesser General Public License v2.1 4 votes vote down vote up
protected void parseStaticDiscoveryOption(final XMLExtendedStreamReader reader, final ModelNode address, final List<ModelNode> list, final Set<String> staticDiscoveryOptionNames) throws XMLStreamException {

        // OP_ADDR will be set after parsing the NAME attribute
        final ModelNode staticDiscoveryOptionAddress = address.clone();
        staticDiscoveryOptionAddress.add(CORE_SERVICE, DISCOVERY_OPTIONS);
        final ModelNode addOp = Util.getEmptyOperation(ADD, new ModelNode());
        list.add(addOp);

        // Handle attributes
        final Set<Attribute> required = EnumSet.of(Attribute.NAME, Attribute.HOST, Attribute.PORT);
        final int count = reader.getAttributeCount();
        for (int i = 0; i < count; i++) {
            requireNoNamespaceAttribute(reader, i);
            final String value = reader.getAttributeValue(i);
            final Attribute attribute = Attribute.forName(reader.getAttributeLocalName(i));
            required.remove(attribute);
            switch (attribute) {
                case NAME: {
                    if (!staticDiscoveryOptionNames.add(value)) {
                        throw ParseUtils.duplicateNamedElement(reader, value);
                    }
                    addOp.get(OP_ADDR).set(staticDiscoveryOptionAddress).add(STATIC_DISCOVERY, value);
                    break;
                }
                case HOST: {
                    StaticDiscoveryResourceDefinition.HOST.parseAndSetParameter(value, addOp, reader);
                    break;
                }
                case PROTOCOL: {
                    StaticDiscoveryResourceDefinition.PROTOCOL.parseAndSetParameter(value, addOp, reader);
                    break;
                }
                case PORT: {
                    StaticDiscoveryResourceDefinition.PORT.parseAndSetParameter(value, addOp, reader);
                    break;
                }
                default:
                    throw unexpectedAttribute(reader, i);
            }
        }

        if (required.size() > 0) {
            throw missingRequired(reader, required);
        }

        requireNoContent(reader);
    }
 
Example 15
Source File: HostXml_6.java    From wildfly-core with GNU Lesser General Public License v2.1 4 votes vote down vote up
private ModelNode parseDiscoveryOptionAttributes(final XMLExtendedStreamReader reader, final ModelNode address,
                                                 final List<ModelNode> list, final Set<String> discoveryOptionNames) throws XMLStreamException {

    // OP_ADDR will be set after parsing the NAME attribute
    final ModelNode discoveryOptionAddress = address.clone();
    discoveryOptionAddress.add(CORE_SERVICE, DISCOVERY_OPTIONS);
    final ModelNode addOp = Util.getEmptyOperation(ADD, new ModelNode());
    list.add(addOp);

    final Set<Attribute> required = EnumSet.of(Attribute.NAME, Attribute.CODE);
    final int count = reader.getAttributeCount();
    for (int i = 0; i < count; i++) {
        requireNoNamespaceAttribute(reader, i);
        final String value = reader.getAttributeValue(i);
        final Attribute attribute = Attribute.forName(reader.getAttributeLocalName(i));
        required.remove(attribute);
        switch (attribute) {
            case NAME: {
                if (!discoveryOptionNames.add(value)) {
                    throw ParseUtils.duplicateNamedElement(reader, value);
                }
                addOp.get(OP_ADDR).set(discoveryOptionAddress).add(DISCOVERY_OPTION, value);
                break;
            }
            case CODE: {
                DiscoveryOptionResourceDefinition.CODE.parseAndSetParameter(value, addOp, reader);
                break;
            }
            case MODULE: {
                DiscoveryOptionResourceDefinition.MODULE.parseAndSetParameter(value, addOp, reader);
                break;
            }
            default:
                throw unexpectedAttribute(reader, i);
        }
    }

    if (required.size() > 0) {
        throw missingRequired(reader, required);
    }

    return addOp;
}
 
Example 16
Source File: HostXml_5.java    From wildfly-core with GNU Lesser General Public License v2.1 4 votes vote down vote up
private void parseStaticDiscoveryOption(final XMLExtendedStreamReader reader, final ModelNode address, final List<ModelNode> list, final Set<String> staticDiscoveryOptionNames) throws XMLStreamException {

        // OP_ADDR will be set after parsing the NAME attribute
        final ModelNode staticDiscoveryOptionAddress = address.clone();
        staticDiscoveryOptionAddress.add(CORE_SERVICE, DISCOVERY_OPTIONS);
        final ModelNode addOp = Util.getEmptyOperation(ADD, new ModelNode());
        list.add(addOp);

        // Handle attributes
        final Set<Attribute> required = EnumSet.of(Attribute.NAME, Attribute.HOST, Attribute.PORT);
        final int count = reader.getAttributeCount();
        for (int i = 0; i < count; i++) {
            requireNoNamespaceAttribute(reader, i);
            final String value = reader.getAttributeValue(i);
            final Attribute attribute = Attribute.forName(reader.getAttributeLocalName(i));
            required.remove(attribute);
            switch (attribute) {
                case NAME: {
                    if (!staticDiscoveryOptionNames.add(value)) {
                        throw ParseUtils.duplicateNamedElement(reader, value);
                    }
                    addOp.get(OP_ADDR).set(staticDiscoveryOptionAddress).add(STATIC_DISCOVERY, value);
                    break;
                }
                case HOST: {
                    StaticDiscoveryResourceDefinition.HOST.parseAndSetParameter(value, addOp, reader);
                    break;
                }
                case PROTOCOL: {
                    StaticDiscoveryResourceDefinition.PROTOCOL.parseAndSetParameter(value, addOp, reader);
                    break;
                }
                case PORT: {
                    StaticDiscoveryResourceDefinition.PORT.parseAndSetParameter(value, addOp, reader);
                    break;
                }
                default:
                    throw unexpectedAttribute(reader, i);
            }
        }

        if (required.size() > 0) {
            throw missingRequired(reader, required);
        }

        requireNoContent(reader);
    }
 
Example 17
Source File: HostXml_13.java    From wildfly-core with GNU Lesser General Public License v2.1 4 votes vote down vote up
private ModelNode parseDiscoveryOptionAttributes(final XMLExtendedStreamReader reader, final ModelNode address,
                                                 final List<ModelNode> list, final Set<String> discoveryOptionNames) throws XMLStreamException {

    // OP_ADDR will be set after parsing the NAME attribute
    final ModelNode discoveryOptionAddress = address.clone();
    discoveryOptionAddress.add(CORE_SERVICE, DISCOVERY_OPTIONS);
    final ModelNode addOp = Util.getEmptyOperation(ADD, new ModelNode());
    list.add(addOp);

    final Set<Attribute> required = EnumSet.of(Attribute.NAME, Attribute.CODE);
    final int count = reader.getAttributeCount();
    for (int i = 0; i < count; i++) {
        requireNoNamespaceAttribute(reader, i);
        final String value = reader.getAttributeValue(i);
        final Attribute attribute = Attribute.forName(reader.getAttributeLocalName(i));
        required.remove(attribute);
        switch (attribute) {
            case NAME: {
                if (!discoveryOptionNames.add(value)) {
                    throw ParseUtils.duplicateNamedElement(reader, value);
                }
                addOp.get(OP_ADDR).set(discoveryOptionAddress).add(DISCOVERY_OPTION, value);
                break;
            }
            case CODE: {
                DiscoveryOptionResourceDefinition.CODE.parseAndSetParameter(value, addOp, reader);
                break;
            }
            case MODULE: {
                DiscoveryOptionResourceDefinition.MODULE.parseAndSetParameter(value, addOp, reader);
                break;
            }
            default:
                throw unexpectedAttribute(reader, i);
        }
    }

    if (required.size() > 0) {
        throw missingRequired(reader, required);
    }

    return addOp;
}
 
Example 18
Source File: HostXml_Legacy.java    From wildfly-core with GNU Lesser General Public License v2.1 4 votes vote down vote up
private void parseStaticDiscoveryOption(final XMLExtendedStreamReader reader, final ModelNode address, final List<ModelNode> list, final Set<String> staticDiscoveryOptionNames) throws XMLStreamException {

        // OP_ADDR will be set after parsing the NAME attribute
        final ModelNode staticDiscoveryOptionAddress = address.clone();
        staticDiscoveryOptionAddress.add(CORE_SERVICE, DISCOVERY_OPTIONS);
        final ModelNode addOp = Util.getEmptyOperation(ADD, new ModelNode());
        list.add(addOp);

        // Handle attributes
        final Set<Attribute> required = EnumSet.of(Attribute.NAME, Attribute.HOST, Attribute.PORT);
        final int count = reader.getAttributeCount();
        for (int i = 0; i < count; i++) {
            requireNoNamespaceAttribute(reader, i);
            final String value = reader.getAttributeValue(i);
            final Attribute attribute = Attribute.forName(reader.getAttributeLocalName(i));
            required.remove(attribute);
            switch (attribute) {
            case NAME: {
                if (!staticDiscoveryOptionNames.add(value)) {
                    throw ParseUtils.duplicateNamedElement(reader, value);
                }
                addOp.get(OP_ADDR).set(staticDiscoveryOptionAddress).add(STATIC_DISCOVERY, value);
                break;
            }
            case HOST: {
                StaticDiscoveryResourceDefinition.HOST.parseAndSetParameter(value, addOp, reader);
                break;
            }
            case PROTOCOL: {
                if(namespace.getMajorVersion() > 2) {
                    StaticDiscoveryResourceDefinition.PROTOCOL.parseAndSetParameter(value, addOp, reader);
                } else {
                    throw unexpectedAttribute(reader, i);
                }
                break;
            }
            case PORT: {
                StaticDiscoveryResourceDefinition.PORT.parseAndSetParameter(value, addOp, reader);
                break;
            }
            default:
                throw unexpectedAttribute(reader, i);
            }
        }

        if (required.size() > 0) {
            throw missingRequired(reader, required);
        }

        requireNoContent(reader);
    }
 
Example 19
Source File: HostXml_Legacy.java    From wildfly-core with GNU Lesser General Public License v2.1 4 votes vote down vote up
private ModelNode parseDiscoveryOptionAttributes(final XMLExtendedStreamReader reader, final ModelNode address,
        final List<ModelNode> list, final Set<String> discoveryOptionNames) throws XMLStreamException {

    // OP_ADDR will be set after parsing the NAME attribute
    final ModelNode discoveryOptionAddress = address.clone();
    discoveryOptionAddress.add(CORE_SERVICE, DISCOVERY_OPTIONS);
    final ModelNode addOp = Util.getEmptyOperation(ADD, new ModelNode());
    list.add(addOp);

    final Set<Attribute> required = EnumSet.of(Attribute.NAME, Attribute.CODE);
    final int count = reader.getAttributeCount();
    for (int i = 0; i < count; i++) {
        requireNoNamespaceAttribute(reader, i);
        final String value = reader.getAttributeValue(i);
        final Attribute attribute = Attribute.forName(reader.getAttributeLocalName(i));
        required.remove(attribute);
        switch (attribute) {
            case NAME: {
                if (!discoveryOptionNames.add(value)) {
                    throw ParseUtils.duplicateNamedElement(reader, value);
                }
                addOp.get(OP_ADDR).set(discoveryOptionAddress).add(DISCOVERY_OPTION, value);
                break;
            }
            case CODE: {
                DiscoveryOptionResourceDefinition.CODE.parseAndSetParameter(value, addOp, reader);
                break;
            }
            case MODULE: {
                DiscoveryOptionResourceDefinition.MODULE.parseAndSetParameter(value, addOp, reader);
                break;
            }
            default:
                throw unexpectedAttribute(reader, i);
        }
    }

    if (required.size() > 0) {
        throw missingRequired(reader, required);
    }

    return addOp;
}
 
Example 20
Source File: HostXml_9.java    From wildfly-core with GNU Lesser General Public License v2.1 4 votes vote down vote up
private ModelNode parseDiscoveryOptionAttributes(final XMLExtendedStreamReader reader, final ModelNode address,
                                                 final List<ModelNode> list, final Set<String> discoveryOptionNames) throws XMLStreamException {

    // OP_ADDR will be set after parsing the NAME attribute
    final ModelNode discoveryOptionAddress = address.clone();
    discoveryOptionAddress.add(CORE_SERVICE, DISCOVERY_OPTIONS);
    final ModelNode addOp = Util.getEmptyOperation(ADD, new ModelNode());
    list.add(addOp);

    final Set<Attribute> required = EnumSet.of(Attribute.NAME, Attribute.CODE);
    final int count = reader.getAttributeCount();
    for (int i = 0; i < count; i++) {
        requireNoNamespaceAttribute(reader, i);
        final String value = reader.getAttributeValue(i);
        final Attribute attribute = Attribute.forName(reader.getAttributeLocalName(i));
        required.remove(attribute);
        switch (attribute) {
            case NAME: {
                if (!discoveryOptionNames.add(value)) {
                    throw ParseUtils.duplicateNamedElement(reader, value);
                }
                addOp.get(OP_ADDR).set(discoveryOptionAddress).add(DISCOVERY_OPTION, value);
                break;
            }
            case CODE: {
                DiscoveryOptionResourceDefinition.CODE.parseAndSetParameter(value, addOp, reader);
                break;
            }
            case MODULE: {
                DiscoveryOptionResourceDefinition.MODULE.parseAndSetParameter(value, addOp, reader);
                break;
            }
            default:
                throw unexpectedAttribute(reader, i);
        }
    }

    if (required.size() > 0) {
        throw missingRequired(reader, required);
    }

    return addOp;
}