本文整理汇总了Java中org.jboss.staxmapper.XMLElementWriter类的典型用法代码示例。如果您正苦于以下问题:Java XMLElementWriter类的具体用法?Java XMLElementWriter怎么用?Java XMLElementWriter使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
XMLElementWriter类属于org.jboss.staxmapper包,在下文中一共展示了XMLElementWriter类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: modelToXml
import org.jboss.staxmapper.XMLElementWriter; //导入依赖的package包/类
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();
}
示例2: writeProfile
import org.jboss.staxmapper.XMLElementWriter; //导入依赖的package包/类
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);
ProfileResourceDefinition.INCLUDES.getMarshaller().marshallAsAttribute(ProfileResourceDefinition.INCLUDES, profileNode, false, writer);
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();
}
示例3: wrapPossibleHost
import org.jboss.staxmapper.XMLElementWriter; //导入依赖的package包/类
private ModelMarshallingContext wrapPossibleHost(final ModelMarshallingContext context) {
if (type == TestModelType.HOST) {
return new ModelMarshallingContext() {
@Override
public XMLElementWriter<SubsystemMarshallingContext> getSubsystemWriter(String subsystemName) {
return context.getSubsystemWriter(subsystemName);
}
@Override
public ModelNode getModelNode() {
return context.getModelNode().get(ModelDescriptionConstants.HOST, "master");
}
};
}
return context;
}
示例4: sanitizeContext
import org.jboss.staxmapper.XMLElementWriter; //导入依赖的package包/类
private ModelMarshallingContext sanitizeContext(final ModelMarshallingContext context) {
if (writeSanitizers == null) {
return context;
}
ModelNode model = context.getModelNode();
for (ModelWriteSanitizer sanitizer : writeSanitizers) {
model = sanitizer.sanitize(model);
}
final ModelNode theModel = model;
return new ModelMarshallingContext() {
@Override
public XMLElementWriter<SubsystemMarshallingContext> getSubsystemWriter(String subsystemName) {
return context.getSubsystemWriter(subsystemName);
}
@Override
public ModelNode getModelNode() {
return theModel;
}
};
}
示例5: writeContent
import org.jboss.staxmapper.XMLElementWriter; //导入依赖的package包/类
@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();
}
示例6: deploy
import org.jboss.staxmapper.XMLElementWriter; //导入依赖的package包/类
@Deployment
public static JavaArchive deploy() throws Exception {
JavaArchive jar = ShrinkWrap.create(JavaArchive.class, "beans.jar");
jar.addPackage(StatefulTestBean.class.getPackage());
jar.addClasses(MgmtOperationException.class);
jar.addClasses(CustomModuleTestCase.class, MgmtOperationException.class, XMLElementReader.class,
XMLElementWriter.class, AbstractMgmtTestBase.class, ContainerResourceMgmtTestBase.class)
.addAsManifestResource(
new StringAsset(
"Dependencies: org.jboss.as.controller-client,org.jboss.dmr,org.jboss.as.cli \n"),
"MANIFEST.MF");
return jar;
}
示例7: writeHostProfile
import org.jboss.staxmapper.XMLElementWriter; //导入依赖的package包/类
private void writeHostProfile(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();
}
示例8: marshallAsXml
import org.jboss.staxmapper.XMLElementWriter; //导入依赖的package包/类
/** {@inheritDoc} */
@Override
public void marshallAsXml(final ModelNode model, final OutputStream output) throws ConfigurationPersistenceException {
final XMLMapper mapper = XMLMapper.Factory.create();
final Map<String, XMLElementWriter<SubsystemMarshallingContext>> localSubsystemWriters = new HashMap<>(subsystemWriters);
try {
XMLStreamWriter streamWriter = null;
try {
streamWriter = XMLOutputFactory.newInstance().createXMLStreamWriter(output);
final ModelMarshallingContext extensibleModel = new ModelMarshallingContext() {
@Override
public ModelNode getModelNode() {
return model;
}
@Override
public XMLElementWriter<SubsystemMarshallingContext> getSubsystemWriter(String extensionName) {
//lazy create writer, but only once per config serialization
XMLElementWriter<SubsystemMarshallingContext> result = localSubsystemWriters.get(extensionName);
if (result == null) {
Supplier<XMLElementWriter<SubsystemMarshallingContext>> supplier = subsystemWriterSuppliers.get(extensionName);
if (supplier != null) {
result = supplier.get();
localSubsystemWriters.put(extensionName, result);
}
}
return result;
}
};
mapper.deparseDocument(rootDeparser, extensibleModel, streamWriter);
streamWriter.close();
} finally {
safeClose(streamWriter);
}
} catch (Exception e) {
throw ControllerLogger.ROOT_LOGGER.failedToWriteConfiguration(e);
}
}
示例9: XmlConfigurationPersister
import org.jboss.staxmapper.XMLElementWriter; //导入依赖的package包/类
/**
* Construct a new instance.
*
* @param fileName the configuration base file name
* @param rootElement the root element of the configuration file
* @param rootParser the root model parser
* @param rootDeparser the root model deparser
*/
public XmlConfigurationPersister(final File fileName, final QName rootElement, final XMLElementReader<List<ModelNode>> rootParser,
final XMLElementWriter<ModelMarshallingContext> rootDeparser, final boolean suppressLoad) {
super(rootDeparser);
this.fileName = fileName;
this.rootElement = rootElement;
this.rootParser = rootParser;
this.additionalParsers = new HashMap<QName, XMLElementReader<List<ModelNode>>>();
this.suppressLoad = suppressLoad;
}
示例10: writeServerProfile
import org.jboss.staxmapper.XMLElementWriter; //导入依赖的package包/类
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();
}
示例11: marshal
import org.jboss.staxmapper.XMLElementWriter; //导入依赖的package包/类
public static void marshal(final Writer writer, final Patch patch) throws XMLStreamException {
final XMLOutputFactory outputFactory = OUTPUT_FACTORY;
final XMLStreamWriter streamWriter = outputFactory.createXMLStreamWriter(writer);
final XMLElementWriter<?> xmlWriter = XML1_0;
MAPPER.deparseDocument(xmlWriter, patch, streamWriter);
streamWriter.close();
}
示例12: registerSubsystemWriter
import org.jboss.staxmapper.XMLElementWriter; //导入依赖的package包/类
@Override
public void registerSubsystemWriter(String name, XMLElementWriter<SubsystemMarshallingContext> writer) {
delegate.registerSubsystemWriter(name, writer);
}
示例13: EmptyConfigurationPersister
import org.jboss.staxmapper.XMLElementWriter; //导入依赖的package包/类
public EmptyConfigurationPersister(XMLElementWriter<ModelMarshallingContext> rootDeparser) {
super(rootDeparser);
}
示例14: BackupRemoteDomainXmlPersister
import org.jboss.staxmapper.XMLElementWriter; //导入依赖的package包/类
BackupRemoteDomainXmlPersister(File file, File bootFile, QName rootElement, XMLElementReader<List<ModelNode>> rootParser, XMLElementWriter<ModelMarshallingContext> rootDeparser) {
super(file, rootElement, rootParser, rootDeparser);
this.bootWriter = new XmlConfigurationPersister(bootFile, rootElement, rootParser, rootDeparser);
this.file = file;
this.bootFile = bootFile;
}
示例15: registerSubsystemWriter
import org.jboss.staxmapper.XMLElementWriter; //导入依赖的package包/类
@Override
public void registerSubsystemWriter(String name, XMLElementWriter<SubsystemMarshallingContext> deparser) {
bootWriter.registerSubsystemWriter(name, deparser);
super.registerSubsystemWriter(name, deparser);
}