Search in sources :

Example 1 with Element

use of org.jboss.as.controller.parsing.Element in project wildfly by wildfly.

the class AppClientXml method parseSocketBindingGroup.

private void parseSocketBindingGroup(final XMLExtendedStreamReader reader, final Set<String> interfaces, final ModelNode address, final Namespace expectedNs, final List<ModelNode> updates) throws XMLStreamException {
    // unique names for both socket-binding and outbound-socket-binding(s)
    final Set<String> uniqueBindingNames = new HashSet<String>();
    ModelNode op = Util.getEmptyOperation(ADD, null);
    // Handle attributes
    String socketBindingGroupName = null;
    final EnumSet<Attribute> required = EnumSet.of(Attribute.NAME, Attribute.DEFAULT_INTERFACE);
    final int count = reader.getAttributeCount();
    for (int i = 0; i < count; i++) {
        final String value = reader.getAttributeValue(i);
        if (!isNoNamespaceAttribute(reader, i)) {
            throw unexpectedAttribute(reader, i);
        }
        final Attribute attribute = Attribute.forName(reader.getAttributeLocalName(i));
        switch(attribute) {
            case NAME:
                {
                    socketBindingGroupName = value;
                    required.remove(attribute);
                    break;
                }
            case DEFAULT_INTERFACE:
                {
                    SocketBindingGroupResourceDefinition.DEFAULT_INTERFACE.parseAndSetParameter(value, op, reader);
                    required.remove(attribute);
                    break;
                }
            case PORT_OFFSET:
                {
                    SocketBindingGroupResourceDefinition.PORT_OFFSET.parseAndSetParameter(value, op, reader);
                    break;
                }
            default:
                throw ParseUtils.unexpectedAttribute(reader, i);
        }
    }
    if (!required.isEmpty()) {
        throw missingRequired(reader, required);
    }
    ModelNode groupAddress = address.clone().add(SOCKET_BINDING_GROUP, socketBindingGroupName);
    op.get(OP_ADDR).set(groupAddress);
    updates.add(op);
    // Handle elements
    while (reader.nextTag() != END_ELEMENT) {
        requireNamespace(reader, expectedNs);
        final Element element = Element.forName(reader.getLocalName());
        switch(element) {
            case SOCKET_BINDING:
                {
                    // FIXME JBAS-8825
                    final String bindingName = parseSocketBinding(reader, interfaces, groupAddress, updates);
                    if (!uniqueBindingNames.add(bindingName)) {
                        throw ControllerLogger.ROOT_LOGGER.alreadyDeclared(Element.SOCKET_BINDING.getLocalName(), Element.OUTBOUND_SOCKET_BINDING.getLocalName(), bindingName, Element.SOCKET_BINDING_GROUP.getLocalName(), socketBindingGroupName, reader.getLocation());
                    }
                    break;
                }
            case OUTBOUND_SOCKET_BINDING:
                {
                    final String bindingName = parseOutboundSocketBinding(reader, interfaces, groupAddress, updates);
                    if (!uniqueBindingNames.add(bindingName)) {
                        throw ControllerLogger.ROOT_LOGGER.alreadyDeclared(Element.SOCKET_BINDING.getLocalName(), Element.OUTBOUND_SOCKET_BINDING.getLocalName(), bindingName, Element.SOCKET_BINDING_GROUP.getLocalName(), socketBindingGroupName, reader.getLocation());
                    }
                    break;
                }
            default:
                throw unexpectedElement(reader);
        }
    }
}
Also used : ParseUtils.unexpectedAttribute(org.jboss.as.controller.parsing.ParseUtils.unexpectedAttribute) ParseUtils.isNoNamespaceAttribute(org.jboss.as.controller.parsing.ParseUtils.isNoNamespaceAttribute) Attribute(org.jboss.as.controller.parsing.Attribute) ParseUtils.nextElement(org.jboss.as.controller.parsing.ParseUtils.nextElement) Element(org.jboss.as.controller.parsing.Element) ParseUtils.unexpectedElement(org.jboss.as.controller.parsing.ParseUtils.unexpectedElement) ModelNode(org.jboss.dmr.ModelNode) HashSet(java.util.HashSet)

Example 2 with Element

use of org.jboss.as.controller.parsing.Element in project wildfly by wildfly.

the class AppClientXml method readServerElement_1_1.

/**
 * Read the <server/> element based on version 1.1 of the schema.
 *
 * @param reader  the xml stream reader
 * @param address address of the parent resource of any resources this method will add
 * @param list the list of boot operations to which any new operations should be added
 * @throws XMLStreamException if a parsing error occurs
 */
private void readServerElement_1_1(final Namespace namespace, final XMLExtendedStreamReader reader, final ModelNode address, final List<ModelNode> list) throws XMLStreamException {
    parseNamespaces(reader, address, list);
    String serverName = null;
    // attributes
    final int count = reader.getAttributeCount();
    for (int i = 0; i < count; i++) {
        switch(Namespace.forUri(reader.getAttributeNamespace(i))) {
            case NONE:
                {
                    final String value = reader.getAttributeValue(i);
                    final Attribute attribute = Attribute.forName(reader.getAttributeLocalName(i));
                    switch(attribute) {
                        case NAME:
                            {
                                serverName = value;
                                break;
                            }
                        default:
                            throw unexpectedAttribute(reader, i);
                    }
                    break;
                }
            case XML_SCHEMA_INSTANCE:
                {
                    switch(Attribute.forName(reader.getAttributeLocalName(i))) {
                        case SCHEMA_LOCATION:
                            {
                                parseSchemaLocations(reader, address, list, i);
                                break;
                            }
                        case NO_NAMESPACE_SCHEMA_LOCATION:
                            {
                                // todo, jeez
                                break;
                            }
                        default:
                            {
                                throw unexpectedAttribute(reader, i);
                            }
                    }
                    break;
                }
            default:
                throw unexpectedAttribute(reader, i);
        }
    }
    setServerName(address, list, serverName);
    // elements - sequence
    Element element = nextElement(reader, namespace);
    if (element == Element.EXTENSIONS) {
        extensionXml.parseExtensions(reader, address, namespace, list);
        element = nextElement(reader, namespace);
    }
    // System properties
    if (element == Element.SYSTEM_PROPERTIES) {
        parseSystemProperties(reader, address, namespace, list, true);
        element = nextElement(reader, namespace);
    }
    if (element == Element.PATHS) {
        parsePaths(reader, address, namespace, list, true);
        element = nextElement(reader, namespace);
    }
    if (element == Element.VAULT) {
        parseVault(reader, address, namespace, list);
        element = nextElement(reader, namespace);
    }
    // Single profile
    if (element == Element.PROFILE) {
        parseServerProfile(reader, address, list);
        element = nextElement(reader, namespace);
    }
    // Interfaces
    final Set<String> interfaceNames = new HashSet<String>();
    if (element == Element.INTERFACES) {
        parseInterfaces(reader, interfaceNames, address, namespace, list, true);
        element = nextElement(reader, namespace);
    }
    // Single socket binding group
    if (element == Element.SOCKET_BINDING_GROUP) {
        parseSocketBindingGroup(reader, interfaceNames, address, namespace, list);
        element = nextElement(reader, namespace);
    }
    if (element != null) {
        throw unexpectedElement(reader);
    }
}
Also used : ParseUtils.unexpectedAttribute(org.jboss.as.controller.parsing.ParseUtils.unexpectedAttribute) ParseUtils.isNoNamespaceAttribute(org.jboss.as.controller.parsing.ParseUtils.isNoNamespaceAttribute) Attribute(org.jboss.as.controller.parsing.Attribute) ParseUtils.nextElement(org.jboss.as.controller.parsing.ParseUtils.nextElement) Element(org.jboss.as.controller.parsing.Element) ParseUtils.unexpectedElement(org.jboss.as.controller.parsing.ParseUtils.unexpectedElement) HashSet(java.util.HashSet)

Example 3 with Element

use of org.jboss.as.controller.parsing.Element in project wildfly by wildfly.

the class AppClientXml method readServerElement_1_0.

/**
 * Read the <server/> element based on version 1.0 of the schema.
 *
 * @param reader  the xml stream reader
 * @param address address of the parent resource of any resources this method will add
 * @param list the list of boot operations to which any new operations should be added
 * @throws XMLStreamException if a parsing error occurs
 */
private void readServerElement_1_0(final XMLExtendedStreamReader reader, final ModelNode address, final List<ModelNode> list) throws XMLStreamException {
    parseNamespaces(reader, address, list);
    String serverName = null;
    // attributes
    final int count = reader.getAttributeCount();
    for (int i = 0; i < count; i++) {
        switch(Namespace.forUri(reader.getAttributeNamespace(i))) {
            case NONE:
                {
                    final String value = reader.getAttributeValue(i);
                    final Attribute attribute = Attribute.forName(reader.getAttributeLocalName(i));
                    switch(attribute) {
                        case NAME:
                            {
                                serverName = value;
                                break;
                            }
                        default:
                            throw unexpectedAttribute(reader, i);
                    }
                    break;
                }
            case XML_SCHEMA_INSTANCE:
                {
                    switch(Attribute.forName(reader.getAttributeLocalName(i))) {
                        case SCHEMA_LOCATION:
                            {
                                parseSchemaLocations(reader, address, list, i);
                                break;
                            }
                        case NO_NAMESPACE_SCHEMA_LOCATION:
                            {
                                // todo, jeez
                                break;
                            }
                        default:
                            {
                                throw unexpectedAttribute(reader, i);
                            }
                    }
                    break;
                }
            default:
                throw unexpectedAttribute(reader, i);
        }
    }
    setServerName(address, list, serverName);
    // elements - sequence
    Element element = nextElement(reader, DOMAIN_1_0);
    if (element == Element.EXTENSIONS) {
        extensionXml.parseExtensions(reader, address, DOMAIN_1_0, list);
        element = nextElement(reader, DOMAIN_1_0);
    }
    // System properties
    if (element == Element.SYSTEM_PROPERTIES) {
        parseSystemProperties(reader, address, DOMAIN_1_0, list, true);
        element = nextElement(reader, DOMAIN_1_0);
    }
    if (element == Element.PATHS) {
        parsePaths(reader, address, DOMAIN_1_0, list, true);
        element = nextElement(reader, DOMAIN_1_0);
    }
    // Single profile
    if (element == Element.PROFILE) {
        parseServerProfile(reader, address, list);
        element = nextElement(reader, DOMAIN_1_0);
    }
    // Interfaces
    final Set<String> interfaceNames = new HashSet<String>();
    if (element == Element.INTERFACES) {
        parseInterfaces(reader, interfaceNames, address, DOMAIN_1_0, list, true);
        element = nextElement(reader, DOMAIN_1_0);
    }
    // Single socket binding group
    if (element == Element.SOCKET_BINDING_GROUP) {
        parseSocketBindingGroup(reader, interfaceNames, address, DOMAIN_1_0, list);
        element = nextElement(reader, DOMAIN_1_0);
    }
    if (element != null) {
        throw unexpectedElement(reader);
    }
}
Also used : ParseUtils.unexpectedAttribute(org.jboss.as.controller.parsing.ParseUtils.unexpectedAttribute) ParseUtils.isNoNamespaceAttribute(org.jboss.as.controller.parsing.ParseUtils.isNoNamespaceAttribute) Attribute(org.jboss.as.controller.parsing.Attribute) ParseUtils.nextElement(org.jboss.as.controller.parsing.ParseUtils.nextElement) Element(org.jboss.as.controller.parsing.Element) ParseUtils.unexpectedElement(org.jboss.as.controller.parsing.ParseUtils.unexpectedElement) HashSet(java.util.HashSet)

Example 4 with Element

use of org.jboss.as.controller.parsing.Element in project wildfly by wildfly.

the class AppClientXml method readServerElement_18.

/**
 * Read the <server/> element based on version 18 of the schema.
 *
 * @param reader  the xml stream reader
 * @param address address of the parent resource of any resources this method will add
 * @param list the list of boot operations to which any new operations should be added
 * @throws XMLStreamException if a parsing error occurs
 */
private void readServerElement_18(final Namespace namespace, final XMLExtendedStreamReader reader, final ModelNode address, final List<ModelNode> list) throws XMLStreamException {
    parseNamespaces(reader, address, list);
    String serverName = null;
    // attributes
    final int count = reader.getAttributeCount();
    for (int i = 0; i < count; i++) {
        switch(Namespace.forUri(reader.getAttributeNamespace(i))) {
            case NONE:
                {
                    final String value = reader.getAttributeValue(i);
                    final Attribute attribute = Attribute.forName(reader.getAttributeLocalName(i));
                    switch(attribute) {
                        case NAME:
                            {
                                serverName = value;
                                break;
                            }
                        default:
                            throw unexpectedAttribute(reader, i);
                    }
                    break;
                }
            case XML_SCHEMA_INSTANCE:
                {
                    switch(Attribute.forName(reader.getAttributeLocalName(i))) {
                        case SCHEMA_LOCATION:
                            {
                                parseSchemaLocations(reader, address, list, i);
                                break;
                            }
                        case NO_NAMESPACE_SCHEMA_LOCATION:
                            {
                                // todo, jeez
                                break;
                            }
                        default:
                            {
                                throw unexpectedAttribute(reader, i);
                            }
                    }
                    break;
                }
            default:
                throw unexpectedAttribute(reader, i);
        }
    }
    setServerName(address, list, serverName);
    // elements - sequence
    Element element = nextElement(reader, namespace);
    if (element == Element.EXTENSIONS) {
        extensionXml.parseExtensions(reader, address, namespace, list);
        element = nextElement(reader, namespace);
    }
    // System properties
    if (element == Element.SYSTEM_PROPERTIES) {
        parseSystemProperties(reader, address, namespace, list, true);
        element = nextElement(reader, namespace);
    }
    if (element == Element.PATHS) {
        parsePaths(reader, address, namespace, list, true);
        element = nextElement(reader, namespace);
    }
    // Single profile
    if (element == Element.PROFILE) {
        parseServerProfile(reader, address, list);
        element = nextElement(reader, namespace);
    }
    // Interfaces
    final Set<String> interfaceNames = new HashSet<String>();
    if (element == Element.INTERFACES) {
        parseInterfaces(reader, interfaceNames, address, namespace, list, true);
        element = nextElement(reader, namespace);
    }
    // Single socket binding group
    if (element == Element.SOCKET_BINDING_GROUP) {
        parseSocketBindingGroup(reader, interfaceNames, address, namespace, list);
        element = nextElement(reader, namespace);
    }
    if (element != null) {
        throw unexpectedElement(reader);
    }
}
Also used : ParseUtils.unexpectedAttribute(org.jboss.as.controller.parsing.ParseUtils.unexpectedAttribute) ParseUtils.isNoNamespaceAttribute(org.jboss.as.controller.parsing.ParseUtils.isNoNamespaceAttribute) Attribute(org.jboss.as.controller.parsing.Attribute) ParseUtils.nextElement(org.jboss.as.controller.parsing.ParseUtils.nextElement) Element(org.jboss.as.controller.parsing.Element) ParseUtils.unexpectedElement(org.jboss.as.controller.parsing.ParseUtils.unexpectedElement) HashSet(java.util.HashSet)

Aggregations

HashSet (java.util.HashSet)4 Attribute (org.jboss.as.controller.parsing.Attribute)4 Element (org.jboss.as.controller.parsing.Element)4 ParseUtils.isNoNamespaceAttribute (org.jboss.as.controller.parsing.ParseUtils.isNoNamespaceAttribute)4 ParseUtils.nextElement (org.jboss.as.controller.parsing.ParseUtils.nextElement)4 ParseUtils.unexpectedAttribute (org.jboss.as.controller.parsing.ParseUtils.unexpectedAttribute)4 ParseUtils.unexpectedElement (org.jboss.as.controller.parsing.ParseUtils.unexpectedElement)4 ModelNode (org.jboss.dmr.ModelNode)1