Esempio n. 1
0
 static {
   final Map<String, Element> map = new HashMap<String, Element>();
   for (Element element : values()) {
     final String name = element.getLocalName();
     if (name != null) map.put(name, element);
   }
   MAP = map;
 }
Esempio n. 2
0
  private void parseManagementClientContent(
      XMLExtendedStreamReader reader, ModelNode address, Namespace expectedNs, List<ModelNode> list)
      throws XMLStreamException {
    requireNoAttributes(reader);

    boolean rolloutPlansAdded = false;
    while (reader.nextTag() != END_ELEMENT) {
      requireNamespace(reader, expectedNs);
      Element element = Element.forName(reader.getLocalName());
      switch (element) {
        case ROLLOUT_PLANS:
          {
            parseRolloutPlans(reader, address, list);
            rolloutPlansAdded = true;
            break;
          }
        default:
          {
            throw unexpectedElement(reader);
          }
      }
    }

    if (!rolloutPlansAdded) {
      initializeRolloutPlans(address, list);
    }
  }
Esempio n. 3
0
 void parseDomainSocketBindingGroups(
     final XMLExtendedStreamReader reader,
     final ModelNode address,
     final Namespace expectedNs,
     final List<ModelNode> list,
     final Set<String> interfaces)
     throws XMLStreamException {
   while (reader.hasNext() && reader.nextTag() != END_ELEMENT) {
     requireNamespace(reader, expectedNs);
     final Element element = Element.forName(reader.getLocalName());
     switch (element) {
       case SOCKET_BINDING_GROUP:
         {
           switch (expectedNs) {
             case DOMAIN_1_0:
               // parse 1.0 socket binding group
               this.parseSocketBindingGroup_1_0(reader, interfaces, address, expectedNs, list);
               break;
             default:
               // parse 1.1 socket binding group
               this.parseSocketBindingGroup_1_1(reader, interfaces, address, expectedNs, list);
               break;
           }
           break;
         }
       default:
         {
           throw unexpectedElement(reader);
         }
     }
   }
 }
Esempio n. 4
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);
       }
   }
 }
Esempio n. 5
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);
    }
  }
Esempio n. 6
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);
    }
  }
Esempio n. 7
0
  private void parseServerProfile(
      final XMLExtendedStreamReader reader, final ModelNode address, final List<ModelNode> list)
      throws XMLStreamException {
    // Attributes
    requireNoAttributes(reader);

    // Content
    final Set<String> configuredSubsystemTypes = new HashSet<String>();
    while (reader.hasNext() && reader.nextTag() != END_ELEMENT) {
      if (Element.forName(reader.getLocalName()) != Element.SUBSYSTEM) {
        throw unexpectedElement(reader);
      }
      if (!configuredSubsystemTypes.add(reader.getNamespaceURI())) {
        throw AppClientLogger.ROOT_LOGGER.duplicateSubsystemDeclaration(reader.getLocation());
      }
      // parse subsystem
      final List<ModelNode> subsystems = new ArrayList<ModelNode>();
      reader.handleAny(subsystems);

      // Process subsystems
      for (final ModelNode update : subsystems) {
        // Process relative subsystem path address
        final ModelNode subsystemAddress = address.clone();
        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);
      }
    }
  }
Esempio n. 8
0
  public static Element nextElement(XMLExtendedStreamReader reader) throws XMLStreamException {
    if (reader.nextTag() == END_ELEMENT) {
      return null;
    }

    return Element.forName(reader.getLocalName());
  }
    @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);
      }
    }
Esempio n. 10
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());
      }
    }
  }
Esempio n. 11
0
  void parseServerGroups(
      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 serverGroup = Element.forName(reader.getLocalName());
      if (Element.SERVER_GROUP != serverGroup) {
        throw unexpectedElement(reader);
      }

      String name = null;
      String profile = null;
      Boolean managementSubsystemEndpoint = null;

      // 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 NAME:
              {
                if (name != null) {
                  throw ParseUtils.duplicateAttribute(reader, attribute.getLocalName());
                }
                if (!names.add(value)) {
                  throw ParseUtils.duplicateNamedElement(reader, value);
                }
                name = value;
                break;
              }
            case PROFILE:
              {
                if (profile != null) {
                  throw ParseUtils.duplicateAttribute(reader, attribute.getLocalName());
                }
                profile = value;
                break;
              }
            case MANAGEMENT_SUBSYSTEM_ENDPOINT:
              {
                if (managementSubsystemEndpoint != null) {
                  throw ParseUtils.duplicateAttribute(reader, attribute.getLocalName());
                }
                managementSubsystemEndpoint = Boolean.valueOf(value);
                break;
              }
            default:
              throw ParseUtils.unexpectedAttribute(reader, i);
          }
        }
      }
      if (name == null) {
        throw missingRequired(reader, Collections.singleton(Attribute.NAME));
      }
      if (profile == null) {
        throw missingRequired(reader, Collections.singleton(Attribute.PROFILE));
      }

      final ModelNode groupAddress = new ModelNode().set(address);
      groupAddress.add(ModelDescriptionConstants.SERVER_GROUP, name);

      final ModelNode group = new ModelNode();
      group.get(OP).set(ADD);
      group.get(OP_ADDR).set(groupAddress);
      group.get(PROFILE).set(profile);
      if (managementSubsystemEndpoint != null) {
        group.get(MANAGEMENT_SUBSYSTEM_ENDPOINT).set(managementSubsystemEndpoint);
      }
      list.add(group);

      // Handle elements

      boolean sawDeployments = false;
      while (reader.hasNext() && reader.nextTag() != END_ELEMENT) {
        requireNamespace(reader, expectedNs);
        final Element element = Element.forName(reader.getLocalName());
        switch (element) {
          case JVM:
            {
              JvmXml.parseJvm(reader, groupAddress, expectedNs, list, new HashSet<String>());
              break;
            }
          case SOCKET_BINDING_GROUP:
            {
              parseSocketBindingGroupRef(reader, groupAddress, list);
              break;
            }
          case DEPLOYMENTS:
            {
              if (sawDeployments) {
                throw MESSAGES.alreadyDefined(element.getLocalName(), reader.getLocation());
              }
              sawDeployments = true;
              parseDeployments(
                  reader,
                  groupAddress,
                  expectedNs,
                  list,
                  EnumSet.of(Attribute.NAME, Attribute.RUNTIME_NAME, Attribute.ENABLED),
                  Collections.<Element>emptySet());
              break;
            }
          case SYSTEM_PROPERTIES:
            {
              parseSystemProperties(reader, groupAddress, expectedNs, list, false);
              break;
            }
          default:
            throw ParseUtils.unexpectedElement(reader);
        }
      }
    }
  }
Esempio n. 12
0
  void parseSocketBindingGroup_1_1(
      final XMLExtendedStreamReader reader,
      final Set<String> interfaces,
      final ModelNode address,
      final Namespace expectedNs,
      final List<ModelNode> updates)
      throws XMLStreamException {
    final Set<String> includedGroups = new HashSet<String>();
    // both outbound-socket-bindings and socket-binding names
    final Set<String> uniqueBindingNames = new HashSet<String>();

    // Handle attributes
    final String[] attrValues =
        requireAttributes(
            reader, Attribute.NAME.getLocalName(), Attribute.DEFAULT_INTERFACE.getLocalName());
    final String socketBindingGroupName = attrValues[0];
    final String defaultInterface = attrValues[1];

    final ModelNode groupAddress = new ModelNode().set(address);
    groupAddress.add(SOCKET_BINDING_GROUP, socketBindingGroupName);

    final ModelNode bindingGroupUpdate = new ModelNode();
    bindingGroupUpdate.get(OP_ADDR).set(groupAddress);
    bindingGroupUpdate.get(OP).set(ADD);

    SocketBindingGroupResourceDefinition.DEFAULT_INTERFACE.parseAndSetParameter(
        defaultInterface, bindingGroupUpdate, reader);
    if (bindingGroupUpdate
                .get(SocketBindingGroupResourceDefinition.DEFAULT_INTERFACE.getName())
                .getType()
            != ModelType.EXPRESSION
        && !interfaces.contains(defaultInterface)) {
      throw MESSAGES.unknownInterface(
          defaultInterface,
          Attribute.DEFAULT_INTERFACE.getLocalName(),
          Element.INTERFACES.getLocalName(),
          reader.getLocation());
    }

    final ModelNode includes = bindingGroupUpdate.get(INCLUDES);
    includes.setEmptyList();
    updates.add(bindingGroupUpdate);

    // Handle elements
    while (reader.nextTag() != END_ELEMENT) {
      requireNamespace(reader, expectedNs);
      final Element element = Element.forName(reader.getLocalName());
      switch (element) {
          /* This will be reintroduced for 7.2.0, leave commented out
          case INCLUDE: {
              final String includedGroup = readStringAttributeElement(reader, Attribute.SOCKET_BINDING_GROUP.getLocalName());
              if (!includedGroups.add(includedGroup)) {
                  throw MESSAGES.alreadyDeclared(Attribute.SOCKET_BINDING_GROUP.getLocalName(), includedGroup, reader.getLocation());
              }
              SocketBindingGroupResourceDefinition.INCLUDES.parseAndAddParameterElement(includedGroup, bindingGroupUpdate, reader.getLocation());
              break;
          }
          */
        case SOCKET_BINDING:
          {
            final String bindingName =
                parseSocketBinding(reader, interfaces, groupAddress, updates);
            if (!uniqueBindingNames.add(bindingName)) {
              throw MESSAGES.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 MESSAGES.alreadyDeclared(
                  Element.SOCKET_BINDING.getLocalName(),
                  Element.OUTBOUND_SOCKET_BINDING.getLocalName(),
                  bindingName,
                  Element.SOCKET_BINDING_GROUP.getLocalName(),
                  socketBindingGroupName,
                  reader.getLocation());
            }
            break;
          }
        default:
          throw unexpectedElement(reader);
      }
    }
  }
Esempio n. 13
0
 public static String localName(final Element element) {
   return element.getLocalName();
 }
Esempio n. 14
0
  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);
      }
    }
  }