in xbean-spring/src/main/java/org/apache/xbean/spring/generator/MappingGeneratorTask.java [95:150]
public void execute() throws BuildException {
if (namespace == null) {
throw new BuildException("'namespace' must be specified");
}
if (srcDir == null) {
throw new BuildException("'srcDir' must be specified");
}
if (destFile == null) {
throw new BuildException("'destFile' must be specified");
}
if (propertyEditorPaths != null) {
List editorSearchPath = new LinkedList(Arrays.asList(PropertyEditorManager.getEditorSearchPath()));
StringTokenizer paths = new StringTokenizer(propertyEditorPaths, " ,");
editorSearchPath.addAll(Collections.list(paths));
PropertyEditorManager.setEditorSearchPath((String[]) editorSearchPath.toArray(new String[editorSearchPath.size()]));
}
ClassLoader oldCL = Thread.currentThread().getContextClassLoader();
Thread.currentThread().setContextClassLoader(getClass().getClassLoader());
try {
String[] excludedClasses = null;
if (this.excludedClasses != null) {
excludedClasses = this.excludedClasses.split(" *, *");
}
MappingLoader mappingLoader = new QdoxMappingLoader(namespace, getFiles(srcDir), excludedClasses);
GeneratorPlugin[] plugins = new GeneratorPlugin[]{
new XmlMetadataGenerator(metaInfDir, destFile),
new DocumentationGenerator(destFile),
new XsdGenerator(destFile, strictXsdOrder)
};
// load the mappings
Set namespaces = mappingLoader.loadNamespaces();
if (namespaces.isEmpty()) {
System.out.println("Warning: no namespaces found!");
}
// generate the files
for (Iterator iterator = namespaces.iterator(); iterator.hasNext();) {
NamespaceMapping namespaceMapping = (NamespaceMapping) iterator.next();
for (int i = 0; i < plugins.length; i++) {
GeneratorPlugin plugin = plugins[i];
plugin.setLog(this);
plugin.generate(namespaceMapping);
}
}
log("...done.");
} catch (Exception e) {
throw new BuildException(e);
} finally {
Thread.currentThread().setContextClassLoader(oldCL);
}
}