Пример #1
0
 protected void readDomainElementAttributes_1_0(
     XMLExtendedStreamReader reader, ModelNode address, List<ModelNode> list)
     throws XMLStreamException {
   final int count = reader.getAttributeCount();
   for (int i = 0; i < count; i++) {
     switch (Namespace.forUri(reader.getAttributeNamespace(i))) {
       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);
     }
   }
 }
Пример #2
0
 @Override
 public void readElement(final XMLExtendedStreamReader reader, final List<ModelNode> nodes)
     throws XMLStreamException {
   if (Element.forName(reader.getLocalName()) != Element.DOMAIN) {
     throw unexpectedElement(reader);
   }
   Namespace readerNS = Namespace.forUri(reader.getNamespaceURI());
   switch (readerNS) {
     case DOMAIN_1_0:
       {
         readDomainElement1_0(reader, new ModelNode(), readerNS, nodes);
         break;
       }
     case DOMAIN_1_1:
     case DOMAIN_1_2:
       readDomainElement1_1(reader, new ModelNode(), readerNS, nodes);
       break;
     case DOMAIN_1_3:
       {
         readDomainElement1_3(reader, new ModelNode(), readerNS, nodes);
         break;
       }
     default:
       {
         throw unexpectedElement(reader);
       }
   }
 }
Пример #3
0
  @Override
  public void readElement(XMLExtendedStreamReader reader, List<ModelNode> operations)
      throws XMLStreamException {

    ParseUtils.requireNoAttributes(reader);
    final Map<String, List<ModelNode>> profileOps = new LinkedHashMap<String, List<ModelNode>>();
    while (reader.hasNext() && reader.nextTag() != END_ELEMENT) {
      if (Namespace.forUri(reader.getNamespaceURI()) != Namespace.UNKNOWN) {
        throw unexpectedElement(reader);
      }
      if (Element.forName(reader.getLocalName()) != Element.SUBSYSTEM) {
        throw unexpectedElement(reader);
      }
      String namespace = reader.getNamespaceURI();
      if (profileOps.containsKey(namespace)) {
        throw ControllerMessages.MESSAGES.duplicateDeclaration("subsystem", reader.getLocation());
      }
      // parse subsystem
      final List<ModelNode> subsystems = new ArrayList<ModelNode>();
      reader.handleAny(subsystems);

      profileOps.put(namespace, subsystems);
    }

    // Let extensions modify the profile
    Set<ProfileParsingCompletionHandler> completionHandlers =
        extensionRegistry.getProfileParsingCompletionHandlers();
    for (ProfileParsingCompletionHandler completionHandler : completionHandlers) {
      completionHandler.handleProfileParsingCompletion(profileOps, operations);
    }

    for (List<ModelNode> subsystems : profileOps.values()) {
      operations.addAll(subsystems);
    }
  }
Пример #4
0
  public void readElement(final XMLExtendedStreamReader reader, final List<ModelNode> operationList)
      throws XMLStreamException {
    final ModelNode address = new ModelNode().setEmptyList();

    if (Element.forName(reader.getLocalName()) != Element.SERVER) {
      throw unexpectedElement(reader);
    }

    Namespace readerNS = Namespace.forUri(reader.getNamespaceURI());
    switch (readerNS) {
      case DOMAIN_1_0:
        readServerElement_1_0(reader, address, operationList);
        break;
      default:
        // Instead of having to list the remaining versions we just check it is actually a valid
        // version.
        for (Namespace current : Namespace.domainValues()) {
          if (readerNS.equals(current)) {
            readServerElement_1_1(readerNS, reader, address, operationList);
            return;
          }
        }
        throw unexpectedElement(reader);
    }
  }
Пример #5
0
    @Override
    public void readElement(XMLExtendedStreamReader reader, List<ModelNode> operations)
        throws XMLStreamException {

      ParseUtils.requireNoAttributes(reader);
      while (reader.hasNext() && reader.nextTag() != END_ELEMENT) {
        if (Namespace.forUri(reader.getNamespaceURI()) != Namespace.UNKNOWN) {
          throw unexpectedElement(reader);
        }
        if (Element.forName(reader.getLocalName()) != Element.SUBSYSTEM) {
          throw unexpectedElement(reader);
        }
        reader.handleAny(operations);
      }
    }
Пример #6
0
 protected void readDomainElementAttributes_1_3(
     XMLExtendedStreamReader reader, Namespace expectedNs, ModelNode address, List<ModelNode> list)
     throws XMLStreamException {
   final int count = reader.getAttributeCount();
   for (int i = 0; i < count; i++) {
     Namespace ns = Namespace.forUri(reader.getAttributeNamespace(i));
     switch (ns) {
       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:
         switch (Attribute.forName(reader.getAttributeLocalName(i))) {
           case NAME:
             ModelNode op = new ModelNode();
             op.get(OP).set(WRITE_ATTRIBUTE_OPERATION);
             op.get(NAME).set(NAME);
             op.get(VALUE).set(ParseUtils.parsePossibleExpression(reader.getAttributeValue(i)));
             list.add(op);
             break;
           default:
             throw unexpectedAttribute(reader, i);
         }
     }
   }
 }
Пример #7
0
  void parseProfiles(
      final XMLExtendedStreamReader reader,
      final ModelNode address,
      final Namespace expectedNs,
      final List<ModelNode> list)
      throws XMLStreamException {
    requireNoAttributes(reader);

    final Set<String> names = new HashSet<String>();

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

      // Attributes
      requireSingleAttribute(reader, Attribute.NAME.getLocalName());
      final String name = reader.getAttributeValue(0);
      if (!names.add(name)) {
        throw MESSAGES.duplicateDeclaration("profile", name, reader.getLocation());
      }

      // final Set<String> includes = new HashSet<String>();  // See commented out section below.
      // final ModelNode profileIncludes = new ModelNode();

      // Content
      // Sequence
      final Map<String, List<ModelNode>> profileOps = new LinkedHashMap<String, List<ModelNode>>();
      while (reader.nextTag() != END_ELEMENT) {
        Namespace ns = Namespace.forUri(reader.getNamespaceURI());
        switch (ns) {
          case UNKNOWN:
            {
              if (Element.forName(reader.getLocalName()) != Element.SUBSYSTEM) {
                throw unexpectedElement(reader);
              }
              String namespace = reader.getNamespaceURI();
              if (profileOps.containsKey(namespace)) {
                throw MESSAGES.duplicateDeclaration("subsystem", name, reader.getLocation());
              }
              // parse content
              final List<ModelNode> subsystems = new ArrayList<ModelNode>();
              reader.handleAny(subsystems);

              profileOps.put(namespace, subsystems);

              break;
            }
          case DOMAIN_1_0:
          case DOMAIN_1_1:
          case DOMAIN_1_2:
          case DOMAIN_1_3:
            {
              requireNamespace(reader, expectedNs);
              // include should come first
              if (profileOps.size() > 0) {
                throw unexpectedElement(reader);
              }
              if (Element.forName(reader.getLocalName()) != Element.INCLUDE) {
                throw unexpectedElement(reader);
              }
              // Remove support for profile includes until 7.2.0
              if (ns == Namespace.DOMAIN_1_0) {
                HOST_CONTROLLER_LOGGER.warnIgnoringProfileInclude(reader.getLocation());
              }
              throw unexpectedElement(reader);
              /* This will be reintroduced for 7.2.0, leave commented out
              final String includedName = readStringAttributeElement(reader, Attribute.PROFILE.getLocalName());
              if (! names.contains(includedName)) {
                  throw MESSAGES.profileNotFound(reader.getLocation());
              }
              if (! includes.add(includedName)) {
                  throw MESSAGES.duplicateProfile(reader.getLocation());
              }
              profileIncludes.add(includedName);
              break;
              */
            }
          default:
            {
              throw unexpectedElement(reader);
            }
        }
      }

      // Let extensions modify the profile
      Set<ProfileParsingCompletionHandler> completionHandlers =
          extensionRegistry.getProfileParsingCompletionHandlers();
      for (ProfileParsingCompletionHandler completionHandler : completionHandlers) {
        completionHandler.handleProfileParsingCompletion(profileOps, list);
      }

      final ModelNode profile = new ModelNode();
      profile.get(OP).set(ADD);
      profile.get(OP_ADDR).set(address).add(ModelDescriptionConstants.PROFILE, name);
      /* This will be reintroduced for 7.2.0, leave commented out
      profile.get(INCLUDES).set(profileIncludes);
      */
      list.add(profile);

      // Process subsystems
      for (List<ModelNode> subsystems : profileOps.values()) {
        for (final ModelNode update : subsystems) {
          // Process relative subsystem path address
          final ModelNode subsystemAddress =
              address.clone().set(address).add(ModelDescriptionConstants.PROFILE, name);
          for (final Property path : update.get(OP_ADDR).asPropertyList()) {
            subsystemAddress.add(path.getName(), path.getValue().asString());
          }
          update.get(OP_ADDR).set(subsystemAddress);
          list.add(update);
        }
      }

      if (profileOps.size() == 0) {
        throw MESSAGES.profileHasNoSubsystems(reader.getLocation());
      }
    }
  }
Пример #8
0
  /**
   * 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) {
      switch (namespace) {
          // Less than 1.1 does not end up in this method
        case DOMAIN_1_1:
        case DOMAIN_1_2:
        case DOMAIN_1_3:
        case DOMAIN_1_4:
        case DOMAIN_1_5:
        case DOMAIN_2_0:
        case DOMAIN_2_1:
          {
            parseVault_1_1(reader, address, namespace, list);
            break;
          }
        default:
          {
            parseVault_3_0(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);
    }
  }