in starters/karaf-boot-starter-jpa/src/main/java/org/apache/karaf/boot/jpa/impl/JpaProcessor.java [55:102]
public void process(Writer writer, List<Class<?>> annotatedList) throws Exception {
Set<String> puNames = new HashSet<String>();
XMLOutputFactory xof = XMLOutputFactory.newInstance();
XMLStreamWriter w = new IndentingXMLStreamWriter(xof.createXMLStreamWriter(writer));
w.setDefaultNamespace("http://java.sun.com/xml/ns/persistence");
w.writeStartDocument();
w.writeStartElement("persistence");
w.writeAttribute("verson", "2.0");
// w.println("<persistence version=\"2.0\" xmlns=\"http://java.sun.com/xml/ns/persistence\"
// xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"
// xsi:schemaLocation=\"http://java.sun.com/xml/ns/persistence
// http://java.sun.com/xml/ns/persistence/persistence_2_0.xsd\">");
for (Class<?> annotated : annotatedList) {
PersistentUnit pu = annotated.getAnnotation(PersistentUnit.class);
if (pu.name() == null || pu.name().isEmpty()) {
throw new IOException("Missing persistent unit name");
}
if (!puNames.add(pu.name())) {
throw new IOException("Duplicate persistent unit name: " + pu.name());
}
w.writeStartElement("persistence-unit");
w.writeAttribute("name", pu.name());
w.writeAttribute("transaction-type", pu.transactionType().toString());
writeElement(w, "description", pu.description());
String providerName = getProvider(pu);
writeElement(w, "provider", providerName);
writeElement(w, "jta-data-source", pu.jtaDataSource());
writeElement(w, "non-jta-data-source", pu.nonJtaDataSource());
Map<String, String> props = new HashMap<>();
addProperties(pu, props);
addAnnProperties(annotated, props);
if (props.size() > 0) {
w.writeStartElement("properties");
for (String key : props.keySet()) {
w.writeEmptyElement("property");
w.writeAttribute("name", key);
w.writeAttribute("value", props.get(key));
}
w.writeEndElement();
}
w.writeEndElement();
}
w.writeEndElement();
w.writeEndDocument();
w.flush();
w.close();
}