public class GroovyPagesTemplateEngine extends ResourceAwareTemplateEngine implements ApplicationContextAware, BeanClassLoaderAware, InitializingBean, ResourceLoaderAware
Based on (but not extending) the existing TemplateEngine implementations
within Groovy. It allows GSP pages to be re-used in different context using code like the below:
Template t = new GroovyPagesTemplateEngine()
.createTemplate(context,request,response);
t.make()
.writeTo(out);
Modifiers | Name | 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 |
Fields inherited from class | Fields |
---|---|
class ResourceAwareTemplateEngine |
BEAN_ID |
Constructor and description |
---|
GroovyPagesTemplateEngine
() |
Type Params | Return Type | Name and description |
---|---|---|
|
public void |
afterPropertiesSet() |
|
protected GroovyPageMetaInfo |
buildPageMetaInfo(Resource resource, java.lang.String pageName) |
|
protected GroovyPageMetaInfo |
buildPageMetaInfo(java.io.InputStream inputStream, Resource res, java.lang.String pageName) Constructs a GroovyPageMetaInfo instance which holds the script class, modified date and so on |
|
public int[] |
calculateLineNumbersForPage(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 |
|
public void |
clearPageCache() Clears the page cache. |
|
public groovy.text.Template |
createTemplate(Resource resource) Creates a Template for the given Spring Resource instance |
|
public groovy.text.Template |
createTemplate(Resource resource, boolean cacheable) Creates a Template for the given Spring Resource instance |
|
protected groovy.text.Template |
createTemplate(Resource resource, java.lang.String pageName, boolean cacheable) |
|
public groovy.text.Template |
createTemplate(java.lang.String uri) Creates a Template using the given URI. |
|
public groovy.text.Template |
createTemplate(ScriptSource scriptSource) |
|
public 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. |
|
public groovy.text.Template |
createTemplate(java.io.File file) Creates a Template for the given file |
|
public groovy.text.Template |
createTemplate(java.net.URL url) Creates a Template for the given URL |
|
public groovy.text.Template |
createTemplate(java.io.InputStream inputStream) Create a Template for the given InputStream |
|
public groovy.text.Template |
createTemplateForUri(java.lang.String uri) |
|
public groovy.text.Template |
createTemplateForUri(java.lang.String[] uris) |
|
protected java.lang.String |
establishPageName(Resource resource, boolean cacheable) |
|
protected java.lang.String |
establishPageName(Resource res, java.lang.String pageName) Establishes the name to use for the given resource |
|
public GroovyPageScriptSource |
findScriptSource(java.lang.String uri) |
|
public GroovyPageScriptSource |
findScriptSource(java.lang.String[] uris) |
|
public java.util.Map<java.lang.String, java.lang.Class<?>> |
getDomainClassMap() |
|
public GroovyPageLocator |
getGroovyPageLocator() |
|
public java.util.List<GroovyPageSourceDecorator> |
getGroovyPageSourceDecorators() |
|
public java.lang.String |
getGspEncoding() |
|
public 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 |
|
public void |
initialize(GroovyPageMetaInfo metaInfo) |
|
public boolean |
isCacheResources() |
|
public boolean |
isReloadEnabled() Return whether reload is enabled for the GroovyPagesTemplateEngine |
|
public int |
mapStackLineNumber(java.lang.String url, int lineNumber) |
|
public Resource |
run() |
|
public void |
setApplicationContext(ApplicationContext applicationContext) Sets the ResourceLoader from the ApplicationContext |
|
public void |
setBeanClassLoader(java.lang.ClassLoader beanClassLoader) |
|
public void |
setCacheResources(boolean cacheResources) |
|
public void |
setClassLoader(java.lang.ClassLoader classLoader) Sets the ClassLoader that the TemplateEngine should use to |
|
public void |
setGroovyPageLocator(GroovyPageLocator groovyPageLocator) |
|
public void |
setGroovyPageSourceDecorators(java.util.List<GroovyPageSourceDecorator> groovyPageSourceDecorators) |
|
public void |
setJspTagLibraryResolver(TagLibraryResolver jspTagLibraryResolver) |
|
public void |
setReloadEnabled(boolean b) Sets whether reloading is enabled |
|
public void |
setResourceLoader(ResourceLoader resourceLoader) |
|
public void |
setTagLibraryLookup(TagLibraryLookup tagLibraryLookup) |
Methods inherited from class | Name |
---|---|
class ResourceAwareTemplateEngine |
createTemplate, createTemplate, createTemplate, createTemplate, createTemplate, createTemplate, createTemplate, createTemplateForUri, mapStackLineNumber |
Constructs a GroovyPageMetaInfo instance which holds the script class, modified date and so on
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)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
url
- The URL of the pageClears the page cache. Views will be re-compiled.
Creates a Template for the given Spring Resource instance
resource
- The Resource to create the Template forCreates a Template for the given Spring Resource instance
resource
- The Resource to create the Template forcacheable
- The resource can be cached or notCreates a Template using the given URI.
uri
- The URI of the page to create the template forCreates a Template using the given text for the Template and the given name. The name of the template is required
txt
- The URI of the page to create the template forpageName
- The name of the page being parsedCreates a Template for the given file
file
- The File to use to construct the template withCreates a Template for the given URL
url
- The URL to use to construct the template withCreate a Template for the given InputStream
inputStream
- The InputStream to create the Template forEstablishes the name to use for the given resource
res
- The Resource to calculate the name forpageName
- The name of the page, can be null, in which case method responsible for calculationAttempts to retrieve a reference to a GSP as a Spring Resource instance for the given URI.
uri
- The URI to checkReturns the path to the view of the relative URI within the Grails views directory
relativeUri
- The relative URIReturn whether reload is enabled for the GroovyPagesTemplateEngine
Sets the ResourceLoader from the ApplicationContext
applicationContext
- The ApplicationContextSets the ClassLoader that the TemplateEngine should use to
classLoader
- The ClassLoader to use when compilation of Groovy Pages occursSets whether reloading is enabled
b
- True if it is enabled