private void initVelocity() throws InitializationException
{
/*
* Get the configuration for this service.
*/
Configuration configuration = getConfiguration();
/*
* Now we have to perform a couple of path translations
* for our log file and template paths.
*/
String logFile = TurbineServlet.getRealPath
(configuration.getString(Velocity.RUNTIME_LOG, null));
if (StringUtils.isValid(logFile))
{
configuration.setProperty(Velocity.RUNTIME_LOG, logFile);
}
else
{
String msg = VelocityService.SERVICE_NAME + " runtime log file " +
"is misconfigured: '" + logFile + "' is not a valid log file";
if (TurbineServlet.getServletConfig() instanceof TurbineConfig)
{
msg += ": TurbineConfig users must use a path relative to " +
"web application root";
}
throw new Error(msg);
}
/*
* Get all the template paths where the velocity
* runtime should search for templates.
*/
Vector templatePaths = configuration.getVector(
Velocity.FILE_RESOURCE_LOADER_PATH);
/*
* Clear the configuration for the template paths, we
* want to translate them all to the webapp space.
*/
Velocity.clearProperty(Velocity.FILE_RESOURCE_LOADER_PATH);
configuration.clearProperty(Velocity.FILE_RESOURCE_LOADER_PATH);
int pathsToProcess = templatePaths.size();
// If I use this line I get an endless loop?
// What the hell is that? Is that a bug with
// Vector used in conjunction with a for loop.
//for (int i = 0; i < templatePaths.size(); i++)
for (int i = 0; i < pathsToProcess; i++)
{
configuration.addProperty(Velocity.FILE_RESOURCE_LOADER_PATH,
TurbineServlet.getRealPath((String) templatePaths.get(i)));
}
try
{