@Override
 public void writeContent(XMLExtendedStreamWriter writer, ModelMarshallingContext context)
     throws XMLStreamException {
   String defaultNamespace =
       writer.getNamespaceContext().getNamespaceURI(XMLConstants.DEFAULT_NS_PREFIX);
   try {
     ModelNode subsystem = context.getModelNode().get(SUBSYSTEM, mainSubsystemName);
     XMLElementWriter<SubsystemMarshallingContext> subsystemWriter =
         context.getSubsystemWriter(mainSubsystemName);
     if (subsystemWriter != null) {
       subsystemWriter.writeContent(writer, new SubsystemMarshallingContext(subsystem, writer));
     }
   } finally {
     writer.setDefaultNamespace(defaultNamespace);
   }
   writer.writeEndDocument();
 }
  public void startSubsystemElement(
      XMLExtendedStreamWriter writer, String namespaceURI, boolean empty)
      throws XMLStreamException {

    if (writer.getNamespaceContext().getPrefix(namespaceURI) == null) {
      // Unknown namespace; it becomes default
      writer.setDefaultNamespace(namespaceURI);
      if (empty) {
        writer.writeEmptyElement(Element.SUBSYSTEM.getLocalName());
      } else {
        writer.writeStartElement(Element.SUBSYSTEM.getLocalName());
      }
      writer.writeNamespace(null, namespaceURI);
    } else {
      if (empty) {
        writer.writeEmptyElement(namespaceURI, Element.SUBSYSTEM.getLocalName());
      } else {
        writer.writeStartElement(namespaceURI, Element.SUBSYSTEM.getLocalName());
      }
    }
  }
Beispiel #3
0
  private void writeProfile(
      final XMLExtendedStreamWriter writer,
      final String profileName,
      final ModelNode profileNode,
      final ModelMarshallingContext context)
      throws XMLStreamException {

    writer.writeStartElement(Element.PROFILE.getLocalName());
    writer.writeAttribute(Attribute.NAME.getLocalName(), profileName);

    if (profileNode.hasDefined(INCLUDES)) {
      for (final ModelNode include : profileNode.get(INCLUDES).asList()) {
        writer.writeEmptyElement(INCLUDE);
        writer.writeAttribute(PROFILE, include.asString());
      }
    }
    if (profileNode.hasDefined(SUBSYSTEM)) {
      final Set<String> subsystemNames = profileNode.get(SUBSYSTEM).keys();
      if (subsystemNames.size() > 0) {
        String defaultNamespace =
            writer.getNamespaceContext().getNamespaceURI(XMLConstants.DEFAULT_NS_PREFIX);
        for (String subsystemName : subsystemNames) {
          try {
            ModelNode subsystem = profileNode.get(SUBSYSTEM, subsystemName);
            XMLElementWriter<SubsystemMarshallingContext> subsystemWriter =
                context.getSubsystemWriter(subsystemName);
            if (subsystemWriter
                != null) { // FIXME -- remove when extensions are doing the registration
              subsystemWriter.writeContent(
                  writer, new SubsystemMarshallingContext(subsystem, writer));
            }
          } finally {
            writer.setDefaultNamespace(defaultNamespace);
          }
        }
      }
    }
    writer.writeEndElement();
  }
Beispiel #4
0
  @Override
  public void writeContent(XMLExtendedStreamWriter writer, ModelMarshallingContext context)
      throws XMLStreamException {

    String defaultNamespace =
        writer.getNamespaceContext().getNamespaceURI(XMLConstants.DEFAULT_NS_PREFIX);
    try {
      ModelNode subsystem = context.getModelNode().get(SUBSYSTEM, mainSubsystemName);
      if (subsystem.isDefined()) {
        // We might have been removed
        XMLElementWriter<SubsystemMarshallingContext> subsystemWriter =
            context.getSubsystemWriter(mainSubsystemName);
        if (subsystemWriter != null) {
          subsystemWriter.writeContent(writer, new SubsystemMarshallingContext(subsystem, writer));
        }
      }
    } catch (Throwable t) {
      Assert.fail("could not marshal subsystem xml " + t);
    } finally {
      writer.setDefaultNamespace(defaultNamespace);
    }
    writer.writeEndDocument();
  }