|
The Spring Framework | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.springframework.ui.velocity.VelocityEngineFactory org.springframework.web.servlet.view.velocity.VelocityConfigurer
public class VelocityConfigurer
JavaBean to configure Velocity for web usage, via the "configLocation" and/or "velocityProperties" and/or "resourceLoaderPath" bean properties. The simplest way to use this class is to specify just a "resourceLoaderPath"; you do not need any further configuration then.
<bean id="velocityConfig" class="org.springframework.web.servlet.view.velocity.VelocityConfigurer"> <property name="resourceLoaderPath"><value>/WEB-INF/velocity/</value></property> </bean>This bean must be included in the application context of any application using Spring's VelocityView for web MVC. It exists purely to configure Velocity; it is not meant to be referenced by application components but just internally by VelocityView. Implements VelocityConfig to be found by VelocityView without depending on the bean name of the configurer. Each DispatcherServlet can define its own VelocityConfigurer if desired.
Note that you can also refer to a preconfigured VelocityEngine instance, for example one set up by VelocityEngineFactoryBean, via the "velocityEngine" property. This allows to share a VelocityEngine for web and email usage, for example.
This configurer registers the "spring.vm" Velocimacro library for web views (contained in this package and thus in spring.jar), which makes all macros defined in it implicitly available:
#springBind("person.age") age is ${status.value}
VelocityEngineFactory.setConfigLocation(org.springframework.core.io.Resource)
,
VelocityEngineFactory.setVelocityProperties(java.util.Properties)
,
VelocityEngineFactory.setResourceLoaderPath(java.lang.String)
,
setVelocityEngine(org.apache.velocity.app.VelocityEngine)
,
VelocityEngineFactoryBean
,
VelocityView
Field Summary |
---|
Fields inherited from class org.springframework.ui.velocity.VelocityEngineFactory |
---|
logger |
Constructor Summary | |
---|---|
VelocityConfigurer()
|
Method Summary | |
---|---|
void |
afterPropertiesSet()
Initialize VelocityEngineFactory's VelocityEngine if not overridden by a preconfigured VelocityEngine. |
org.apache.velocity.app.VelocityEngine |
getVelocityEngine()
Return the VelocityEngine for the current web application context. |
protected void |
postProcessVelocityEngine(org.apache.velocity.app.VelocityEngine velocityEngine)
Provides a ClasspathResourceLoader in addition to any default or user-defined loader in order to load the spring Velocity macros from the class path. |
void |
setVelocityEngine(org.apache.velocity.app.VelocityEngine velocityEngine)
Set a preconfigured VelocityEngine to use for the Velocity web config, e.g. |
Methods inherited from class org.springframework.ui.velocity.VelocityEngineFactory |
---|
createVelocityEngine, getResourceLoader, initSpringResourceLoader, initVelocityResourceLoader, isPreferFileSystemAccess, newVelocityEngine, setConfigLocation, setOverrideLogging, setPreferFileSystemAccess, setResourceLoader, setResourceLoaderPath, setVelocityProperties, setVelocityPropertiesMap |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Methods inherited from interface org.springframework.context.ResourceLoaderAware |
---|
setResourceLoader |
Constructor Detail |
---|
public VelocityConfigurer()
Method Detail |
---|
public void setVelocityEngine(org.apache.velocity.app.VelocityEngine velocityEngine)
VelocityEngineFactoryBean
public void afterPropertiesSet() throws IOException, org.apache.velocity.exception.VelocityException
afterPropertiesSet
in interface InitializingBean
IOException
org.apache.velocity.exception.VelocityException
VelocityEngineFactory.createVelocityEngine()
,
setVelocityEngine(org.apache.velocity.app.VelocityEngine)
protected void postProcessVelocityEngine(org.apache.velocity.app.VelocityEngine velocityEngine)
postProcessVelocityEngine
in class VelocityEngineFactory
velocityEngine
- the current VelocityEngineClasspathResourceLoader
public org.apache.velocity.app.VelocityEngine getVelocityEngine()
VelocityConfig
getVelocityEngine
in interface VelocityConfig
|
The Spring Framework | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |