Search in sources :

Example 21 with XMLStreamWriter

use of javax.xml.stream.XMLStreamWriter in project aries by apache.

the class SpringTransactionalFactory method handleBeanAnnotation.

@Override
public void handleBeanAnnotation(AnnotatedElement annotatedElement, String id, ContextEnricher contextEnricher, BeanEnricher beanEnricher) {
    final String nsTx1 = getNamespaceByPattern(contextEnricher.getBlueprintConfiguration().getNamespaces(), PATTERN_NS_TX1);
    if (nsTx1 != null) {
        enableAnnotationTx1(contextEnricher, nsTx1);
        final Transactional transactional = annotatedElement.getAnnotation(Transactional.class);
        final String transactionTypeName = getTransactionTypeName(transactional);
        beanEnricher.addBeanContentWriter("javax.transactional.method/" + annotatedElement + "/*/" + transactionTypeName, new XmlWriter() {

            @Override
            public void write(XMLStreamWriter writer) throws XMLStreamException {
                writer.writeEmptyElement("transaction");
                writer.writeDefaultNamespace(nsTx1);
                writer.writeAttribute("method", "*");
                writer.writeAttribute("value", transactionTypeName);
            }
        });
    }
    final String nsTx2 = getNamespaceByPattern(contextEnricher.getBlueprintConfiguration().getNamespaces(), PATTERN_NS_TX1);
    if (nsTx2 != null) {
        insertEnableAnnotationTx2(contextEnricher, nsTx2);
    }
}
Also used : XMLStreamException(javax.xml.stream.XMLStreamException) XMLStreamWriter(javax.xml.stream.XMLStreamWriter) XmlWriter(org.apache.aries.blueprint.plugin.spi.XmlWriter) Transactional(org.springframework.transaction.annotation.Transactional)

Example 22 with XMLStreamWriter

use of javax.xml.stream.XMLStreamWriter in project aries by apache.

the class SpringTransactionalFactory method handleMethodAnnotation.

@Override
public void handleMethodAnnotation(Class<?> clazz, List<Method> methods, ContextEnricher contextEnricher, BeanEnricher beanEnricher) {
    final String nsTx1 = getNamespaceByPattern(contextEnricher.getBlueprintConfiguration().getNamespaces(), PATTERN_NS_TX1);
    if (nsTx1 != null) {
        enableAnnotationTx1(contextEnricher, nsTx1);
        for (final Method method : methods) {
            final Transactional transactional = method.getAnnotation(Transactional.class);
            final String transactionTypeName = getTransactionTypeName(transactional);
            final String name = method.getName();
            beanEnricher.addBeanContentWriter("javax.transactional.method/" + clazz.getName() + "/" + name + "/" + transactionTypeName, new XmlWriter() {

                @Override
                public void write(XMLStreamWriter writer) throws XMLStreamException {
                    writer.writeEmptyElement("transaction");
                    writer.writeDefaultNamespace(nsTx1);
                    writer.writeAttribute("method", name);
                    writer.writeAttribute("value", transactionTypeName);
                }
            });
        }
    }
    final String nsTx2 = getNamespaceByPattern(contextEnricher.getBlueprintConfiguration().getNamespaces(), PATTERN_NS_TX2);
    if (nsTx2 != null) {
        insertEnableAnnotationTx2(contextEnricher, nsTx2);
    }
}
Also used : XMLStreamException(javax.xml.stream.XMLStreamException) XMLStreamWriter(javax.xml.stream.XMLStreamWriter) Method(java.lang.reflect.Method) XmlWriter(org.apache.aries.blueprint.plugin.spi.XmlWriter) Transactional(org.springframework.transaction.annotation.Transactional)

Example 23 with XMLStreamWriter

use of javax.xml.stream.XMLStreamWriter in project logging-log4j2 by apache.

the class DefaultConfigurationBuilder method writeXmlConfiguration.

@Override
public void writeXmlConfiguration(final OutputStream output) throws IOException {
    try {
        final XMLStreamWriter xmlWriter = XMLOutputFactory.newInstance().createXMLStreamWriter(output);
        writeXmlConfiguration(xmlWriter);
        xmlWriter.close();
    } catch (final XMLStreamException e) {
        if (e.getNestedException() instanceof IOException) {
            throw (IOException) e.getNestedException();
        }
        Throwables.rethrow(e);
    }
}
Also used : XMLStreamException(javax.xml.stream.XMLStreamException) XMLStreamWriter(javax.xml.stream.XMLStreamWriter) IOException(java.io.IOException)

Example 24 with XMLStreamWriter

use of javax.xml.stream.XMLStreamWriter in project webservices-axiom by apache.

the class TestGetPrefixAfterWriteNamespace method runTest.

protected void runTest() throws Throwable {
    XMLStreamWriter writer = staxImpl.newNormalizedXMLOutputFactory().createXMLStreamWriter(new NullOutputStream());
    writer.writeStartElement("", "root", "");
    writer.writeNamespace("p", "urn:test");
    assertEquals("p", writer.getPrefix("urn:test"));
}
Also used : XMLStreamWriter(javax.xml.stream.XMLStreamWriter) NullOutputStream(org.apache.commons.io.output.NullOutputStream)

Example 25 with XMLStreamWriter

use of javax.xml.stream.XMLStreamWriter in project webservices-axiom by apache.

the class TestSetPrefixScope method runTest.

protected void runTest() throws Throwable {
    XMLOutputFactory factory = staxImpl.newNormalizedXMLOutputFactory();
    XMLStreamWriter writer = factory.createXMLStreamWriter(new ByteArrayOutputStream());
    writer.writeStartDocument();
    writer.writeStartElement("root");
    writer.setPrefix("p", "urn:ns");
    writer.writeStartElement("child");
    assertEquals("p", writer.getPrefix("urn:ns"));
    writer.writeEndElement();
    assertEquals("p", writer.getPrefix("urn:ns"));
    writer.writeEndElement();
    writer.writeEndDocument();
    writer.close();
}
Also used : XMLOutputFactory(javax.xml.stream.XMLOutputFactory) XMLStreamWriter(javax.xml.stream.XMLStreamWriter) ByteArrayOutputStream(java.io.ByteArrayOutputStream)

Aggregations

XMLStreamWriter (javax.xml.stream.XMLStreamWriter)82 XMLStreamException (javax.xml.stream.XMLStreamException)36 XMLOutputFactory (javax.xml.stream.XMLOutputFactory)28 StringWriter (java.io.StringWriter)15 ByteArrayOutputStream (java.io.ByteArrayOutputStream)14 IOException (java.io.IOException)12 XmlWriter (org.apache.aries.blueprint.plugin.spi.XmlWriter)7 OutputStream (java.io.OutputStream)6 StAXResult (javax.xml.transform.stax.StAXResult)6 Test (org.junit.Test)6 OutputStreamWriter (java.io.OutputStreamWriter)5 JAXBException (javax.xml.bind.JAXBException)5 StreamResult (javax.xml.transform.stream.StreamResult)5 ZipEntry (java.util.zip.ZipEntry)4 XMLStreamReader (javax.xml.stream.XMLStreamReader)4 PcrManifest (com.intel.mountwilson.manifest.data.PcrManifest)3 StringReader (java.io.StringReader)3 ToXmlGenerator (com.fasterxml.jackson.dataformat.xml.ser.ToXmlGenerator)2 IManifest (com.intel.mountwilson.manifest.data.IManifest)2 Headers (com.sun.net.httpserver.Headers)2