| java.lang.Object org.springframework.ui.velocity.VelocityEngineFactory
Field Summary | |
final protected Log | logger |
Method Summary | |
public VelocityEngine | createVelocityEngine() Prepare the VelocityEngine instance and return it. | protected ResourceLoader | getResourceLoader() Return the Spring ResourceLoader to use for loading Velocity template files. | protected void | initSpringResourceLoader(VelocityEngine velocityEngine, String resourceLoaderPath) Initialize a SpringResourceLoader for the given VelocityEngine. | protected void | initVelocityResourceLoader(VelocityEngine velocityEngine, String resourceLoaderPath) Initialize a Velocity resource loader for the given VelocityEngine:
either a standard Velocity FileResourceLoader or a SpringResourceLoader. | protected boolean | isPreferFileSystemAccess() Return whether to prefer file system access for template loading. | protected VelocityEngine | newVelocityEngine() Return a new VelocityEngine. | protected void | postProcessVelocityEngine(VelocityEngine velocityEngine) To be implemented by subclasses that want to to perform custom
post-processing of the VelocityEngine after this FactoryBean
performed its default configuration (but before VelocityEngine.init). | public void | setConfigLocation(Resource configLocation) Set the location of the Velocity config file. | public void | setOverrideLogging(boolean overrideLogging) Set whether Velocity should log via Commons Logging, i.e. | public void | setPreferFileSystemAccess(boolean preferFileSystemAccess) Set whether to prefer file system access for template loading.
File system access enables hot detection of template changes.
If this is enabled, VelocityEngineFactory will try to resolve the
specified "resourceLoaderPath" as file system resource (which will work
for expanded class path resources and ServletContext resources too).
Default is "true". | public void | setResourceLoader(ResourceLoader resourceLoader) Set the Spring ResourceLoader to use for loading Velocity template files.
The default is DefaultResourceLoader. | public void | setResourceLoaderPath(String resourceLoaderPath) Set the Velocity resource loader path via a Spring resource location.
Accepts multiple locations in Velocity's comma-separated path style.
When populated via a String, standard URLs like "file:" and "classpath:"
pseudo URLs are supported, as understood by ResourceLoader. | public void | setVelocityProperties(Properties velocityProperties) Set Velocity properties, like "file.resource.loader.path". | public void | setVelocityPropertiesMap(Map velocityPropertiesMap) Set Velocity properties as Map, to allow for non-String values
like "ds.resource.loader.instance". |
logger | final protected Log logger(Code) | | |
createVelocityEngine | public VelocityEngine createVelocityEngine() throws IOException, VelocityException(Code) | | Prepare the VelocityEngine instance and return it.
the VelocityEngine instance throws: IOException - if the config file wasn't found throws: VelocityException - on Velocity initialization failure |
getResourceLoader | protected ResourceLoader getResourceLoader()(Code) | | Return the Spring ResourceLoader to use for loading Velocity template files.
|
initSpringResourceLoader | protected void initSpringResourceLoader(VelocityEngine velocityEngine, String resourceLoaderPath)(Code) | | Initialize a SpringResourceLoader for the given VelocityEngine.
Called by initVelocityResourceLoader .
Parameters: velocityEngine - the VelocityEngine to configure Parameters: resourceLoaderPath - the path to load Velocity resources from See Also: SpringResourceLoader See Also: VelocityEngineFactory.initVelocityResourceLoader |
initVelocityResourceLoader | protected void initVelocityResourceLoader(VelocityEngine velocityEngine, String resourceLoaderPath)(Code) | | Initialize a Velocity resource loader for the given VelocityEngine:
either a standard Velocity FileResourceLoader or a SpringResourceLoader.
Called by createVelocityEngine() .
Parameters: velocityEngine - the VelocityEngine to configure Parameters: resourceLoaderPath - the path to load Velocity resources from See Also: org.apache.velocity.runtime.resource.loader.FileResourceLoader See Also: SpringResourceLoader See Also: VelocityEngineFactory.initSpringResourceLoader See Also: VelocityEngineFactory.createVelocityEngine() |
isPreferFileSystemAccess | protected boolean isPreferFileSystemAccess()(Code) | | Return whether to prefer file system access for template loading.
|
newVelocityEngine | protected VelocityEngine newVelocityEngine() throws IOException, VelocityException(Code) | | Return a new VelocityEngine. Subclasses can override this for
custom initialization, or for using a mock object for testing.
Called by createVelocityEngine() .
the VelocityEngine instance throws: IOException - if a config file wasn't found throws: VelocityException - on Velocity initialization failure See Also: VelocityEngineFactory.createVelocityEngine() |
postProcessVelocityEngine | protected void postProcessVelocityEngine(VelocityEngine velocityEngine) throws IOException, VelocityException(Code) | | To be implemented by subclasses that want to to perform custom
post-processing of the VelocityEngine after this FactoryBean
performed its default configuration (but before VelocityEngine.init).
Called by createVelocityEngine() .
Parameters: velocityEngine - the current VelocityEngine throws: IOException - if a config file wasn't found throws: VelocityException - on Velocity initialization failure See Also: VelocityEngineFactory.createVelocityEngine() See Also: org.apache.velocity.app.VelocityEngine.init |
setOverrideLogging | public void setOverrideLogging(boolean overrideLogging)(Code) | | Set whether Velocity should log via Commons Logging, i.e. whether Velocity's
log system should be set to CommonsLoggingLogSystem. Default value is true.
See Also: CommonsLoggingLogSystem |
setPreferFileSystemAccess | public void setPreferFileSystemAccess(boolean preferFileSystemAccess)(Code) | | Set whether to prefer file system access for template loading.
File system access enables hot detection of template changes.
If this is enabled, VelocityEngineFactory will try to resolve the
specified "resourceLoaderPath" as file system resource (which will work
for expanded class path resources and ServletContext resources too).
Default is "true". Turn this off to always load via SpringResourceLoader
(i.e. as stream, without hot detection of template changes), which might
be necessary if some of your templates reside in an expanded classes
directory while others reside in jar files.
See Also: VelocityEngineFactory.setResourceLoaderPath |
setResourceLoaderPath | public void setResourceLoaderPath(String resourceLoaderPath)(Code) | | Set the Velocity resource loader path via a Spring resource location.
Accepts multiple locations in Velocity's comma-separated path style.
When populated via a String, standard URLs like "file:" and "classpath:"
pseudo URLs are supported, as understood by ResourceLoader. Allows for
relative paths when running in an ApplicationContext.
Will define a path for the default Velocity resource loader with the name
"file". If the specified resource cannot be resolved to a java.io.File ,
a generic SpringResourceLoader will be used under the name "spring", without
modification detection.
Note that resource caching will be enabled in any case. With the file
resource loader, the last-modified timestamp will be checked on access to
detect changes. With SpringResourceLoader, the resource will be cached
forever (for example for class path resources).
To specify a modification check interval for files, use Velocity's
standard "file.resource.loader.modificationCheckInterval" property. By default,
the file timestamp is checked on every access (which is surprisingly fast).
Of course, this just applies when loading resources from the file system.
To enforce the use of SpringResourceLoader, i.e. to not resolve a path
as file system resource in any case, turn off the "preferFileSystemAccess"
flag. See the latter's javadoc for details.
See Also: VelocityEngineFactory.setResourceLoader See Also: VelocityEngineFactory.setVelocityProperties See Also: VelocityEngineFactory.setPreferFileSystemAccess See Also: SpringResourceLoader See Also: org.apache.velocity.runtime.resource.loader.FileResourceLoader |
|
|