org.apache.jetspeed.services.template
Class JetspeedTemplateService

java.lang.Object
  extended byorg.apache.turbine.services.BaseInitable
      extended byorg.apache.turbine.services.BaseService
          extended byorg.apache.turbine.services.TurbineBaseService
              extended byorg.apache.jetspeed.services.template.JetspeedTemplateService
All Implemented Interfaces:
org.apache.turbine.services.Initable, org.apache.turbine.services.Service

public class JetspeedTemplateService
extends org.apache.turbine.services.TurbineBaseService

This service extends the TurbineTemplateService to modify its behaviour: Not only layout and screen packages, but also the screen templates are searched in the template neames filepath, so that a fallback strategy is provided, that can be used for multi-language, multi-device and browser-specific support support.

E.g: a template name "/html/en/US/IE/mytemplate" would search for following files (in the given order):

  1. . /html/en/US/IE/mytemplate
  2. . /html/en/US/mytemplate
  3. . /html/en/mytemplate
  4. . /html/mytemplate
  5. . /mytemplate

TurbineTemplateService part:

Version:
$Id: JetspeedTemplateService.java,v 1.11 2004/02/23 03:38:54 jford Exp $
Author:
John D. McNally, Dave Bryson JetspeedTemplateService part:, Ingo Schuster

Field Summary
 
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.Service
SERVICE_NAME
 
Constructor Summary
JetspeedTemplateService()
           
 
Method Summary
 java.lang.String getDefaultExtension()
          Get the default extension given in the properties file.
 java.lang.String getDefaultLayoutTemplate()
          Get the default layout template given in the properties file.
 java.lang.String getDefaultNavigation()
          Get the default Navigation given in the properties file.
 java.lang.String getDefaultScreen()
          Get the Screen template given in the properties file.
 java.lang.String getLayoutTemplateName(java.lang.String name)
          Locate and return the name of a layout template.
 java.lang.String getNavigationName(java.lang.String name)
          Locate and return the name of a Navigation module.
 java.lang.String getScreenName(java.lang.String name)
          Locate and return the name of a Screen module.
 java.lang.String getScreenTemplateName(java.lang.String key)
          Locate and return the name of a screen template.
 void init(javax.servlet.ServletConfig config)
          Called the first time the Service is used.
protected  java.lang.String parseNavigationTemplate(java.lang.String template)
          Parse the template name out to a package path to locate the Navigation module.
protected  java.lang.String[] parseScreenTemplate(java.lang.String template)
          This method takes the template parameter and parses it, so that relevant Screen/Layout-template information can be extracted.
 
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
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.apache.turbine.services.Initable
getInit, setInitableBroker
 

Constructor Detail

JetspeedTemplateService

public JetspeedTemplateService()
Method Detail

init

public void init(javax.servlet.ServletConfig config)
          throws org.apache.turbine.services.InitializationException
Called the first time the Service is used.

Parameters:
config - A ServletConfig.
Throws:
org.apache.turbine.services.InitializationException

getDefaultScreen

public java.lang.String getDefaultScreen()
Get the Screen template given in the properties file.

Returns:
A String which is the value of the TemplateService default.screen property.

getDefaultNavigation

public java.lang.String getDefaultNavigation()
Get the default Navigation given in the properties file.

Returns:
A String which is the value of the TemplateService default.navigation property.

getDefaultLayoutTemplate

public java.lang.String getDefaultLayoutTemplate()
Get the default layout template given in the properties file.

Returns:
A String which is the value of the TemplateService default.layout.template property.

getScreenTemplateName

public java.lang.String getScreenTemplateName(java.lang.String key)
                                       throws java.lang.Exception
Locate and return the name of a screen template.

Returns:
A String with the screen template path.
Throws:
Exception, - a generic exception.
java.lang.Exception

getLayoutTemplateName

public java.lang.String getLayoutTemplateName(java.lang.String name)
                                       throws java.lang.Exception
Locate and return the name of a layout template.

Parameters:
name - A String with the name of the template.
Returns:
A String with the layout template path.
Throws:
Exception, - a generic exception.
java.lang.Exception

getNavigationName

public java.lang.String getNavigationName(java.lang.String name)
                                   throws java.lang.Exception
Locate and return the name of a Navigation module.

Parameters:
name - A String with the name of the template.
Returns:
A String with the name of the navigation.
Throws:
Exception, - a generic exception.
java.lang.Exception

getScreenName

public java.lang.String getScreenName(java.lang.String name)
                               throws java.lang.Exception
Locate and return the name of a Screen module.

Parameters:
name - A String with the name of the template.
Returns:
A String with the name of the screen.
Throws:
Exception, - a generic exception.
java.lang.Exception

getDefaultExtension

public java.lang.String getDefaultExtension()
Get the default extension given in the properties file.

Returns:
A String with the extension.

parseScreenTemplate

protected java.lang.String[] parseScreenTemplate(java.lang.String template)
                                          throws java.lang.Exception
This method takes the template parameter and parses it, so that relevant Screen/Layout-template information can be extracted.

Parameters:
template - A String with the template name.
Returns:
A String[] where the first element is the Screen name and the second element is the layout template.
Throws:
java.lang.Exception

parseNavigationTemplate

protected java.lang.String parseNavigationTemplate(java.lang.String template)
Parse the template name out to a package path to locate the Navigation module. This is different than the Screen/Layout parser in that it only looks for packages. Note: If caching is enabled, this is only performed once for each unique template.

Returns:
A String with the name of the Navigation module to use for the template.


Copyright © 2000-2005 Apache Software Foundation. All Rights Reserved.