* template using the VelocityEngine instance.
*
* @since 1.2
*/
private void initializeClassTemplate(String template) throws CayenneRuntimeException {
VelocityEngine velocityEngine = new VelocityEngine();
try {
// use ClasspathResourceLoader for velocity templates lookup
// if Cayenne URL is not null, load resource from this URL
Properties props = new Properties();
// null logger that will prevent velocity.log from being generated
props.put(RuntimeConstants.RUNTIME_LOG_LOGSYSTEM_CLASS, NullLogSystem.class
.getName());
props.put("resource.loader", "cayenne");
props.put("cayenne.resource.loader.class", ClassGeneratorResourceLoader.class
.getName());
velocityEngine.init(props);
}
catch (Exception ex) {
throw new CayenneRuntimeException("Can't initialize Velocity", ex);
}
try {
classTemplate = velocityEngine.getTemplate(template);
}
catch (Exception ex) {
throw new CayenneRuntimeException("Can't create template: " + template, ex);
}
}