public class GroovyPagesTemplateEngine
extends org.codehaus.groovy.grails.support.ResourceAwareTemplateEngine
implements org.springframework.context.ApplicationContextAware, org.springframework.web.context.ServletContextAware, org.springframework.beans.factory.InitializingBean, org.springframework.context.ApplicationListener<org.springframework.context.event.ContextRefreshedEvent>, org.springframework.beans.factory.BeanClassLoaderAware
Template t = new GroovyPagesTemplateEngine()
.createTemplate(context,request,response);
t.make()
.writeTo(out);
| Modifier and Type | Field and Description |
|---|---|
static java.lang.String |
BEAN_ID |
static java.lang.String |
CONFIG_PROPERTY_DISABLE_CACHING_RESOURCES |
static java.lang.String |
CONFIG_PROPERTY_GSP_ENABLE_RELOAD |
| Constructor and Description |
|---|
GroovyPagesTemplateEngine() |
GroovyPagesTemplateEngine(javax.servlet.ServletContext servletContext)
Deprecated.
here for compatibility
|
| Modifier and Type | Method and Description |
|---|---|
void |
afterPropertiesSet() |
protected GroovyPageMetaInfo |
buildPageMetaInfo(java.io.InputStream inputStream,
org.springframework.core.io.Resource res,
java.lang.String pageName)
Constructs a GroovyPageMetaInfo instance which holds the script class, modified date and so on
|
protected GroovyPageMetaInfo |
buildPageMetaInfo(org.springframework.core.io.Resource resource,
java.lang.String pageName) |
int[] |
calculateLineNumbersForPage(javax.servlet.ServletContext context,
java.lang.String url)
Retrieves a line number matrix for the specified page that can be used
to retrieve the actual line number within the GSP page if the line number within the
compiled GSP is known
|
void |
clearPageCache()
Clears the page cache.
|
groovy.text.Template |
createTemplate()
Creates a Template for the currently executing Request
|
groovy.text.Template |
createTemplate(java.io.File file)
Creates a Template for the given file
|
groovy.text.Template |
createTemplate(java.io.InputStream inputStream)
Create a Template for the given InputStream
|
groovy.text.Template |
createTemplate(org.springframework.core.io.Resource resource)
Creates a Template for the given Spring Resource instance
|
groovy.text.Template |
createTemplate(org.springframework.core.io.Resource resource,
boolean cacheable)
Creates a Template for the given Spring Resource instance
|
protected groovy.text.Template |
createTemplate(org.springframework.core.io.Resource resource,
java.lang.String pageName,
boolean cacheable) |
groovy.text.Template |
createTemplate(org.springframework.scripting.ScriptSource scriptSource) |
groovy.text.Template |
createTemplate(java.lang.String uri)
Creates a Template using the given URI.
|
groovy.text.Template |
createTemplate(java.lang.String txt,
java.lang.String pageName)
Creates a Template using the given text for the Template and the given name.
|
groovy.text.Template |
createTemplate(java.net.URL url)
Creates a Template for the given URL
|
groovy.text.Template |
createTemplateForUri(java.lang.String uri) |
groovy.text.Template |
createTemplateForUri(java.lang.String[] uris) |
protected java.lang.String |
establishPageName(org.springframework.core.io.Resource resource,
boolean cacheable) |
protected java.lang.String |
establishPageName(org.springframework.core.io.Resource res,
java.lang.String pageName)
Establishes the name to use for the given resource
|
GroovyPageScriptSource |
findScriptSource(java.lang.String uri) |
GroovyPageScriptSource |
findScriptSource(java.lang.String[] uris) |
protected java.lang.String |
getCurrentRequestUri(javax.servlet.http.HttpServletRequest request)
Return the page identifier.
|
java.util.Map<java.lang.String,java.lang.Class<?>> |
getDomainClassMap() |
GroovyPageLocator |
getGroovyPageLocator() |
org.springframework.core.io.Resource |
getResourceForUri(java.lang.String uri)
Attempts to retrieve a reference to a GSP as a Spring Resource instance for the given URI.
|
protected java.lang.String |
getUriWithinGrailsViews(java.lang.String relativeUri)
Returns the path to the view of the relative URI within the Grails views directory
|
boolean |
isCacheResources() |
boolean |
isReloadEnabled()
Return whether reload is enabled for the GroovyPagesTemplateEngine
|
int |
mapStackLineNumber(java.lang.String url,
int lineNumber) |
void |
onApplicationEvent(org.springframework.context.event.ContextRefreshedEvent event) |
void |
setApplicationContext(org.springframework.context.ApplicationContext applicationContext)
Sets the ResourceLoader from the ApplicationContext
|
void |
setBeanClassLoader(java.lang.ClassLoader beanClassLoader) |
void |
setCacheResources(boolean cacheResources) |
void |
setClassLoader(java.lang.ClassLoader classLoader)
Sets the ClassLoader that the TemplateEngine should use to
|
void |
setGroovyPageLocator(GroovyPageLocator groovyPageLocator) |
void |
setJspTagLibraryResolver(TagLibraryResolver jspTagLibraryResolver) |
void |
setReloadEnabled(boolean b)
Sets whether reloading is enabled
|
void |
setResourceLoader(org.springframework.core.io.ResourceLoader resourceLoader) |
void |
setServletContext(javax.servlet.ServletContext servletContext) |
void |
setTagLibraryLookup(TagLibraryLookup tagLibraryLookup) |
public static final java.lang.String CONFIG_PROPERTY_DISABLE_CACHING_RESOURCES
public static final java.lang.String CONFIG_PROPERTY_GSP_ENABLE_RELOAD
public static final java.lang.String BEAN_ID
public GroovyPagesTemplateEngine()
@Deprecated public GroovyPagesTemplateEngine(javax.servlet.ServletContext servletContext)
servletContext - The servlet contextpublic void setGroovyPageLocator(GroovyPageLocator groovyPageLocator)
public GroovyPageLocator getGroovyPageLocator()
public void setResourceLoader(org.springframework.core.io.ResourceLoader resourceLoader)
public void afterPropertiesSet()
afterPropertiesSet in interface org.springframework.beans.factory.InitializingBeanpublic void setTagLibraryLookup(TagLibraryLookup tagLibraryLookup)
public void setJspTagLibraryResolver(TagLibraryResolver jspTagLibraryResolver)
public void setClassLoader(java.lang.ClassLoader classLoader)
classLoader - The ClassLoader to use when compilation of Groovy Pages occurspublic int[] calculateLineNumbersForPage(javax.servlet.ServletContext context,
java.lang.String url)
context - The ServletContext instanceurl - The URL of the pagepublic int mapStackLineNumber(java.lang.String url,
int lineNumber)
mapStackLineNumber in class org.codehaus.groovy.grails.support.ResourceAwareTemplateEnginepublic groovy.text.Template createTemplate(org.springframework.core.io.Resource resource)
createTemplate in class org.codehaus.groovy.grails.support.ResourceAwareTemplateEngineresource - The Resource to create the Template forpublic groovy.text.Template createTemplate(org.springframework.core.io.Resource resource,
boolean cacheable)
createTemplate in class org.codehaus.groovy.grails.support.ResourceAwareTemplateEngineresource - The Resource to create the Template forcacheable - The resource can be cached or notprotected groovy.text.Template createTemplate(org.springframework.core.io.Resource resource,
java.lang.String pageName,
boolean cacheable)
throws java.io.IOException
java.io.IOExceptionprotected java.lang.String establishPageName(org.springframework.core.io.Resource resource,
boolean cacheable)
public groovy.text.Template createTemplate(java.lang.String uri)
createTemplate in class org.codehaus.groovy.grails.support.ResourceAwareTemplateEngineuri - The URI of the page to create the template fororg.codehaus.groovy.control.CompilationFailedExceptionpublic groovy.text.Template createTemplateForUri(java.lang.String uri)
public groovy.text.Template createTemplateForUri(java.lang.String[] uris)
createTemplateForUri in class org.codehaus.groovy.grails.support.ResourceAwareTemplateEnginepublic GroovyPageScriptSource findScriptSource(java.lang.String uri)
public GroovyPageScriptSource findScriptSource(java.lang.String[] uris)
public groovy.text.Template createTemplate(org.springframework.scripting.ScriptSource scriptSource)
public groovy.text.Template createTemplate(java.lang.String txt,
java.lang.String pageName)
throws java.io.IOException
txt - The URI of the page to create the template forpageName - The name of the page being parsedorg.codehaus.groovy.control.CompilationFailedExceptionjava.io.IOException - Thrown if an IO exception occurs creating the Templatepublic groovy.text.Template createTemplate()
java.io.IOException - Thrown when an exception occurs Reading the Templatejava.lang.ClassNotFoundException - Thrown when the class of the template was not foundpublic groovy.text.Template createTemplate(java.io.File file)
throws org.codehaus.groovy.control.CompilationFailedException,
java.lang.ClassNotFoundException,
java.io.IOException
createTemplate in class org.codehaus.groovy.grails.support.ResourceAwareTemplateEnginefile - The File to use to construct the template withorg.codehaus.groovy.control.CompilationFailedException - When an error occured compiling the Templatejava.lang.ClassNotFoundException - When a Class cannot be found within the given Templatejava.io.IOException - When a I/O Exception occurs reading the Templatepublic groovy.text.Template createTemplate(java.net.URL url)
throws org.codehaus.groovy.control.CompilationFailedException,
java.lang.ClassNotFoundException,
java.io.IOException
createTemplate in class org.codehaus.groovy.grails.support.ResourceAwareTemplateEngineurl - The URL to use to construct the template withorg.codehaus.groovy.control.CompilationFailedException - When an error occured compiling the Templatejava.lang.ClassNotFoundException - When a Class cannot be found within the given Templatejava.io.IOException - When a I/O Exception occurs reading the Templatepublic groovy.text.Template createTemplate(java.io.InputStream inputStream)
createTemplate in class org.codehaus.groovy.grails.support.ResourceAwareTemplateEngineinputStream - The InputStream to create the Template forprotected GroovyPageMetaInfo buildPageMetaInfo(org.springframework.core.io.Resource resource, java.lang.String pageName) throws java.io.IOException
java.io.IOExceptionpublic boolean isReloadEnabled()
public void setReloadEnabled(boolean b)
b - True if it is enabledpublic org.springframework.core.io.Resource getResourceForUri(java.lang.String uri)
uri - The URI to checkprotected GroovyPageMetaInfo buildPageMetaInfo(java.io.InputStream inputStream, org.springframework.core.io.Resource res, java.lang.String pageName)
inputStream - The InputStream to construct the GroovyPageMetaInfo instance fromres - The Spring Resource to construct the MetaInfo frompageName - The name of the page (can be null, in which case method responsible for calculating appropriate alternative)protected java.lang.String establishPageName(org.springframework.core.io.Resource res,
java.lang.String pageName)
res - The Resource to calculate the name forpageName - The name of the page, can be null, in which case method responsible for calculationpublic void setApplicationContext(org.springframework.context.ApplicationContext applicationContext)
throws org.springframework.beans.BeansException
setApplicationContext in interface org.springframework.context.ApplicationContextAwareapplicationContext - The ApplicationContextorg.springframework.beans.BeansException - Thrown when an error occurs with the ApplicationContextprotected java.lang.String getCurrentRequestUri(javax.servlet.http.HttpServletRequest request)
request - The HttpServletRequest instanceprotected java.lang.String getUriWithinGrailsViews(java.lang.String relativeUri)
relativeUri - The relative URIpublic void clearPageCache()
public boolean isCacheResources()
public void setCacheResources(boolean cacheResources)
public java.util.Map<java.lang.String,java.lang.Class<?>> getDomainClassMap()
public void setServletContext(javax.servlet.ServletContext servletContext)
setServletContext in interface org.springframework.web.context.ServletContextAwarepublic void onApplicationEvent(org.springframework.context.event.ContextRefreshedEvent event)
onApplicationEvent in interface org.springframework.context.ApplicationListener<org.springframework.context.event.ContextRefreshedEvent>public void setBeanClassLoader(java.lang.ClassLoader beanClassLoader)
setBeanClassLoader in interface org.springframework.beans.factory.BeanClassLoaderAware