Java Code Examples for org.jboss.staxmapper.XMLExtendedStreamWriter#writeEndDocument()
The following examples show how to use
org.jboss.staxmapper.XMLExtendedStreamWriter#writeEndDocument() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: TestParser.java From wildfly-core with GNU Lesser General Public License v2.1 | 6 votes |
@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(); }
Example 2
Source File: PatchXml_1_0.java From wildfly-core with GNU Lesser General Public License v2.1 | 5 votes |
@Override public void writeContent(final XMLExtendedStreamWriter writer, final Patch patch) throws XMLStreamException { // Get started ... writer.writeStartDocument(); writer.writeStartElement(Element.PATCH.name); writer.writeDefaultNamespace(PatchXml.Namespace.PATCH_1_2.getNamespace()); writePatch(writer, patch); // Done writer.writeEndElement(); writer.writeEndDocument(); }
Example 3
Source File: RollbackPatchXml_1_0.java From wildfly-core with GNU Lesser General Public License v2.1 | 5 votes |
@Override public void writeContent(final XMLExtendedStreamWriter writer, final RollbackPatch rollbackPatch) throws XMLStreamException { // Get started ... writer.writeStartDocument(); writer.writeStartElement(Element.PATCH.name); writer.writeDefaultNamespace(PatchXml.Namespace.ROLLBACK_1_2.getNamespace()); writePatch(writer, rollbackPatch); writeInstallation(writer, rollbackPatch.getIdentityState()); // Done writer.writeEndElement(); writer.writeEndDocument(); }
Example 4
Source File: DomainXml_14.java From wildfly-core with GNU Lesser General Public License v2.1 | 4 votes |
void writeContent(final XMLExtendedStreamWriter writer, final ModelMarshallingContext context) throws XMLStreamException { ModelNode modelNode = context.getModelNode(); writer.writeStartDocument(); writer.writeStartElement(Element.DOMAIN.getLocalName()); writer.writeDefaultNamespace(CURRENT.getUriString()); writeNamespaces(writer, modelNode); writeSchemaLocation(writer, modelNode); DomainRootDefinition.NAME.marshallAsAttribute(modelNode, false, writer); if (modelNode.hasDefined(DOMAIN_ORGANIZATION)) { DomainRootDefinition.ORGANIZATION_IDENTIFIER.marshallAsAttribute(modelNode, writer); } if (modelNode.hasDefined(EXTENSION)) { extensionXml.writeExtensions(writer, modelNode.get(EXTENSION)); } if (modelNode.hasDefined(SYSTEM_PROPERTY)) { writeProperties(writer, modelNode.get(SYSTEM_PROPERTY), Element.SYSTEM_PROPERTIES, false); } if (modelNode.hasDefined(PATH)) { writePaths(writer, modelNode.get(PATH), true); } if (modelNode.hasDefined(CORE_SERVICE) && modelNode.get(CORE_SERVICE).hasDefined(MANAGEMENT)) { // We use CURRENT here as we only support writing the most recent. ManagementXml managementXml = ManagementXml.newInstance(CURRENT, this, true); managementXml.writeManagement(writer, modelNode.get(CORE_SERVICE, MANAGEMENT), true); } if (modelNode.hasDefined(PROFILE)) { writer.writeStartElement(Element.PROFILES.getLocalName()); ModelNode profiles = modelNode.get(PROFILE); for (final String profile : profiles.keys()) { writeProfile(writer, profile, profiles.get(profile), context); } writer.writeEndElement(); } if (modelNode.hasDefined(INTERFACE)) { writeInterfaces(writer, modelNode.get(INTERFACE)); } if (modelNode.hasDefined(SOCKET_BINDING_GROUP)) { writer.writeStartElement(Element.SOCKET_BINDING_GROUPS.getLocalName()); ModelNode sbgs = modelNode.get(SOCKET_BINDING_GROUP); for (final String sbg : sbgs.keys()) { writeSocketBindingGroup(writer, sbgs.get(sbg), sbg); } writer.writeEndElement(); } if (modelNode.hasDefined(DEPLOYMENT)) { writeDomainDeployments(writer, modelNode.get(DEPLOYMENT)); } if (modelNode.hasDefined(DEPLOYMENT_OVERLAY)) { writeDeploymentOverlays(writer, modelNode.get(DEPLOYMENT_OVERLAY)); } if (modelNode.hasDefined(SERVER_GROUP)) { writer.writeStartElement(Element.SERVER_GROUPS.getLocalName()); ModelNode sgs = modelNode.get(SERVER_GROUP); for (final String sg : sgs.keys()) { writeServerGroup(writer, sg, sgs.get(sg)); } writer.writeEndElement(); } if (modelNode.hasDefined(HOST_EXCLUDE)) { writeHostExcludes(writer, modelNode.get(HOST_EXCLUDE)); } if (modelNode.hasDefined(MANAGEMENT_CLIENT_CONTENT)) { writeManagementClientContent(writer, modelNode.get(MANAGEMENT_CLIENT_CONTENT)); } writer.writeEndElement(); writer.writeEndDocument(); }
Example 5
Source File: HostXml_14.java From wildfly-core with GNU Lesser General Public License v2.1 | 4 votes |
void writeContent(final XMLExtendedStreamWriter writer, final ModelMarshallingContext context) throws XMLStreamException { final ModelNode modelNode = context.getModelNode(); writer.writeStartDocument(); writer.writeStartElement(Element.HOST.getLocalName()); writer.writeDefaultNamespace(Namespace.CURRENT.getUriString()); writeNamespaces(writer, modelNode); writeSchemaLocation(writer, modelNode); if (modelNode.hasDefined(NAME)) { HostResourceDefinition.NAME.marshallAsAttribute(modelNode, writer); } if (modelNode.hasDefined(ORGANIZATION)) { HostResourceDefinition.ORGANIZATION_IDENTIFIER.marshallAsAttribute(modelNode, writer); } if (modelNode.hasDefined(EXTENSION)) { extensionXml.writeExtensions(writer, modelNode.get(EXTENSION)); } if (modelNode.hasDefined(SYSTEM_PROPERTY)) { writeProperties(writer, modelNode.get(SYSTEM_PROPERTY), Element.SYSTEM_PROPERTIES, false); } if (modelNode.hasDefined(PATH)) { writePaths(writer, modelNode.get(PATH), false); } boolean hasCoreServices = modelNode.hasDefined(CORE_SERVICE); if (hasCoreServices && modelNode.get(CORE_SERVICE).hasDefined(VAULT)) { writeVault(writer, modelNode.get(CORE_SERVICE, VAULT)); } if (hasCoreServices) { ManagementXml managementXml = ManagementXml.newInstance(CURRENT, this, false); managementXml.writeManagement(writer, modelNode.get(CORE_SERVICE, MANAGEMENT), true); } if (modelNode.hasDefined(DOMAIN_CONTROLLER)) { ModelNode ignoredResources = null; ModelNode discoveryOptions = null; if (hasCoreServices && modelNode.get(CORE_SERVICE).hasDefined(IGNORED_RESOURCES) && modelNode.get(CORE_SERVICE, IGNORED_RESOURCES).hasDefined(IGNORED_RESOURCE_TYPE)) { ignoredResources = modelNode.get(CORE_SERVICE, IGNORED_RESOURCES, IGNORED_RESOURCE_TYPE); } if (hasCoreServices && modelNode.get(CORE_SERVICE).hasDefined(DISCOVERY_OPTIONS) && modelNode.get(CORE_SERVICE, DISCOVERY_OPTIONS).hasDefined(ModelDescriptionConstants.OPTIONS)) { // List of discovery option types and names, in the order they were provided discoveryOptions = modelNode.get(CORE_SERVICE, DISCOVERY_OPTIONS, ModelDescriptionConstants.OPTIONS); } writeDomainController(writer, modelNode.get(DOMAIN_CONTROLLER), ignoredResources, discoveryOptions); } if (modelNode.hasDefined(INTERFACE)) { writeInterfaces(writer, modelNode.get(INTERFACE)); } if (modelNode.hasDefined(JVM)) { writer.writeStartElement(Element.JVMS.getLocalName()); ModelNode jvms = modelNode.get(JVM); for (final String jvm : jvms.keys()) { JvmXml.writeJVMElement(writer, jvm, jvms.get(jvm)); } writer.writeEndElement(); } if (modelNode.hasDefined(SERVER_CONFIG)) { writer.writeStartElement(Element.SERVERS.getLocalName()); // Write the directory grouping HostResourceDefinition.DIRECTORY_GROUPING.marshallAsAttribute(modelNode, writer); writeServers(writer, modelNode.get(SERVER_CONFIG)); writer.writeEndElement(); } else if (modelNode.hasDefined(DIRECTORY_GROUPING)) { // In case there are no servers defined, write an empty element, preserving the directory grouping writer.writeEmptyElement(Element.SERVERS.getLocalName()); HostResourceDefinition.DIRECTORY_GROUPING.marshallAsAttribute(modelNode, writer); } writeHostProfile(writer, context); if (modelNode.hasDefined(SOCKET_BINDING_GROUP)) { Set<String> groups = modelNode.get(SOCKET_BINDING_GROUP).keys(); if (groups.size() > 1) { throw ControllerLogger.ROOT_LOGGER.multipleModelNodes(SOCKET_BINDING_GROUP); } for (String group : groups) { writeSocketBindingGroup(writer, modelNode.get(SOCKET_BINDING_GROUP, group), group); } } writer.writeEndElement(); writer.writeEndDocument(); }
Example 6
Source File: StandaloneXml_14.java From wildfly-core with GNU Lesser General Public License v2.1 | 4 votes |
void writeContent(final XMLExtendedStreamWriter writer, final ModelMarshallingContext context) throws XMLStreamException { ModelNode modelNode = context.getModelNode(); writer.writeStartDocument(); writer.writeStartElement(Element.SERVER.getLocalName()); if (modelNode.hasDefined(NAME)) { ServerRootResourceDefinition.NAME.marshallAsAttribute(modelNode, false, writer); } if (modelNode.hasDefined(ORGANIZATION_IDENTIFIER.getName())) { ServerRootResourceDefinition.ORGANIZATION_IDENTIFIER.marshallAsAttribute(modelNode, false, writer); } writer.writeDefaultNamespace(CURRENT.getUriString()); writeNamespaces(writer, modelNode); writeSchemaLocation(writer, modelNode); if (modelNode.hasDefined(EXTENSION)) { extensionHandler.writeExtensions(writer, modelNode.get(EXTENSION)); } if (modelNode.hasDefined(SYSTEM_PROPERTY)) { writeProperties(writer, modelNode.get(SYSTEM_PROPERTY), Element.SYSTEM_PROPERTIES, true); } if (modelNode.hasDefined(PATH)) { writePaths(writer, modelNode.get(PATH), false); } if (modelNode.hasDefined(CORE_SERVICE) && modelNode.get(CORE_SERVICE).hasDefined(VAULT)) { writeVault(writer, modelNode.get(CORE_SERVICE, VAULT)); } if (modelNode.hasDefined(CORE_SERVICE)) { ManagementXml managementXml = ManagementXml.newInstance(CURRENT, this, false); managementXml.writeManagement(writer, modelNode.get(CORE_SERVICE, MANAGEMENT), true); } writeServerProfile(writer, context); if (modelNode.hasDefined(INTERFACE)) { writeInterfaces(writer, modelNode.get(INTERFACE)); } if (modelNode.hasDefined(SOCKET_BINDING_GROUP)) { Set<String> groups = modelNode.get(SOCKET_BINDING_GROUP).keys(); if (groups.size() > 1) { throw ControllerLogger.ROOT_LOGGER.multipleModelNodes(SOCKET_BINDING_GROUP); } for (String group : groups) { writeSocketBindingGroup(writer, modelNode.get(SOCKET_BINDING_GROUP, group), group); } } if (modelNode.hasDefined(DEPLOYMENT)) { writeServerDeployments(writer, modelNode.get(DEPLOYMENT)); WriteUtils.writeNewLine(writer); } if (modelNode.hasDefined(DEPLOYMENT_OVERLAY)) { writeDeploymentOverlays(writer, modelNode.get(DEPLOYMENT_OVERLAY)); WriteUtils.writeNewLine(writer); } writer.writeEndElement(); writer.writeEndDocument(); }
Example 7
Source File: ModuleConfigImpl.java From wildfly-core with GNU Lesser General Public License v2.1 | 4 votes |
@Override public void writeContent(XMLExtendedStreamWriter writer, ModuleConfig value) throws XMLStreamException { writer.writeStartDocument(); writer.writeStartElement(MODULE); writer.writeDefaultNamespace(MODULE_NS); if(moduleName == null) { throw new XMLStreamException("Module name is missing."); } writer.writeAttribute(NAME, moduleName); if (slotName != null) { writer.writeAttribute(SLOT, slotName); } if(properties != null) { writeNewLine(writer); writer.writeStartElement(PROPERTIES); for(Map.Entry<String, String> entry: properties.entrySet()) { writer.writeStartElement(PROPERTY); writer.writeAttribute(NAME, entry.getKey()); writer.writeAttribute(VALUE, entry.getValue()); writer.writeEndElement(); } writer.writeEndElement(); } if(mainClass != null) { writeNewLine(writer); writer.writeStartElement(MAIN_CLASS); writer.writeAttribute(NAME, mainClass); writer.writeEndElement(); } if(resources != null) { writeNewLine(writer); writer.writeStartElement(RESOURCES); for(Resource res : resources) { res.writeContent(writer, res); } writer.writeEndElement(); } if(dependencies != null) { writeNewLine(writer); writer.writeStartElement(DEPENDENCIES); for(Dependency dep : dependencies) { dep.writeContent(writer, dep); } writer.writeEndElement(); } writeNewLine(writer); writer.writeEndElement(); writer.writeEndDocument(); }