in buildtools/src/main/java/org/apache/cxf/maven/CXFAllTransformer.java [77:130]
public void modifyOutputStream(JarOutputStream jos) throws IOException {
List<String> imps = new ArrayList<String>(extensions.keySet());
for (Map.Entry<String, ByteArrayOutputStream> ent : extensions.entrySet()) {
jos.putNextEntry(new JarEntry(ent.getKey()));
ent.getValue().writeTo(jos);
try {
Document r = new SAXBuilder()
.build(new ByteArrayInputStream(ent.getValue().toByteArray()));
Element root = r.getRootElement();
for (Iterator itr = root.getChildren().iterator(); itr.hasNext();) {
Content n = (Content)itr.next();
if (n instanceof Element) {
Element e = (Element)n;
if ("import".equals(e.getName())
&& "http://www.springframework.org/schema/beans".equals(e.getNamespaceURI())) {
//remove stuff that is imported from other extensions to
//keep them from being loaded twice. (it's not an issue
//to load them twice, there just is a performance
//penalty in doing so
String loc = e.getAttributeValue("resource");
if (loc.startsWith("classpath:META-INF/cxf/cxf")) {
loc = loc.substring(10);
imps.remove(loc);
}
}
}
}
} catch (JDOMException e) {
throw new RuntimeException(e);
}
}
if (imps.size() > 0) {
jos.putNextEntry(new JarEntry("META-INF/cxf/cxf-all.xml"));
Writer writer = new OutputStreamWriter(jos, "UTF-8");
writer.append("<?xml version=\"1.0\" encoding=\"UTF-8\"?>");
writer.append("<beans xmlns=\"http://www.springframework.org/schema/beans\"\n");
writer.append(" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"\n");
writer.append(" xsi:schemaLocation=\"");
writer.append("http://www.springframework.org/schema/beans ");
writer.append("http://www.springframework.org/schema/beans/spring-beans.xsd\">\n");
writer.append(" <import resource=\"classpath:META-INF/cxf/cxf.xml\"/>\n");
for (String res : imps) {
writer.append(" <import resource=\"classpath:");
writer.append(res);
writer.append("\"/>\n");
}
writer.append("</beans>");
writer.flush();
}
}