xdoclet.util.velocity
Class VelocityConfigurer

java.lang.Object
  |
  +--xdoclet.util.velocity.VelocityConfigurer

public class VelocityConfigurer
extends Object

Utility class that supports dynamic configuration of Velocity's ResourceLoaders. This is necessary because templates will be read from jar files (plugin jars) and possibly also directories, and these are discovered at runtime by looking at the classpath.

Version:
$Revision: 1.5 $
Author:
Aslak Hellesøy

Constructor Summary
VelocityConfigurer(ClasspathManager classpathManager)
          Constructs a new VelocityConfigurer.
 
Method Summary
 void addLoader(Class resourceLoaderClass, Collection files)
          Adds a Velocity ResourceLoader.
 Properties getProperties()
          Gets the additional Velocity properties.
static Map getResourceLoaderMap()
          Returns a Map that should have java.lang.Class objects as keys and a 2-dimensional String[] as value.
 VelocityEngine initVelocity()
          Configures a VelocityEngine and returns it.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

VelocityConfigurer

public VelocityConfigurer(ClasspathManager classpathManager)
Constructs a new VelocityConfigurer.

Parameters:
classpathManager - holds the classpath
Method Detail

getResourceLoaderMap

public static Map getResourceLoaderMap()
Returns a Map that should have java.lang.Class objects as keys and a 2-dimensional String[] as value. The class should be of type org.apache.velocity.runtime.resource.loader.ResourceLoader, and the String array should be {name, pathPrefix}. Name is the logical name for the loader, and pathPerfix is the required prefix for path entries. The map is preconfigured with If you need to configure VelocityConfigurer to handle additional Resource loader types.

Returns:
a Map as described above.

addLoader

public void addLoader(Class resourceLoaderClass,
                      Collection files)
Adds a Velocity ResourceLoader.

Parameters:
resourceLoaderClass - resource loader class
files - Files to put on resource loader's path

initVelocity

public VelocityEngine initVelocity()
                            throws Exception
Configures a VelocityEngine and returns it.

If you need to configure the VelocityEngine beyond the standard configuration, call addLoader(java.lang.Class, java.util.Collection) to add additional loaders.

It's also possible to set additional Velocity properties in the Properties object returned by getProperties().

Exception

getProperties

public Properties getProperties()
Gets the additional Velocity properties.

Returns:
the additional Velocity properties


Copyright © 2000-2003 XDoclet Team. All Rights Reserved.