org.apache.turbine.services.jsp
Class TurbineJspService

java.lang.Object
  |
  +--org.apache.turbine.services.BaseInitable
        |
        +--org.apache.turbine.services.BaseService
              |
              +--org.apache.turbine.services.TurbineBaseService
                    |
                    +--org.apache.turbine.services.template.BaseTemplateEngineService
                          |
                          +--org.apache.turbine.services.jsp.TurbineJspService
All Implemented Interfaces:
Initable, JspService, Service, TemplateEngineService

public class TurbineJspService
extends BaseTemplateEngineService
implements JspService

This is a Service that can process JSP templates from within a Turbine screen.

Author:
John D. McNally, Jason van Zyl, Daniel Rall

Field Summary
private  int bufferSize
          The buffer size for the output stream.
private  java.lang.String[] relativeTemplatePaths
          The relative path[s] prepended to filenames
private  java.lang.String[] templatePaths
          The base path[s] prepended to filenames given in arguments
 
Fields inherited from class org.apache.turbine.services.template.BaseTemplateEngineService
configuration
 
Fields inherited from class org.apache.turbine.services.BaseService
name, properties, serviceBroker
 
Fields inherited from class org.apache.turbine.services.BaseInitable
initableBroker, isInitialized
 
Fields inherited from interface org.apache.turbine.services.jsp.JspService
LINK, RUNDATA, SERVICE_NAME
 
Fields inherited from interface org.apache.turbine.services.template.TemplateEngineService
DEFAULT_ERROR_SCREEN, DEFAULT_LAYOUT, DEFAULT_LAYOUT_TEMPLATE, DEFAULT_NAVIGATION, DEFAULT_PAGE, DEFAULT_SCREEN, DEFAULT_TEMPLATE_EXTENSION, TEMPLATE_EXTENSIONS
 
Constructor Summary
TurbineJspService()
           
 
Method Summary
 void addDefaultObjects(RunData data)
          Adds some convenience objects to the request.
 int getDefaultBufferSize()
          The buffer size
 java.lang.String getRelativeTemplateName(java.lang.String template)
          Searchs for a template in the default.template path[s] and returns the template name with a relative path which is required by javax.servlet.RequestDispatcher
 void handleRequest(RunData data, java.lang.String filename)
          Process the request
 void handleRequest(RunData data, java.lang.String filename, boolean isForward)
          Process the request
 void init(javax.servlet.ServletConfig config)
          Performs early initialization of this Turbine service.
private  void initJsp()
          This method sets up the template cache.
 boolean templateExists(java.lang.String template)
          Determine whether a given template exists.
 
Methods inherited from class org.apache.turbine.services.template.BaseTemplateEngineService
getAssociatedFileExtensions, getTemplateEngineServiceConfiguration, initConfiguration, registerConfiguration
 
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, registerNatives, toString, wait, wait, wait
 
Methods inherited from interface org.apache.turbine.services.Service
getConfiguration, getProperties, setName, setServiceBroker
 
Methods inherited from interface org.apache.turbine.services.Initable
getInit, init, init, setInitableBroker, shutdown
 

Field Detail

templatePaths

private java.lang.String[] templatePaths
The base path[s] prepended to filenames given in arguments

relativeTemplatePaths

private java.lang.String[] relativeTemplatePaths
The relative path[s] prepended to filenames

bufferSize

private int bufferSize
The buffer size for the output stream.
Constructor Detail

TurbineJspService

public TurbineJspService()
Method Detail

init

public void init(javax.servlet.ServletConfig config)
          throws InitializationException
Performs early initialization of this Turbine service.
Overrides:
init in class TurbineBaseService
Following copied from class: org.apache.turbine.services.TurbineBaseService
Parameters:
config - A ServletConfing to use for initialization activities.
Throws:
InitializationException, - if initialization of this class was not successful.

addDefaultObjects

public void addDefaultObjects(RunData data)
Adds some convenience objects to the request. For example an instance of JspLink which can be used to generate links to other templates.
Specified by:
addDefaultObjects in interface JspService
Parameters:
RunData - the turbine rundata object

getDefaultBufferSize

public int getDefaultBufferSize()
The buffer size
Specified by:
getDefaultBufferSize in interface JspService

handleRequest

public void handleRequest(RunData data,
                          java.lang.String filename)
                   throws TurbineException
Process the request
Specified by:
handleRequest in interface JspService
Parameters:
RunData -  
String - the filename of the template.
Throws:
TurbineException - Any exception trown while processing will be wrapped into a TurbineException and rethrown.

handleRequest

public void handleRequest(RunData data,
                          java.lang.String filename,
                          boolean isForward)
                   throws TurbineException
Process the request
Specified by:
handleRequest in interface JspService
Parameters:
RunData -  
String - the filename of the template.
boolean - whether to perform a forward or include.
Throws:
TurbineException - Any exception trown while processing will be wrapped into a TurbineException and rethrown.

initJsp

private void initJsp()
              throws java.lang.Exception
This method sets up the template cache.

templateExists

public boolean templateExists(java.lang.String template)
Determine whether a given template exists. This service currently only supports file base template hierarchies so we will use the utility methods provided by the template service to do the searching.
Overrides:
templateExists in class BaseTemplateEngineService
Parameters:
String - template
Returns:
boolean

getRelativeTemplateName

public java.lang.String getRelativeTemplateName(java.lang.String template)
Searchs for a template in the default.template path[s] and returns the template name with a relative path which is required by javax.servlet.RequestDispatcher
Parameters:
String - template
Returns:
String


Copyright © 1999-2001 Apache Software Foundation. All Rights Reserved.