当前位置: 首页>>代码示例>>Java>>正文


Java XMLExtendedStreamWriter类代码示例

本文整理汇总了Java中org.jboss.staxmapper.XMLExtendedStreamWriter的典型用法代码示例。如果您正苦于以下问题:Java XMLExtendedStreamWriter类的具体用法?Java XMLExtendedStreamWriter怎么用?Java XMLExtendedStreamWriter使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


XMLExtendedStreamWriter类属于org.jboss.staxmapper包,在下文中一共展示了XMLExtendedStreamWriter类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: StandaloneXMLParser

import org.jboss.staxmapper.XMLExtendedStreamWriter; //导入依赖的package包/类
public StandaloneXMLParser() {

        parserDelegate = new StandaloneXml(new ExtensionHandler() {
            @Override
            public void parseExtensions(XMLExtendedStreamReader reader, ModelNode address, Namespace namespace, List<ModelNode> list) throws XMLStreamException {
                reader.discardRemainder(); // noop
            }

            @Override
            public Set<ProfileParsingCompletionHandler> getProfileParsingCompletionHandlers() {
                return Collections.emptySet();
            }

            @Override
            public void writeExtensions(XMLExtendedStreamWriter writer, ModelNode modelNode) throws XMLStreamException {
                // noop
            }
        }, ParsingOption.IGNORE_SUBSYSTEM_FAILURES);

        xmlMapper = XMLMapper.Factory.create();

        addDelegate(new QName(Namespace.CURRENT.getUriString(), SERVER), parserDelegate);
        addDelegate(new QName("urn:jboss:domain:4.1", SERVER), parserDelegate);
        addDelegate(new QName("urn:jboss:domain:4.0", SERVER), parserDelegate);
        addDelegate(new QName("urn:jboss:domain:2.0", SERVER), parserDelegate);
    }
 
开发者ID:wildfly-swarm,项目名称:wildfly-swarm,代码行数:27,代码来源:StandaloneXMLParser.java

示例2: StandaloneXmlParser

import org.jboss.staxmapper.XMLExtendedStreamWriter; //导入依赖的package包/类
public StandaloneXmlParser() {

        parserDelegate = new StandaloneXml(new ExtensionHandler() {
            @Override
            public void parseExtensions(XMLExtendedStreamReader reader, ModelNode address, Namespace namespace, List<ModelNode> list) throws XMLStreamException {
                reader.discardRemainder(); // noop
            }

            @Override
            public Set<ProfileParsingCompletionHandler> getProfileParsingCompletionHandlers() {
                return Collections.EMPTY_SET;
            }

            @Override
            public void writeExtensions(XMLExtendedStreamWriter writer, ModelNode modelNode) throws XMLStreamException {
                // noop
            }
        }, ParsingOption.IGNORE_SUBSYSTEM_FAILURES);

        xmlMapper = XMLMapper.Factory.create();
        xmlMapper.registerRootElement(new QName("urn:jboss:domain:4.0", "server"), parserDelegate);

    }
 
开发者ID:wildfly-swarm-archive,项目名称:ARCHIVE-wildfly-swarm,代码行数:24,代码来源:StandaloneXmlParser.java

示例3: writeSources

import org.jboss.staxmapper.XMLExtendedStreamWriter; //导入依赖的package包/类
private void writeSources(XMLExtendedStreamWriter writer, ModelNode sources) throws XMLStreamException {
    for(String sourcePath : sources.keys()) {
        ModelNode source = sources.get(sourcePath);
        writer.writeStartElement(Constants.SOURCE);
        writer.writeAttribute(Constants.PATH, sourcePath);
        writer.writeAttribute(Constants.TYPE, source.get(Constants.TYPE).asString());

        if(source.hasDefined(Constants.ENABLED) && !source.get(Constants.ENABLED).asBoolean()) {
            writer.writeAttribute(Constants.ENABLED, "false");
        }

        ModelNode metrics = source.get(Constants.METRIC);
        writeMetrics(writer, metrics);

        writer.writeEndElement();
    }
}
 
开发者ID:ncdc,项目名称:jboss-openshift-metrics-module,代码行数:18,代码来源:OpenShiftSubsystemParser.java

示例4: testChildlessResource

import org.jboss.staxmapper.XMLExtendedStreamWriter; //导入依赖的package包/类
@Test
public void testChildlessResource() throws Exception {
    MyParser parser = new ChildlessParser();
    String xml =
            "<subsystem xmlns=\"" + MyParser.NAMESPACE + "\">" +
                    "   <cluster attr1=\"alice\"/>" +
                    "</subsystem>";
    StringReader strReader = new StringReader(xml);

    XMLMapper mapper = XMLMapper.Factory.create();
    mapper.registerRootElement(new QName(MyParser.NAMESPACE, "subsystem"), parser);

    XMLStreamReader reader = XMLInputFactory.newInstance().createXMLStreamReader(new StreamSource(strReader));
    List<ModelNode> operations = new ArrayList<>();
    mapper.parseDocument(operations, reader);

    ModelNode subsystem = opsToModel(operations);

    StringWriter stringWriter = new StringWriter();
    XMLExtendedStreamWriter xmlStreamWriter = createXMLStreamWriter(XMLOutputFactory.newInstance()
            .createXMLStreamWriter(stringWriter));
    SubsystemMarshallingContext context = new SubsystemMarshallingContext(subsystem, xmlStreamWriter);
    mapper.deparseDocument(parser, context, xmlStreamWriter);
    String out = stringWriter.toString();
    Assert.assertEquals(normalizeXML(xml), normalizeXML(out));
}
 
开发者ID:wildfly,项目名称:wildfly-core,代码行数:27,代码来源:PersistentResourceXMLParserTestCase.java

示例5: testServerWithComplexAttributeParser

import org.jboss.staxmapper.XMLExtendedStreamWriter; //导入依赖的package包/类
@Test
public void testServerWithComplexAttributeParser() throws Exception {
    ServerParser parser = new ServerParser();

    String xml = readResource("server-complex-attribute.xml");
    StringReader strReader = new StringReader(xml);

    XMLMapper mapper = XMLMapper.Factory.create();
    mapper.registerRootElement(new QName(MyParser.NAMESPACE, "subsystem"), parser);

    XMLStreamReader reader = XMLInputFactory.newInstance().createXMLStreamReader(new StreamSource(strReader));
    List<ModelNode> operations = new ArrayList<>();
    mapper.parseDocument(operations, reader);

    Assert.assertEquals(5, operations.size());
    ModelNode subsystem = opsToModel(operations);

    StringWriter stringWriter = new StringWriter();
    XMLExtendedStreamWriter xmlStreamWriter = createXMLStreamWriter(XMLOutputFactory.newInstance().createXMLStreamWriter(stringWriter));
    SubsystemMarshallingContext context = new SubsystemMarshallingContext(subsystem, xmlStreamWriter);
    mapper.deparseDocument(parser, context, xmlStreamWriter);
    String out = stringWriter.toString();
    Assert.assertEquals(normalizeXML(xml), normalizeXML(out));
}
 
开发者ID:wildfly,项目名称:wildfly-core,代码行数:25,代码来源:PersistentResourceXMLParserTestCase.java

示例6: writeSecurityRealm

import org.jboss.staxmapper.XMLExtendedStreamWriter; //导入依赖的package包/类
private void writeSecurityRealm(XMLExtendedStreamWriter writer, ModelNode management) throws XMLStreamException {
    ModelNode securityRealms = management.get(SECURITY_REALM);
    writer.writeStartElement(Element.SECURITY_REALMS.getLocalName());

    for (String variableName : securityRealms.keys()) {
        writer.writeStartElement(Element.SECURITY_REALM.getLocalName());
        writeAttribute(writer, Attribute.NAME, variableName);

        ModelNode realm = securityRealms.get(variableName);
        if (realm.hasDefined(PLUG_IN)) {
            writePlugIns(writer, realm.get(PLUG_IN));
        }

        if (realm.hasDefined(SERVER_IDENTITY)) {
            writeServerIdentities(writer, realm);
        }

        if (realm.hasDefined(AUTHENTICATION)) {
            writeAuthentication(writer, realm);
        }

        writeAuthorization(writer, realm);
        writer.writeEndElement();
    }
    writer.writeEndElement();
}
 
开发者ID:wildfly,项目名称:wildfly-core,代码行数:27,代码来源:ManagementXml_5.java

示例7: writeIgnoredResources

import org.jboss.staxmapper.XMLExtendedStreamWriter; //导入依赖的package包/类
private void writeIgnoredResources(XMLExtendedStreamWriter writer, ModelNode ignoredTypes) throws XMLStreamException {
    for (String ignoredName : ignoredTypes.keys()) {

        ModelNode ignored = ignoredTypes.get(ignoredName);

        ModelNode names = ignored.hasDefined(NAMES) ? ignored.get(NAMES) : null;
        boolean hasNames = names != null && names.asInt() > 0;
        if (hasNames) {
            writer.writeStartElement(Element.IGNORED_RESOURCE.getLocalName());
        } else {
            writer.writeEmptyElement(Element.IGNORED_RESOURCE.getLocalName());
        }

        writer.writeAttribute(Attribute.TYPE.getLocalName(), ignoredName);
        IgnoredDomainTypeResourceDefinition.WILDCARD.marshallAsAttribute(ignored, writer);

        if (hasNames) {
            for (ModelNode name : names.asList()) {
                writer.writeEmptyElement(Element.INSTANCE.getLocalName());
                writer.writeAttribute(Attribute.NAME.getLocalName(), name.asString());
            }
            writer.writeEndElement();
        }
    }
}
 
开发者ID:wildfly,项目名称:wildfly-core,代码行数:26,代码来源:HostXml_6.java

示例8: writeProfile

import org.jboss.staxmapper.XMLExtendedStreamWriter; //导入依赖的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();
    }
 
开发者ID:wildfly,项目名称:wildfly-core,代码行数:26,代码来源:DomainXml_6.java

示例9: writeDomainDeployments

import org.jboss.staxmapper.XMLExtendedStreamWriter; //导入依赖的package包/类
private void writeDomainDeployments(final XMLExtendedStreamWriter writer, final ModelNode modelNode) throws XMLStreamException {

        final Set<String> deploymentNames = modelNode.keys();
        if (deploymentNames.size() > 0) {
            writer.writeStartElement(Element.DEPLOYMENTS.getLocalName());
            for (String uniqueName : deploymentNames) {
                final ModelNode deployment = modelNode.get(uniqueName);
                writer.writeStartElement(Element.DEPLOYMENT.getLocalName());
                WriteUtils.writeAttribute(writer, Attribute.NAME, uniqueName);
                DeploymentAttributes.RUNTIME_NAME.marshallAsAttribute(deployment, writer);
                final List<ModelNode> contentItems = deployment.require(CONTENT).asList();
                for (ModelNode contentItem : contentItems) {
                    writeContentItem(writer, contentItem);
                }
                writer.writeEndElement();
            }
            writer.writeEndElement();
        }
    }
 
开发者ID:wildfly,项目名称:wildfly-core,代码行数:20,代码来源:DomainXml_6.java

示例10: writeServerGroupDeployments

import org.jboss.staxmapper.XMLExtendedStreamWriter; //导入依赖的package包/类
private void writeServerGroupDeployments(final XMLExtendedStreamWriter writer, final ModelNode modelNode) throws XMLStreamException {

        final Set<String> deploymentNames = modelNode.keys();
        if (deploymentNames.size() > 0) {
            writer.writeStartElement(Element.DEPLOYMENTS.getLocalName());
            for (String uniqueName : deploymentNames) {
                final ModelNode deployment = modelNode.get(uniqueName);
                writer.writeStartElement(Element.DEPLOYMENT.getLocalName());
                WriteUtils.writeAttribute(writer, Attribute.NAME, uniqueName);
                DeploymentAttributes.RUNTIME_NAME.marshallAsAttribute(deployment, writer);
                DeploymentAttributes.ENABLED.marshallAsAttribute(deployment, writer);
                writer.writeEndElement();
            }
            writer.writeEndElement();
        }
    }
 
开发者ID:wildfly,项目名称:wildfly-core,代码行数:17,代码来源:DomainXml_6.java

示例11: main

import org.jboss.staxmapper.XMLExtendedStreamWriter; //导入依赖的package包/类
public static void main(String[] args) throws Exception {

        ModuleConfigImpl module = new ModuleConfigImpl("o.r.g");

        module.setProperty("jboss.api", "private");
        module.setProperty("prop", VALUE);

        module.setMainClass("o.r.g.MainClass");

        module.addResource(new ResourceRoot("a.jar"));
        module.addResource(new ResourceRoot("another.jar"));

        module.addDependency(new ModuleDependency("a.module"));
        module.addDependency(new ModuleDependency("another.module"));

        StringWriter strWriter = new StringWriter();
        XMLExtendedStreamWriter writer = create(XMLOutputFactory.newInstance().createXMLStreamWriter(strWriter));
        module.writeContent(writer, module);
        writer.flush();
        System.out.println(strWriter.toString());
    }
 
开发者ID:wildfly,项目名称:wildfly-core,代码行数:22,代码来源:ModuleConfigImpl.java

示例12: writeContent

import org.jboss.staxmapper.XMLExtendedStreamWriter; //导入依赖的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();
}
 
开发者ID:wildfly,项目名称:wildfly-core,代码行数:24,代码来源:TestParser.java

示例13: writeConnector

import org.jboss.staxmapper.XMLExtendedStreamWriter; //导入依赖的package包/类
private void writeConnector(final XMLExtendedStreamWriter writer, final ModelNode node, final String name) throws XMLStreamException {
    writer.writeStartElement(Element.CONNECTOR.getLocalName());
    writer.writeAttribute(Attribute.NAME.getLocalName(), name);

    ConnectorResource.SOCKET_BINDING.marshallAsAttribute(node, writer);
    ConnectorResource.SSL_CONTEXT.marshallAsAttribute(node, writer);
    if (node.hasDefined(SECURITY_REALM)) {
        writer.writeAttribute(Attribute.SECURITY_REALM.getLocalName(), node.require(SECURITY_REALM).asString());
    }
    ConnectorCommon.SERVER_NAME.marshallAsAttribute(node, writer);
    ConnectorCommon.SASL_PROTOCOL.marshallAsAttribute(node, writer);
    ConnectorResource.SASL_AUTHENTICATION_FACTORY.marshallAsAttribute(node, writer);
    ConnectorResource.AUTHENTICATION_PROVIDER.marshallAsElement(node, writer);

    if (node.hasDefined(PROPERTY)) {
        writeProperties(writer, node.get(PROPERTY));
    }
    if (node.hasDefined(SECURITY) && node.get(SECURITY).hasDefined(SASL)) {
        writeSasl(writer, node.get(SECURITY, SASL));
    }
    writer.writeEndElement();
}
 
开发者ID:wildfly,项目名称:wildfly-core,代码行数:23,代码来源:RemotingSubsystemXMLPersister.java

示例14: writeHttpConnector

import org.jboss.staxmapper.XMLExtendedStreamWriter; //导入依赖的package包/类
private void writeHttpConnector(final XMLExtendedStreamWriter writer, final ModelNode node, final String name) throws XMLStreamException {
    writer.writeStartElement(Element.HTTP_CONNECTOR.getLocalName());
    writer.writeAttribute(Attribute.NAME.getLocalName(), name);

    HttpConnectorResource.CONNECTOR_REF.marshallAsAttribute(node, writer);
    if (node.hasDefined(SECURITY_REALM)) {
        HttpConnectorResource.SECURITY_REALM.marshallAsAttribute(node, writer);
    }
    ConnectorCommon.SERVER_NAME.marshallAsAttribute(node, writer);
    ConnectorCommon.SASL_PROTOCOL.marshallAsAttribute(node, writer);
    HttpConnectorResource.SASL_AUTHENTICATION_FACTORY.marshallAsAttribute(node, writer);
    HttpConnectorResource.AUTHENTICATION_PROVIDER.marshallAsElement(node, writer);

    if (node.hasDefined(PROPERTY)) {
        writeProperties(writer, node.get(PROPERTY));
    }
    if (node.hasDefined(SECURITY) && node.get(SECURITY).hasDefined(SASL)) {
        writeSasl(writer, node.get(SECURITY, SASL));
    }
    writer.writeEndElement();
}
 
开发者ID:wildfly,项目名称:wildfly-core,代码行数:22,代码来源:RemotingSubsystemXMLPersister.java

示例15: writeSasl

import org.jboss.staxmapper.XMLExtendedStreamWriter; //导入依赖的package包/类
private void writeSasl(final XMLExtendedStreamWriter writer, final ModelNode node) throws XMLStreamException {
    writer.writeStartElement(Element.SASL.getLocalName());
    SaslResource.INCLUDE_MECHANISMS_ATTRIBUTE.marshallAsElement(node, writer);
    SaslResource.QOP_ATTRIBUTE.marshallAsElement(node, writer);
    SaslResource.STRENGTH_ATTRIBUTE.marshallAsElement(node, writer);
    SaslResource.SERVER_AUTH_ATTRIBUTE.marshallAsElement(node, writer);
    SaslResource.REUSE_SESSION_ATTRIBUTE.marshallAsElement(node, writer);

    if (node.hasDefined(SASL_POLICY)) {
        writePolicy(writer, node.get(SASL_POLICY));
    }
    if (node.hasDefined(PROPERTY)) {
        writeProperties(writer, node.get(PROPERTY));
    }

    writer.writeEndElement();
}
 
开发者ID:wildfly,项目名称:wildfly-core,代码行数:18,代码来源:RemotingSubsystemXMLPersister.java


注:本文中的org.jboss.staxmapper.XMLExtendedStreamWriter类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。