org.jboss.staxmapper.XMLElementWriter类的使用及代码示例

x33g5p2x  于2022-02-03 转载在 其他  
字(11.2k)|赞(0)|评价(0)|浏览(78)

本文整理了Java中org.jboss.staxmapper.XMLElementWriter类的一些代码示例,展示了XMLElementWriter类的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。XMLElementWriter类的具体详情如下:
包路径:org.jboss.staxmapper.XMLElementWriter
类名称:XMLElementWriter

XMLElementWriter介绍

暂无

代码示例

代码示例来源:origin: org.wildfly.core/wildfly-core-model-test-framework

@Override
public void writeContent(XMLExtendedStreamWriter streamWriter, ModelMarshallingContext context) throws XMLStreamException {
  this.writer.writeContent(streamWriter, sanitizeContext(wrapPossibleHost(context)));
}

代码示例来源:origin: wildfly/wildfly-core

public String modelToXml(String subsystemName, String childType, XMLElementWriter<SubsystemMarshallingContext> parser) throws Exception {
  final ModelNode address = new ModelNode();
  address.add("subsystem", subsystemName);
  address.protect();
  final ModelNode operation = new ModelNode();
  operation.get(OP).set("read-children-resources");
  operation.get("child-type").set(childType);
  operation.get(RECURSIVE).set(true);
  operation.get(OP_ADDR).set(address);
  final ModelNode result = executeOperation(operation);
  Assert.assertNotNull(result);
  ModelNode dsNode = new ModelNode();
  dsNode.get(childType).set(result);
  StringWriter strWriter = new StringWriter();
  XMLExtendedStreamWriter writer = XMLExtendedStreamWriterFactory.create(XMLOutputFactory.newInstance()
      .createXMLStreamWriter(strWriter));
  parser.writeContent(writer, new SubsystemMarshallingContext(dsNode, writer));
  writer.flush();
  return strWriter.toString();
}

代码示例来源:origin: wildfly/wildfly-core

@Override
public void writeContent(XMLExtendedStreamWriter streamWriter, ModelMarshallingContext context) throws XMLStreamException {
  this.writer.writeContent(streamWriter, sanitizeContext(wrapPossibleHost(context)));
}

代码示例来源:origin: org.jboss.as/jboss-as-testsuite-shared

public String modelToXml(String subsystemName, String childType, XMLElementWriter<SubsystemMarshallingContext> parser) throws Exception {
  final ModelNode address = new ModelNode();
  address.add("subsystem", subsystemName);
  address.protect();
  final ModelNode operation = new ModelNode();
  operation.get(OP).set("read-children-resources");
  operation.get("child-type").set(childType);
  operation.get(RECURSIVE).set(true);
  operation.get(OP_ADDR).set(address);
  final ModelNode result = executeOperation(operation);
  Assert.assertNotNull(result);
  ModelNode dsNode = new ModelNode();
  dsNode.get(childType).set(result);
  StringWriter strWriter = new StringWriter();
  XMLExtendedStreamWriter writer = XMLExtendedStreamWriterFactory.create(XMLOutputFactory.newInstance()
      .createXMLStreamWriter(strWriter));
  parser.writeContent(writer, new SubsystemMarshallingContext(dsNode, writer));
  writer.flush();
  return strWriter.toString();
}

代码示例来源:origin: org.wildfly.core/wildfly-server

protected static void writeSubsystems(final ModelNode profileNode, final XMLExtendedStreamWriter writer,
                   final ModelMarshallingContext context) throws XMLStreamException {
  if (profileNode.hasDefined(SUBSYSTEM)) {
    Set<String> subsystemNames = profileNode.get(SUBSYSTEM).keys();
    if (subsystemNames.size() > 0) {
      if (isOrderExtensions()) {
        Set<String> alphabetical = new TreeSet<>(subsystemNames);
        if (alphabetical.contains("logging")) {
          subsystemNames = new LinkedHashSet<>();
          subsystemNames.add("logging");
          subsystemNames.addAll(alphabetical);
        } else {
          subsystemNames = alphabetical;
        }
      }
      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);
        }
      }
    }
  }
}

代码示例来源:origin: org.jboss.as/jboss-as-subsystem-test-framework

@Override
public void writeContent(XMLExtendedStreamWriter writer, ModelMarshallingContext context) throws XMLStreamException {
  String defaultNamespace = writer.getNamespaceContext().getNamespaceURI(XMLConstants.DEFAULT_NS_PREFIX);
  try {
    ModelNode subsystems = context.getModelNode().get(SUBSYSTEM);
    if (subsystems.has(mainSubsystemName)) {
      ModelNode subsystem = subsystems.get(mainSubsystemName);
      //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.getMessage()+":\n"+ Arrays.toString(t.getStackTrace()).replaceAll(", ","\n"));
  } finally {
    writer.setDefaultNamespace(defaultNamespace);
  }
  writer.writeEndDocument();
}

代码示例来源:origin: wildfly/wildfly-core

protected static void writeSubsystems(final ModelNode profileNode, final XMLExtendedStreamWriter writer,
                   final ModelMarshallingContext context) throws XMLStreamException {
  if (profileNode.hasDefined(SUBSYSTEM)) {
    Set<String> subsystemNames = profileNode.get(SUBSYSTEM).keys();
    if (subsystemNames.size() > 0) {
      if (isOrderExtensions()) {
        Set<String> alphabetical = new TreeSet<>(subsystemNames);
        if (alphabetical.contains("logging")) {
          subsystemNames = new LinkedHashSet<>();
          subsystemNames.add("logging");
          subsystemNames.addAll(alphabetical);
        } else {
          subsystemNames = alphabetical;
        }
      }
      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);
        }
      }
    }
  }
}

代码示例来源:origin: org.wildfly.core/wildfly-subsystem-test-framework

@Override
public void writeContent(XMLExtendedStreamWriter writer, ModelMarshallingContext context) throws XMLStreamException {
  String defaultNamespace = writer.getNamespaceContext().getNamespaceURI(XMLConstants.DEFAULT_NS_PREFIX);
  try {
    ModelNode subsystems = context.getModelNode().get(SUBSYSTEM);
    if (subsystems.has(mainSubsystemName)) {
      ModelNode subsystem = subsystems.get(mainSubsystemName);
      //We might have been removed
      XMLElementWriter<SubsystemMarshallingContext> subsystemWriter = context.getSubsystemWriter(mainSubsystemName);
      if (subsystemWriter != null) {
        subsystemWriter.writeContent(writer, new SubsystemMarshallingContext(subsystem, writer));
      }
    }else{
      writer.writeEmptyElement(Element.SUBSYSTEM.getLocalName());
    }
  }catch (Throwable t){
    Assert.fail("could not marshal subsystem xml: "+t.getMessage()+":\n"+ Arrays.toString(t.getStackTrace()).replaceAll(", ","\n"));
  } finally {
    writer.setDefaultNamespace(defaultNamespace);
  }
  writer.writeEndDocument();
}

代码示例来源:origin: wildfly/wildfly-core

@Override
public void writeContent(XMLExtendedStreamWriter writer, ModelMarshallingContext context) throws XMLStreamException {
  String defaultNamespace = writer.getNamespaceContext().getNamespaceURI(XMLConstants.DEFAULT_NS_PREFIX);
  try {
    ModelNode subsystems = context.getModelNode().get(SUBSYSTEM);
    if (subsystems.has(mainSubsystemName)) {
      ModelNode subsystem = subsystems.get(mainSubsystemName);
      //We might have been removed
      XMLElementWriter<SubsystemMarshallingContext> subsystemWriter = context.getSubsystemWriter(mainSubsystemName);
      if (subsystemWriter != null) {
        subsystemWriter.writeContent(writer, new SubsystemMarshallingContext(subsystem, writer));
      }
    }else{
      writer.writeEmptyElement(Element.SUBSYSTEM.getLocalName());
    }
  }catch (Throwable t){
    Assert.fail("could not marshal subsystem xml: "+t.getMessage()+":\n"+ Arrays.toString(t.getStackTrace()).replaceAll(", ","\n"));
  } finally {
    writer.setDefaultNamespace(defaultNamespace);
  }
  writer.writeEndDocument();
}

代码示例来源:origin: org.jboss.as/jboss-as-server

private void writeServerProfile(final XMLExtendedStreamWriter writer, final ModelMarshallingContext context)
    throws XMLStreamException {
  final ModelNode profileNode = context.getModelNode();
  // In case there are no subsystems defined
  if (!profileNode.hasDefined(SUBSYSTEM)) {
    return;
  }
  writer.writeStartElement(Element.PROFILE.getLocalName());
  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();
}

代码示例来源:origin: org.wildfly/wildfly-server

private void writeServerProfile(final XMLExtendedStreamWriter writer, final ModelMarshallingContext context)
    throws XMLStreamException {
  final ModelNode profileNode = context.getModelNode();
  // In case there are no subsystems defined
  if (!profileNode.hasDefined(SUBSYSTEM)) {
    return;
  }
  writer.writeStartElement(Element.PROFILE.getLocalName());
  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();
}

代码示例来源:origin: org.jboss.as/jboss-as-host-controller

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();
}

相关文章

XMLElementWriter类方法