|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--org.apache.turbine.services.BaseInitable | +--org.apache.turbine.services.BaseService | +--org.apache.turbine.services.TurbineBaseService | +--org.apache.turbine.services.template.TurbineTemplateService
This service provides a method for mapping templates to their appropriate Screens or Navigations. It also allows templates to define a layout/navigations/screen modularization within the template structure. It also performs caching if turned on in the properties file. Since everything is keyed off the template variable, if data.getParameters().getString("template") returns /about_us/directions/driving.vm, the search for the Screen class is as follows (in order): 1. about_us.directions.Driving 2. about_us.directions.Default 3. about_us.Default 4. Default 5. VelocityScreen If the template variable does not exist, then VelocityScreen will be executed and templates/screens/index.vm will be executed. If index.vm is not found or if the template is invalid or Velocity execution throws an exception of any reason, then templates/screens/error.vm will be executed. For the Layouts and Navigations, the following paths will be searched in the layouts and navigations template subdirectories (in order): 1./about_us/directions/driving.vm 2./about_us/directions/default.vm 3./about_us/default.vm 4./default.vm
Field Summary | |
private java.lang.String |
defaultExtension
Default extension for templates. |
private java.lang.String[] |
defaultNameProperties
The properties for default template object names. |
private java.lang.String |
defaultTemplate
Default template with the default extension. |
protected static int |
LAYOUT_KEY
|
protected static int |
LAYOUT_TEMPLATE_KEY
|
protected static int |
NAVIGATION_KEY
|
protected static java.lang.String |
NO_FILE_EXT
The default file extension used as a registry key when a template's file extension cannot be determined. |
protected static int |
PAGE_KEY
The keys of template objects provided by the service. |
protected static int |
SCREEN_KEY
|
protected static int |
SCREEN_TEMPLATE_KEY
|
private java.util.HashMap |
templateEngineRegistry
The mappings of template file extensions to TemplateEngineService
implementations. |
private java.util.Hashtable[] |
templateNameCache
The hashtables used to cache template object names. |
private boolean |
useCache
Flag set if cache is to be used. |
Fields inherited from class org.apache.turbine.services.BaseService |
configuration, name, properties, serviceBroker |
Fields inherited from class org.apache.turbine.services.BaseInitable |
initableBroker, isInitialized |
Fields inherited from interface org.apache.turbine.services.template.TemplateService |
SERVICE_NAME |
Constructor Summary | |
TurbineTemplateService()
|
Method Summary | |
protected java.lang.String |
getCachedName(java.lang.String template,
int key)
Get the cached template object name. |
java.lang.String |
getDefaultExtension()
Get the default template name extension specified in the template service properties. |
java.lang.String |
getDefaultLayout()
Get the default layout module name of the template engine service corresponding to the default template name extension. |
java.lang.String |
getDefaultLayoutName(RunData data)
Find the default layout module name for the given request. |
java.lang.String |
getDefaultLayoutName(java.lang.String template)
Get the default layout module name of the template engine service corresponding to the template name extension of the named template. |
java.lang.String |
getDefaultLayoutTemplate()
Get the default layout template name of the template engine service corresponding to the default template name extension. |
java.lang.String |
getDefaultLayoutTemplateName(java.lang.String template)
Get the default layout template name of the template engine service corresponding to the template name extension of the named template. |
protected java.lang.String |
getDefaultModuleName(java.lang.String template,
int key)
Get the default module name of the template engine service corresponding to the template name extension of the named template. |
java.lang.String |
getDefaultNavigation()
Get the default navigation module name of the template engine service corresponding to the default template name extension. |
java.lang.String |
getDefaultNavigationName(java.lang.String template)
Get the default navigation module name of the template engine service corresponding to the template name extension of the named template. |
java.lang.String |
getDefaultPage()
Get the default page module name of the template engine service corresponding to the default template name extension. |
java.lang.String |
getDefaultPageName(RunData data)
Find the default page module name for the given request. |
java.lang.String |
getDefaultPageName(java.lang.String template)
Get the default page module name of the template engine service corresponding to the template name extension of the named template. |
java.lang.String |
getDefaultScreen()
Get the default screen module name of the template engine service corresponding to the default template name extension. |
java.lang.String |
getDefaultScreenName(java.lang.String template)
Get the default screen module name of the template engine service corresponding to the template name extension of the named template. |
java.lang.String |
getLayoutName(java.lang.String template)
Locate and return the name of the layout module to be used with the named layout template. |
java.lang.String |
getLayoutTemplateName(java.lang.String template)
Locate and return the name of the layout template corresponding to the given screen template name parameter. |
java.lang.String |
getNavigationName(java.lang.String template)
Locate and return the name of the navigation module to be used with the named navigation template. |
protected java.lang.String |
getParsedLayoutTemplateName(java.lang.String template)
Get the parsed layout template name for the specified template. |
protected java.lang.String |
getParsedModuleName(java.lang.String template,
int key)
Get the parsed module name for the specified template. |
protected java.lang.String |
getParsedScreenTemplateName(java.lang.String template)
Get the parsed screen template name for the specified template. |
java.lang.String |
getScreenName(java.lang.String template)
Locate and return the name of the screen module to be used with the named screen template. |
java.lang.String |
getScreenTemplateName(java.lang.String template)
Locate and return the name of the screen template corresponding to the given template name parameter. |
protected TemplateEngineService |
getTemplateEngineService(java.lang.String template)
The TemplateEngineService
associated with the specified template's file extension. |
void |
init()
Called the first time the Service is used. |
private void |
initTemplate()
Initialize the template service. |
private int |
parseTemplatePath(java.lang.String template,
java.lang.StringBuffer buffer)
Parse the template name collected from URL parameters or template context to a path name. |
void |
registerTemplateEngineService(TemplateEngineService service)
Registers the provided template engine for use by the TemplateService . |
boolean |
templateExists(java.lang.String template,
java.lang.String[] templatePaths)
Delegates to the appropriate TemplateEngineService to
check the existance of the specified template. |
java.lang.String[] |
translateTemplatePaths(java.lang.String[] templatePaths)
Translates the supplied template paths into their Turbine-canonical equivalent (probably absolute paths). |
Methods inherited from class org.apache.turbine.services.TurbineBaseService |
init, init, init, shutdown |
Methods inherited from class org.apache.turbine.services.BaseService |
getConfiguration, getName, getProperties, getServiceBroker, setName, setServiceBroker |
Methods inherited from class org.apache.turbine.services.BaseInitable |
getInit, getInitableBroker, setInit, setInitableBroker |
Methods inherited from class java.lang.Object |
|
Methods inherited from interface org.apache.turbine.services.Service |
getConfiguration, getName, getProperties, setName, setServiceBroker |
Methods inherited from interface org.apache.turbine.services.Initable |
getInit, init, setInitableBroker, shutdown |
Field Detail |
protected static final java.lang.String NO_FILE_EXT
protected static final int PAGE_KEY
protected static final int SCREEN_KEY
protected static final int LAYOUT_KEY
protected static final int NAVIGATION_KEY
protected static final int LAYOUT_TEMPLATE_KEY
protected static final int SCREEN_TEMPLATE_KEY
private java.lang.String[] defaultNameProperties
private java.util.Hashtable[] templateNameCache
private boolean useCache
private java.lang.String defaultExtension
private java.lang.String defaultTemplate
private java.util.HashMap templateEngineRegistry
TemplateEngineService
implementations. Implementing template engines can locate
templates within the capability of any resource loaders they
may posses, and other template engines are stuck with file
based template hierarchy only.Constructor Detail |
public TurbineTemplateService()
Method Detail |
public void init() throws InitializationException
init
in interface Initable
init
in class TurbineBaseService
InitializationException.
- public java.lang.String getDefaultExtension()
getDefaultExtension
in interface TemplateService
public java.lang.String getDefaultPage()
getDefaultPage
in interface TemplateService
public java.lang.String getDefaultScreen()
getDefaultScreen
in interface TemplateService
public java.lang.String getDefaultLayout()
getDefaultLayout
in interface TemplateService
public java.lang.String getDefaultNavigation()
getDefaultNavigation
in interface TemplateService
public java.lang.String getDefaultLayoutTemplate()
getDefaultLayoutTemplate
in interface TemplateService
public java.lang.String getDefaultPageName(java.lang.String template)
getDefaultPageName
in interface TemplateService
template
- The template name.public java.lang.String getDefaultScreenName(java.lang.String template)
getDefaultScreenName
in interface TemplateService
template
- The template name.public java.lang.String getDefaultLayoutName(java.lang.String template)
getDefaultLayoutName
in interface TemplateService
template
- The template name.public java.lang.String getDefaultNavigationName(java.lang.String template)
getDefaultNavigationName
in interface TemplateService
template
- The template name.public java.lang.String getDefaultLayoutTemplateName(java.lang.String template)
getDefaultLayoutTemplateName
in interface TemplateService
template
- The template name.public java.lang.String getDefaultPageName(RunData data)
getDefaultPageName
in interface TemplateService
data
- The encapsulation of the request to retrieve the
default page for.public java.lang.String getDefaultLayoutName(RunData data)
getDefaultLayoutName
in interface TemplateService
data
- The encapsulation of the request to retrieve the
default layout for.public java.lang.String getScreenName(java.lang.String template) throws java.lang.Exception
getScreenName
in interface TemplateService
template
- The screen template name.Exception,
- a generic exception.public java.lang.String getLayoutName(java.lang.String template) throws java.lang.Exception
getLayoutName
in interface TemplateService
template
- The layout template name.Exception,
- a generic exception.public java.lang.String getNavigationName(java.lang.String template) throws java.lang.Exception
getNavigationName
in interface TemplateService
template
- The navigation template name.Exception,
- a generic exception.public java.lang.String getScreenTemplateName(java.lang.String template) throws java.lang.Exception
getScreenTemplateName
in interface TemplateService
template
- The template name parameter.Exception,
- a generic exception.public java.lang.String getLayoutTemplateName(java.lang.String template) throws java.lang.Exception
getLayoutTemplateName
in interface TemplateService
template
- The template name parameter.Exception,
- a generic exception.public java.lang.String[] translateTemplatePaths(java.lang.String[] templatePaths)
translateTemplatePaths
in interface TemplateService
templatePaths
- An array of template paths.public boolean templateExists(java.lang.String template, java.lang.String[] templatePaths)
TemplateEngineService
to
check the existance of the specified template.templateExists
in interface TemplateService
template
- The template to check for the existance of.templatePaths
- The paths to check for the template.public void registerTemplateEngineService(TemplateEngineService service)
TemplateService
.registerTemplateEngineService
in interface TemplateService
service
- The TemplateEngineService
to register.protected TemplateEngineService getTemplateEngineService(java.lang.String template)
TemplateEngineService
associated with the specified template's file extension.template
- The template name.protected java.lang.String getDefaultModuleName(java.lang.String template, int key)
template
- The template name.key
- The module type key.protected java.lang.String getCachedName(java.lang.String template, int key) throws java.lang.Exception
template
- The template name.key
- The object type key.Exception,
- a generic exception.protected java.lang.String getParsedModuleName(java.lang.String template, int key) throws java.lang.Exception
template
- The template name.key
- The module type key.Exception,
- a generaic exception.protected java.lang.String getParsedScreenTemplateName(java.lang.String template) throws java.lang.Exception
template
- The template name.Exception,
- a generic exception.protected java.lang.String getParsedLayoutTemplateName(java.lang.String template) throws java.lang.Exception
template
- The template name.Exception,
- a generic exception.private int parseTemplatePath(java.lang.String template, java.lang.StringBuffer buffer) throws java.lang.Exception
template
- The template name.buffer
- A buffer for the result.java.lang.Exception
- Malformed template name.private void initTemplate()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |