use of javax.xml.stream.XMLStreamWriter in project aries by apache.
the class InitContextExample method initContext.
@Override
public void initContext(ContextEnricher contextEnricher) {
final Map<String, String> customParameters = contextEnricher.getBlueprintConfiguration().getCustomParameters();
for (final String param : customParameters.keySet()) {
if (param.startsWith("example.")) {
final String key = param.split("\\.")[1];
contextEnricher.addBlueprintContentWriter("enrichContextWithExample-" + key, new XmlWriter() {
@Override
public void write(XMLStreamWriter xmlStreamWriter) throws XMLStreamException {
xmlStreamWriter.writeEmptyElement("example");
xmlStreamWriter.writeDefaultNamespace("http://exampleNamespace");
xmlStreamWriter.writeAttribute("id", key);
xmlStreamWriter.writeAttribute("value", customParameters.get(param));
}
});
}
}
}
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 spring-framework by spring-projects.
the class AbstractMarshallerTests method marshalStaxResultStreamWriter.
@Test
public void marshalStaxResultStreamWriter() throws Exception {
XMLOutputFactory outputFactory = XMLOutputFactory.newInstance();
StringWriter writer = new StringWriter();
XMLStreamWriter streamWriter = outputFactory.createXMLStreamWriter(writer);
Result result = StaxUtils.createStaxResult(streamWriter);
marshaller.marshal(flights, result);
assertThat("Marshaller writes invalid StreamResult", writer.toString(), isSimilarTo(EXPECTED_STRING));
}
Aggregations