Class GroovyMarkupConfigurer
- All Implemented Interfaces:
- Aware,- InitializingBean,- ApplicationContextAware,- GroovyMarkupConfig
TemplateConfiguration and
 an implementation of Spring MVC's GroovyMarkupConfig for creating
 a MarkupTemplateEngine for use in a web application. The most basic
 way to configure this class is to set the "resourceLoaderPath". For example:
 
 // Add the following to an @Configuration class
 @Bean
 public GroovyMarkupConfig groovyMarkupConfigurer() {
     GroovyMarkupConfigurer configurer = new GroovyMarkupConfigurer();
     configurer.setResourceLoaderPath("classpath:/WEB-INF/groovymarkup/");
     return configurer;
 }
 
 By default this bean will create a MarkupTemplateEngine with:
 - a parent ClassLoader for loading Groovy templates with their references
- the default configuration in the base class TemplateConfiguration
- a TemplateResolverfor resolving template files
MarkupTemplateEngine instance directly to this bean
 in which case all other properties will not be effectively ignored.
 This bean must be included in the application context of any application
 using the Spring MVC GroovyMarkupView for rendering. It exists purely
 for the purpose of configuring Groovy's Markup templates. It is not meant to be
 referenced by application components directly. It implements GroovyMarkupConfig
 to be found by GroovyMarkupView without depending on a bean name. Each
 DispatcherServlet can define its own GroovyMarkupConfigurer if desired.
 
Note that resource caching is enabled by default in MarkupTemplateEngine.
 Use the TemplateConfiguration.setCacheTemplates(boolean) to configure that as necessary.
 
Spring's Groovy Markup template support requires Groovy 2.3.1 or higher.
- Since:
- 4.1
- Author:
- Brian Clozel, Rossen Stoyanchev
- See Also:
- 
Constructor SummaryConstructors
- 
Method SummaryModifier and TypeMethodDescriptionvoidInvoked by the containingBeanFactoryafter it has set all bean properties and satisfiedBeanFactoryAware,ApplicationContextAwareetc.protected ClassLoaderCreate a parent ClassLoader for Groovy to use as parent ClassLoader when loading and compiling templates.protected groovy.text.markup.MarkupTemplateEngineprotected ApplicationContextgroovy.text.markup.MarkupTemplateEngineReturn the GroovyMarkupTemplateEnginefor the current web application context.protected URLresolveTemplate(ClassLoader classLoader, String templatePath) Resolve a template from the given template path.voidsetApplicationContext(ApplicationContext applicationContext) Set the ApplicationContext that this object runs in.voidThis method should not be used, since the considered Locale for resolving templates is the Locale for the current HTTP request.voidsetResourceLoaderPath(String resourceLoaderPath) Set the Groovy Markup Template resource loader path(s) via a Spring resource location.voidsetTemplateEngine(groovy.text.markup.MarkupTemplateEngine templateEngine) Set a pre-configured MarkupTemplateEngine to use for the Groovy Markup Template web configuration.Methods inherited from class groovy.text.markup.TemplateConfigurationgetAutoIndentString, getBaseTemplateClass, getDeclarationEncoding, getLocale, getNewLineString, isAutoEscape, isAutoIndent, isAutoNewLine, isCacheTemplates, isExpandEmptyElements, isUseDoubleQuotes, setAutoEscape, setAutoIndent, setAutoIndentString, setAutoNewLine, setBaseTemplateClass, setCacheTemplates, setDeclarationEncoding, setExpandEmptyElements, setNewLineString, setUseDoubleQuotes
- 
Constructor Details- 
GroovyMarkupConfigurerpublic GroovyMarkupConfigurer()
 
- 
- 
Method Details- 
setResourceLoaderPathSet the Groovy Markup Template resource loader path(s) via a Spring resource location. Accepts multiple locations as a comma-separated list of paths. Standard URLs like "file:" and "classpath:" and pseudo URLs are supported as understood by Spring'sResourceLoader. Relative paths are allowed when running in an ApplicationContext.
- 
getResourceLoaderPath
- 
setTemplateEnginepublic void setTemplateEngine(groovy.text.markup.MarkupTemplateEngine templateEngine) Set a pre-configured MarkupTemplateEngine to use for the Groovy Markup Template web configuration.Note that this engine instance has to be manually configured, since all other bean properties of this configurer will be ignored. 
- 
getTemplateEnginepublic groovy.text.markup.MarkupTemplateEngine getTemplateEngine()Description copied from interface:GroovyMarkupConfigReturn the GroovyMarkupTemplateEnginefor the current web application context. May be unique to one servlet, or shared in the root context.- Specified by:
- getTemplateEnginein interface- GroovyMarkupConfig
- Returns:
- the Groovy MarkupTemplateEngine engine
 
- 
setApplicationContextDescription copied from interface:ApplicationContextAwareSet the ApplicationContext that this object runs in. Normally this call will be used to initialize the object.Invoked after population of normal bean properties but before an init callback such as InitializingBean.afterPropertiesSet()or a custom init-method. Invoked afterResourceLoaderAware.setResourceLoader(org.springframework.core.io.ResourceLoader),ApplicationEventPublisherAware.setApplicationEventPublisher(org.springframework.context.ApplicationEventPublisher)andMessageSourceAware, if applicable.- Specified by:
- setApplicationContextin interface- ApplicationContextAware
- Parameters:
- applicationContext- the ApplicationContext object to be used by this object
- See Also:
 
- 
getApplicationContext
- 
setLocaleThis method should not be used, since the considered Locale for resolving templates is the Locale for the current HTTP request.- Overrides:
- setLocalein class- groovy.text.markup.TemplateConfiguration
 
- 
afterPropertiesSetDescription copied from interface:InitializingBeanInvoked by the containingBeanFactoryafter it has set all bean properties and satisfiedBeanFactoryAware,ApplicationContextAwareetc.This method allows the bean instance to perform validation of its overall configuration and final initialization when all bean properties have been set. - Specified by:
- afterPropertiesSetin interface- InitializingBean
- Throws:
- Exception- in the event of misconfiguration (such as failure to set an essential property) or if initialization fails for any other reason
 
- 
createTemplateEngine- Throws:
- IOException
 
- 
createTemplateClassLoaderCreate a parent ClassLoader for Groovy to use as parent ClassLoader when loading and compiling templates.- Throws:
- IOException
 
- 
resolveTemplateResolve a template from the given template path.The default implementation uses the Locale associated with the current request, as obtained through LocaleContextHolder, to find the template file. Effectively the locale configured at the engine level is ignored.- Throws:
- IOException
- See Also:
 
 
-