VelocityContext context = new VelocityContext();
Template template = getTemplate();
// Put common properties
for (Iterator iter = config.getComponents().iterator(); iter.hasNext();) {
ComponentBean component = (ComponentBean) iter.next();
TagHandlerBean tagHandler = component.getTaghandler();
if ( null != tagHandler && tagHandler.isGenerate() && null !=tagHandler.getClassname()) {
context.put("component", component);
if (null != component.getRenderer()) {
context.put("renderer", component.getRenderer());
} else {
context.put("renderer",Boolean.FALSE);
}
context.put("tag", tagHandler);
context.put("package", tagHandler.getPackageName());
Set<String> importClasses = new HashSet<String>();
for (Iterator it = component.getProperties().iterator(); it
.hasNext();) {
PropertyBean property = (PropertyBean) it.next();
// For non-primitive types, add import declaration.
if (!property.isSimpleType() && !property.isHidden()) {
importClasses.add(property.getClassname());
}
}
importClasses.add(tagHandler.getSuperclass());
context.put("imports", importClasses);
String resultPath = tagHandler.getClassname().replace('.', '/')
+ ".java";
File javaFile = new File(getDestDir(), resultPath);
File javaDir = javaFile.getParentFile();
if (!javaDir.exists()) {
javaDir.mkdirs();