@Override
  public void writeContent(final XMLExtendedStreamWriter writer, final Distribution distribution)
      throws XMLStreamException {

    // Get started ...
    writer.writeStartDocument();
    writer.writeStartElement(Element.DISTRIBUTION.name);
    writer.writeDefaultNamespace(DistributionXml.Namespace.DISTRIBUTION_1_0.getNamespace());

    final DistributionContentItem root = distribution.getRoot();
    final Collection<DistributionContentItem> children = root.getChildren();

    final Set<String> layers = distribution.getLayers();
    if (!layers.isEmpty()) {
      writer.writeStartElement(Element.LAYERS.name);
      for (final String layerName : layers) {
        final Distribution.ProcessedLayer layer = distribution.getLayer(layerName);
        writeLayer(writer, layer, Element.LAYER);
      }
      writer.writeEndElement();
    }
    final Set<String> addOns = distribution.getAddOns();
    if (!addOns.isEmpty()) {
      writer.writeStartElement(Element.ADD_ONS.name);
      for (final String addOnName : addOns) {
        final Distribution.ProcessedLayer addOn = distribution.getAddOn(addOnName);
        writeLayer(writer, addOn, Element.ADD_ON);
      }
      writer.writeEndElement();
    }

    // The misc tree
    writer.writeStartElement(Element.FILES.name);
    writeChildren(writer, children);
    writer.writeEndElement();

    // Done
    writer.writeEndElement();
    writer.writeEndDocument();
  }
Exemple #2
0
  @Override
  public void writeContent(
      final XMLExtendedStreamWriter writer, final ModelMarshallingContext context)
      throws XMLStreamException {
    ModelNode modelNode = context.getModelNode();

    writer.writeStartDocument();
    writer.writeStartElement(Element.DOMAIN.getLocalName());

    writer.writeDefaultNamespace(Namespace.CURRENT.getUriString());
    writeNamespaces(writer, modelNode);
    writeSchemaLocation(writer, modelNode);

    DomainAttributes.NAME.marshallAsAttribute(modelNode, false, writer);

    writeNewLine(writer);

    if (modelNode.hasDefined(EXTENSION)) {
      extensionXml.writeExtensions(writer, modelNode.get(EXTENSION));
      writeNewLine(writer);
    }
    if (modelNode.hasDefined(SYSTEM_PROPERTY)) {
      writeProperties(writer, modelNode.get(SYSTEM_PROPERTY), Element.SYSTEM_PROPERTIES, false);
      writeNewLine(writer);
    }
    if (modelNode.hasDefined(PATH)) {
      writePaths(writer, modelNode.get(PATH));
      writeNewLine(writer);
    }
    if (modelNode.hasDefined(PROFILE)) {
      writer.writeStartElement(Element.PROFILES.getLocalName());
      for (final Property profile : modelNode.get(PROFILE).asPropertyList()) {
        writeProfile(writer, profile.getName(), profile.getValue(), context);
      }
      writer.writeEndElement();
      writeNewLine(writer);
    }
    if (modelNode.hasDefined(INTERFACE)) {
      writeInterfaces(writer, modelNode.get(INTERFACE));
      writeNewLine(writer);
    }
    if (modelNode.hasDefined(SOCKET_BINDING_GROUP)) {
      writer.writeStartElement(Element.SOCKET_BINDING_GROUPS.getLocalName());
      for (final Property property : modelNode.get(SOCKET_BINDING_GROUP).asPropertyList()) {
        writeSocketBindingGroup(writer, property.getValue(), false);
      }
      writer.writeEndElement();
      writeNewLine(writer);
    }
    if (modelNode.hasDefined(DEPLOYMENT)) {
      writeDomainDeployments(writer, modelNode.get(DEPLOYMENT));
      writeNewLine(writer);
    }
    if (modelNode.hasDefined(SERVER_GROUP)) {
      writer.writeStartElement(Element.SERVER_GROUPS.getLocalName());
      for (final Property property : modelNode.get(SERVER_GROUP).asPropertyList()) {
        writeServerGroup(writer, property.getName(), property.getValue());
      }
      writer.writeEndElement();
      writeNewLine(writer);
    }
    if (modelNode.hasDefined(MANAGEMENT_CLIENT_CONTENT)) {
      writeManagementClientContent(writer, modelNode.get(MANAGEMENT_CLIENT_CONTENT));
      writeNewLine(writer);
    }

    writer.writeEndElement();
    writeNewLine(writer);
    writer.writeEndDocument();
  }