|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.springframework.ui.velocity.VelocityEngineFactory
Factory that configures a VelocityEngine. Can be used standalone, but typically you will either use VelocityEngineFactoryBean for preparing a VelocityEngine as bean reference, or VelocityConfigurer for web views.
The optional "configLocation" property sets the location of the Velocity properties file, within the current application. Velocity properties can be overridden via "velocityProperties", or even completely specified locally, avoiding the need for an external properties file.
The "resourceLoaderPath" property can be used to specify the Velocity resource loader path via Spring's Resource abstraction, possibly relative to the Spring application context.
If "overrideLogging" is true (the default), the VelocityEngine will be configured to log via Commons Logging, i.e. using CommonsLoggingLogSystem as log system.
The simplest way to use this class is to specify just a "resourceLoaderPath": The VelocityEngine does not need any further configuration then.
setConfigLocation(org.springframework.core.io.Resource)
,
setVelocityProperties(java.util.Properties)
,
setResourceLoaderPath(java.lang.String)
,
setOverrideLogging(boolean)
,
createVelocityEngine()
,
CommonsLoggingLogSystem
,
VelocityEngineFactoryBean
,
VelocityConfigurer
Field Summary | |
protected org.apache.commons.logging.Log |
logger
|
Constructor Summary | |
VelocityEngineFactory()
|
Method Summary | |
org.apache.velocity.app.VelocityEngine |
createVelocityEngine()
Prepare the VelocityEngine instance and return it. |
protected org.apache.velocity.app.VelocityEngine |
newVelocityEngine()
Return a new VelocityEngine. |
protected void |
postProcessVelocityEngine(org.apache.velocity.app.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). |
void |
setConfigLocation(Resource configLocation)
Set the location of the Velocity config file. |
void |
setOverrideLogging(boolean overrideLogging)
If Velocity should log via Commons Logging, i.e. if Velocity's log system should be set to CommonsLoggingLogSystem. |
void |
setResourceLoader(ResourceLoader resourceLoader)
Set the Spring ResourceLoader to use for loading Velocity template files. |
void |
setResourceLoaderPath(java.lang.String resourceLoaderPath)
Set the Velocity resource loader path via a Spring resource location. |
void |
setVelocityProperties(java.util.Properties velocityProperties)
Set Velocity properties, like "file.resource.loader.path". |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
protected final org.apache.commons.logging.Log logger
Constructor Detail |
public VelocityEngineFactory()
Method Detail |
public void setConfigLocation(Resource configLocation)
setVelocityProperties(java.util.Properties)
,
setResourceLoaderPath(java.lang.String)
public void setVelocityProperties(java.util.Properties velocityProperties)
Can be used to override values in a Velocity config file, or to specify all necessary properties locally.
setConfigLocation(org.springframework.core.io.Resource)
public void setResourceLoaderPath(java.lang.String resourceLoaderPath)
When populated via a String, standard URLs like "file:" and "classpath:" pseudo URLs are supported, as understood by ResourceEditor. 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, the generic SpringResourceLoader will be used, without modification detection.
ResourceEditor
,
ResourceLoader.getResource(java.lang.String)
,
FileResourceLoader
,
SpringResourceLoader
public void setResourceLoader(ResourceLoader resourceLoader)
DefaultResourceLoader
public void setOverrideLogging(boolean overrideLogging)
CommonsLoggingLogSystem
public org.apache.velocity.app.VelocityEngine createVelocityEngine() throws java.io.IOException, org.apache.velocity.exception.VelocityException
java.io.IOException
- if the config file wasn't found
org.apache.velocity.exception.VelocityException
- on Velocity initialization failureprotected org.apache.velocity.app.VelocityEngine newVelocityEngine() throws java.io.IOException, org.apache.velocity.exception.VelocityException
java.io.IOException
- if a config file wasn't found
org.apache.velocity.exception.VelocityException
- on Velocity initialization failurecreateVelocityEngine()
protected void postProcessVelocityEngine(org.apache.velocity.app.VelocityEngine velocityEngine) throws java.io.IOException, org.apache.velocity.exception.VelocityException
velocityEngine
- the current VelocityEngine
java.io.IOException
- if a config file wasn't found
org.apache.velocity.exception.VelocityException
- on Velocity initialization failurecreateVelocityEngine()
,
VelocityEngine.init()
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |