template = new File(getSrcDir(), renderer.getTemplate());
} else {
template = new File(renderer.getTemplate());
}
ClassLoader classLoader = getClassLoader();
CompilationContext rendererBean = new RendererCompilationContext(
getLog(), classLoader,getConfig());
if (null != renderer.getClassname()) {
rendererBean.setBaseclass(renderer.getClassname());
}
if (null != renderer.getClassname()) {
rendererBean.setFullClassName(renderer.getClassname());
}
if (null != component) {
try {
rendererBean
.setComponentClass(component.getClassname());
} catch (CompilationException e) {
if (null != component.getSuperclass()) {
rendererBean.setComponentClass(component
.getSuperclass());
}
}
}
// unfinished check of non-static fields in renderer classes
//
// String baseclassName = rendererBean.getFullClassName();
// try {
// classLoader.loadClass(baseclassName);
// } catch (ClassNotFoundException e) {
// getLog().debug("Class not found: " + e.getLocalizedMessage());
//
// baseclassName = rendererBean.getFullBaseclass();
// classLoader.loadClass(baseclassName);
// }
//
// if (baseclassName != null) {
// Class<?> baseclass = classLoader.loadClass(baseclassName);
// Class<? extends Annotation> annotationClass = (Class<? extends Annotation>) classLoader.loadClass("org.richfaces.AllowedRendererField");
//
// do {
// Field[] fields = baseclass.getDeclaredFields();
// for (Field field : fields) {
// if ((field.getModifiers() & Modifier.STATIC) == 0 && field.getAnnotation(annotationClass) == null) {
// throw new RuntimeException("Non-static field: " + field + " in renderer class. ");
// }
// }
//
// baseclass = baseclass.getSuperclass();
// } while (baseclass != null);
// }
TemplateCompiler templateCompiler = new TemplateCompiler();
InputStream templateStream = new FileInputStream(template);
templateCompiler.processing(templateStream, rendererBean);
renderer.setClassname(rendererBean.getFullClassName());
String resultPath = rendererBean.getComponentFileName();
if (null == getPackage()) {
resultPath = resultPath.replace('.', '/');
} else {
resultPath = getPackage().replace('.', '/') + "/"
+ resultPath;