ConfigurationMetadata model = null;
try {
model = builder.build(src);
} catch (IOException ex) {
throw new ConfigurationException(new Message("FAILED_TO_GENERATE_BEAN_EXC", LOG), ex);
}
String className = SpringUtils.getBeanClassName(model.getNamespaceURI());
StringBuffer classFileName = new StringBuffer(className);
for (int i = 0; i < classFileName.length(); i++) {
if ('.' == classFileName.charAt(i)) {
classFileName.setCharAt(i, File.separatorChar);
}
}
classFileName.append(".java");
File classFile = new File(outputDir, classFileName.toString());
File dir = classFile.getParentFile();
if (!dir.exists()) {
dir.mkdirs();
}
LOG.info("Generating class: " + className + "\n"
+ " file: " + classFile.getPath());
PrintWriter pw = null;
try {
pw = new PrintWriter(new FileOutputStream(classFile));
// pw = new PrintWriter(System.out);
writeClass(pw, model, className);
} catch (IOException ex) {
throw new ConfigurationException(new Message("FAILED_TO_GENERATE_BEAN_EXC", LOG), ex);
} finally {
pw.close();
}
}