Beispiel #1
0
  private void writeServerGroup(
      final XMLExtendedStreamWriter writer, final String groupName, final ModelNode group)
      throws XMLStreamException {
    writer.writeStartElement(Element.SERVER_GROUP.getLocalName());
    writer.writeAttribute(Attribute.NAME.getLocalName(), groupName);
    writer.writeAttribute(Attribute.PROFILE.getLocalName(), group.get(PROFILE).asString());

    // JVM
    if (group.hasDefined(JVM)) {
      for (final Property jvm : group.get(JVM).asPropertyList()) {
        JvmXml.writeJVMElement(writer, jvm.getName(), jvm.getValue());
        break; // TODO just write the first !?
      }
    }

    // Socket binding ref
    String bindingGroupRef =
        group.hasDefined(SOCKET_BINDING_GROUP) ? group.get(SOCKET_BINDING_GROUP).asString() : null;
    String portOffset =
        group.hasDefined(SOCKET_BINDING_PORT_OFFSET)
            ? group.get(SOCKET_BINDING_PORT_OFFSET).asString()
            : null;
    Boolean managementSubsystemEndpoint =
        group.hasDefined(MANAGEMENT_SUBSYSTEM_ENDPOINT)
            ? group.get(MANAGEMENT_SUBSYSTEM_ENDPOINT).asBoolean()
            : null;
    if (bindingGroupRef != null || portOffset != null) {
      writer.writeStartElement(Element.SOCKET_BINDING_GROUP.getLocalName());
      if (bindingGroupRef != null) {
        writeAttribute(writer, Attribute.REF, bindingGroupRef);
      }
      if (portOffset != null) {
        writeAttribute(writer, Attribute.PORT_OFFSET, portOffset);
      }
      if (managementSubsystemEndpoint != null) {
        writeAttribute(
            writer,
            Attribute.MANAGEMENT_SUBSYSTEM_ENDPOINT,
            managementSubsystemEndpoint.toString());
      }
      writer.writeEndElement();
    }

    if (group.hasDefined(DEPLOYMENT)) {
      writeServerGroupDeployments(writer, group.get(DEPLOYMENT));
    }
    // System properties
    if (group.hasDefined(SYSTEM_PROPERTY)) {
      writeProperties(writer, group.get(SYSTEM_PROPERTY), Element.SYSTEM_PROPERTIES, false);
    }

    writer.writeEndElement();
  }
Beispiel #2
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);
      }
    }
  }
Beispiel #3
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);
      }
    }
  }