|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.springframework.ui.freemarker.FreeMarkerConfigurationFactory
Factory that configures a FreeMarker Configuration. Can be used standalone, but typically you will either use FreeMarkerConfigurationFactoryBean for preparing a Configuration as bean reference, or FreeMarkerConfigurer for web views.
The optional "configLocation" property sets the location of a FreeMarker properties file, within the current application. FreeMarker properties can be overridden via "freemarkerSettings". All of these properties will be set by calling FreeMarker's Configuration.setSetting() method and are subject to constraints set by FreeMarker
The "freemarkerVariables" property can be used to specify a Map of shared variables that will be applied to the Configuration via the setSharedVariable() method. Like setSettings(), these entries are subject to FreeMarker constraints and may throw a FreemarkerInitializationException.
Note: Spring's FreeMarker support requires FreeMarker 2.3 or higher.
setConfigLocation(org.springframework.core.io.Resource)
,
setFreemarkerSettings(java.util.Properties)
,
setFreemarkerVariables(java.util.Map)
,
setTemplateLoaderPath(java.lang.String)
,
createConfiguration()
Field Summary | |
protected org.apache.commons.logging.Log |
logger
|
Constructor Summary | |
FreeMarkerConfigurationFactory()
|
Method Summary | |
freemarker.template.Configuration |
createConfiguration()
Prepare the FreeMarker Configuration and return it. |
protected freemarker.template.Configuration |
newConfiguration()
Return a new Configuration object. |
protected void |
postProcessConfiguration(freemarker.template.Configuration config)
To be implemented by subclasses that want to to perform custom post-processing of the Configuration object after this FactoryBean performed its default initialization. |
void |
setConfigLocation(Resource resource)
Set the location of the FreeMarker config file. |
void |
setFreemarkerSettings(java.util.Properties settings)
Set properties that contain well-known FreeMarker keys which will be passed to FreeMarker's Configuration.setSettings method. |
void |
setFreemarkerVariables(java.util.Map variables)
Set a Map that contains well-known FreeMarker objects which will be passed to FreeMarker's Configuration.setAllSharedVariables method. |
void |
setResourceLoader(ResourceLoader resourceLoader)
Set the Spring ResourceLoader to use for loading FreeMarker template files. |
void |
setTemplateLoaderPath(java.lang.String templateLoaderPath)
Set the Freemarker template loader path via a Spring resource location. |
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 FreeMarkerConfigurationFactory()
Method Detail |
public void setConfigLocation(Resource resource)
setFreemarkerSettings(java.util.Properties)
,
setTemplateLoaderPath(java.lang.String)
public void setFreemarkerSettings(java.util.Properties settings)
Configurable.setSettings(java.util.Properties)
public void setFreemarkerVariables(java.util.Map variables)
Configuration.setAllSharedVariables(freemarker.template.TemplateHashModelEx)
public void setTemplateLoaderPath(java.lang.String templateLoaderPath)
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 FreeMarker template loader. If the specified resource cannot be resolved to a java.io.File, the generic SpringTemplateLoader will be used, without modification detection.
ResourceEditor
,
ResourceLoader.getResource(java.lang.String)
,
Configuration.setDirectoryForTemplateLoading(java.io.File)
,
SpringTemplateLoader
public void setResourceLoader(ResourceLoader resourceLoader)
DefaultResourceLoader
public freemarker.template.Configuration createConfiguration() throws java.io.IOException, freemarker.template.TemplateException
java.io.IOException
- if the config file wasn't found
freemarker.template.TemplateException
- on FreeMarker initialization failureprotected freemarker.template.Configuration newConfiguration() throws java.io.IOException, freemarker.template.TemplateException
java.io.IOException
- if a config file wasn't found
freemarker.template.TemplateException
- on FreeMarker initialization failurecreateConfiguration()
protected void postProcessConfiguration(freemarker.template.Configuration config) throws java.io.IOException, freemarker.template.TemplateException
config
- the current Configuration object
java.io.IOException
- if a config file wasn't found
freemarker.template.TemplateException
- on FreeMarker initialization failurecreateConfiguration()
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |