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