Docjar: A Java Source and Docuemnt Enginecom.*    java.*    javax.*    org.*    all    new    plug-in

Quick Search    Search Deep

org.apache.turbine
Class Turbine  view Turbine download Turbine.java

java.lang.Object
  extended byjavax.servlet.GenericServlet
      extended byjavax.servlet.http.HttpServlet
          extended byorg.apache.turbine.Turbine
All Implemented Interfaces:
java.io.Serializable, javax.servlet.Servlet, javax.servlet.ServletConfig, TurbineConstants

public class Turbine
extends javax.servlet.http.HttpServlet
implements TurbineConstants

Turbine is the main servlet for the entire system. It is final because you should not ever need to subclass this servlet. If you need to perform initialization of a service, then you should implement the Services API and let your code be initialized by it. If you need to override something in the doGet() or doPost() methods, edit the TurbineResources.properties file and specify your own classes there.

Turbine servlet recognizes the following initialization parameters.

Version:
$Id: Turbine.java 264152 2005-08-29 14:50:22Z henning $

Field Summary
private static java.lang.String applicationRoot
          The base from which the Turbine application will operate.
static java.lang.String BASEDIR_KEY
          The base directory key
private static org.apache.commons.configuration.Configuration configuration
          Our internal configuration object
private static boolean firstDoGet
          Should initialization activities be performed during doGet() execution?
private static boolean firstInit
          In certain situations the init() method is called more than once, somtimes even concurrently.
private static java.lang.Throwable initFailure
          Whether init succeeded or not.
private  java.lang.String inputEncoding
          Default Input encoding if the servlet container does not report an encoding
private static org.apache.commons.logging.Log log
          Logging class from commons.logging
static java.lang.String REDIRECTED_PATHINFO_NAME
          Name of path info parameter used to indicate the redirected stage of a given user's initial Turbine request
private  org.apache.turbine.services.rundata.RunDataService rundataService
          A reference to the RunData Service
private static long serialVersionUID
          SerialVersionUID for serialization
private static org.apache.turbine.util.ServerData serverData
          Keep all the properties of the web server in a convenient data structure
private static javax.servlet.ServletConfig servletConfig
          Servlet config for this Turbine webapp.
private static javax.servlet.ServletContext servletContext
          Servlet context for this Turbine webapp.
private  org.apache.turbine.services.template.TemplateService templateService
          A reference to the Template Service
private static java.lang.String webappRoot
          The webapp root where the Turbine application is running in the servlet container.
 
Fields inherited from class javax.servlet.http.HttpServlet
 
Fields inherited from class javax.servlet.GenericServlet
 
Fields inherited from interface org.apache.turbine.TurbineConstants
ACTION_ACCESS_CONTROLLER_DEFAULT, ACTION_ACCESS_CONTROLLER_KEY, ACTION_CACHE_SIZE_DEFAULT, ACTION_CACHE_SIZE_KEY, ACTION_EVENTSUBMIT_NEEDSVALUE_DEFAULT, ACTION_EVENTSUBMIT_NEEDSVALUE_KEY, ACTION_LOGIN_DEFAULT, ACTION_LOGIN_KEY, ACTION_LOGOUT_DEFAULT, ACTION_LOGOUT_KEY, ACTION_PREFIX, ACTION_SESSION_VALIDATOR_DEFAULT, ACTION_SESSION_VALIDATOR_KEY, APPLICATION_ROOT_DEFAULT, APPLICATION_ROOT_KEY, CONFIG_NAMESPACE, DEFAULT_DOCUMENT_TYPE_KEY, DEFAULT_HTML_DOCTYPE_IDENTIFIER_DEFAULT, DEFAULT_HTML_DOCTYPE_IDENTIFIER_KEY, DEFAULT_HTML_DOCTYPE_ROOT_ELEMENT_DEFAULT, DEFAULT_HTML_DOCTYPE_ROOT_ELEMENT_KEY, DEFAULT_HTML_DOCTYPE_URI_DEFAULT, DEFAULT_HTML_DOCTYPE_URI_KEY, DEFAULT_LOGGER, DOCUMENT_TYPE_HTML40FRAMESET, DOCUMENT_TYPE_HTML40STRICT, DOCUMENT_TYPE_HTML40TRANSITIONAL, LAYOUT_CACHE_SIZE_DEFAULT, LAYOUT_CACHE_SIZE_KEY, LAYOUT_DEFAULT, LAYOUT_PREFIX, LOCALE_DEFAULT_CHARSET_DEFAULT, LOCALE_DEFAULT_CHARSET_KEY, LOCALE_DEFAULT_COUNTRY_DEFAULT, LOCALE_DEFAULT_COUNTRY_KEY, LOCALE_DEFAULT_LANGUAGE_DEFAULT, LOCALE_DEFAULT_LANGUAGE_KEY, LOG4J_CONFIG_FILE, LOG4J_CONFIG_FILE_DEFAULT, LOGGING_ROOT_DEFAULT, LOGGING_ROOT_KEY, LOGIN_ERROR, LOGIN_MESSAGE, LOGIN_MESSAGE_NOSCREEN, LOGOUT_MESSAGE, MAIL_SERVER_DEFAULT, MAIL_SERVER_KEY, MAIL_SMTP_FROM, MODULE_CACHE_DEFAULT, MODULE_CACHE_KEY, MODULE_PACKAGES, NAVIGATION_CACHE_SIZE_DEFAULT, NAVIGATION_CACHE_SIZE_KEY, NAVIGATION_PLACEHOLDER, NAVIGATION_PREFIX, PAGE_CACHE_SIZE_DEFAULT, PAGE_CACHE_SIZE_KEY, PAGE_DEFAULT_DEFAULT, PAGE_DEFAULT_KEY, PAGE_PREFIX, PARAMETER_ENCODING_DEFAULT, PARAMETER_ENCODING_KEY, PP_URL_CASE_FOLDING, PROCESSING_EXCEPTION_PLACEHOLDER, SCHEDULED_JOB_CACHE_SIZE_DEFAULT, SCHEDULED_JOB_CACHE_SIZE_KEY, SCHEDULEDJOB_PREFIX, SCHEDULER_LOG_FACILITY, SCREEN_CACHE_SIZE_DEFAULT, SCREEN_CACHE_SIZE_KEY, SCREEN_DEFAULT_DEFAULT, SCREEN_ERROR_DEFAULT, SCREEN_ERROR_KEY, SCREEN_HOMEPAGE, SCREEN_INVALID_STATE, SCREEN_LOGIN, SCREEN_PLACEHOLDER, SCREEN_PREFIX, SESSION_TIMEOUT_DEFAULT, SESSION_TIMEOUT_KEY, STACK_TRACE_PLACEHOLDER, TEMPLATE_ERROR_JSP, TEMPLATE_ERROR_KEY, TEMPLATE_ERROR_VM, TEMPLATE_HOMEPAGE, TEMPLATE_INVALID_STATE, TEMPLATE_LOGIN, USE_SSL_DEFAULT, USE_SSL_KEY, UUID_ADDRESS_KEY, WEB_CONTEXT, WEBAPP_ROOT_KEY
 
Constructor Summary
Turbine()
           
 
Method Summary
private  void cleanupTemplateContext(org.apache.turbine.util.RunData data)
          cleans the Velocity Context if available.
private  void configure(javax.servlet.ServletConfig config, javax.servlet.ServletContext context)
          Read the master configuration file in, configure logging and start up any early services.
private static void createRuntimeDirectories(javax.servlet.ServletContext context, javax.servlet.ServletConfig config)
          Create any directories that might be needed during runtime.
 void destroy()
          The Servlet destroy method.
 void doGet(javax.servlet.http.HttpServletRequest req, javax.servlet.http.HttpServletResponse res)
          The primary method invoked when the Turbine servlet is executed.
 void doPost(javax.servlet.http.HttpServletRequest req, javax.servlet.http.HttpServletResponse res)
          In this application doGet and doPost are the same thing.
protected static java.lang.String findInitParameter(javax.servlet.ServletContext context, javax.servlet.ServletConfig config, java.lang.String name, java.lang.String defaultValue)
          Finds the specified servlet configuration/initialization parameter, looking first for a servlet-specific parameter, then for a global parameter, and using the provided default if not found.
static java.lang.String getApplicationRoot()
          Get the application root for this Turbine webapp.
static org.apache.commons.configuration.Configuration getConfiguration()
          Return the current configuration with all keys included
static java.lang.String getContextPath()
          Return the context path.
static org.apache.turbine.util.ServerData getDefaultServerData()
          Return all the Turbine Servlet information (Server Name, Port, Scheme in a ServerData structure.
static java.lang.String getRealPath(java.lang.String path)
          Used to get the real path of configuration and resource information.
static java.lang.String getScriptName()
          Get the script name.
static java.lang.String getServerName()
          Return the server name.
static java.lang.String getServerPort()
          Return the server port.
static java.lang.String getServerScheme()
          Return the server scheme.
private  org.apache.turbine.services.ServiceManager getServiceManager()
          Return an instance of the currently configured Service Manager
 java.lang.String getServletInfo()
          Return the servlet info.
static javax.servlet.ServletConfig getTurbineServletConfig()
          Get the servlet config for this turbine webapp.
static javax.servlet.ServletContext getTurbineServletContext()
          Get the servlet context for this turbine webapp.
private  void handleException(org.apache.turbine.util.RunData data, javax.servlet.http.HttpServletResponse res, java.lang.Throwable t)
          This method is about making sure that we catch and display errors to the screen in one fashion or another.
 void init()
          This init method will load the default resources from a properties file.
 void init(org.apache.turbine.util.RunData data)
          Initializes the services which need RunData to initialize themselves (post startup).
private  void loginAction(org.apache.turbine.util.RunData data)
          This method is executed if the configured Login action should be executed by Turbine.
private  void logoutAction(org.apache.turbine.util.RunData data)
          This method is executed if the configured Logout action should be executed by Turbine.
static void saveServletInfo(org.apache.turbine.util.RunData data)
          Save some information about this servlet so that it can be utilized by object instances that do not have direct access to RunData.
static void setApplicationRoot(java.lang.String val)
          Set the application root for the webapp.
static void setTurbineServletConfig(javax.servlet.ServletConfig config)
          Set the servlet config for this turbine webapp.
static void setTurbineServletContext(javax.servlet.ServletContext context)
          Set the servlet context for this turbine webapp.
 
Methods inherited from class javax.servlet.http.HttpServlet
doDelete, doHead, doOptions, doPut, doTrace, getLastModified, service, service
 
Methods inherited from class javax.servlet.GenericServlet
getInitParameter, getInitParameterNames, getServletConfig, getServletContext, getServletName, init, log, log
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

serialVersionUID

private static final long serialVersionUID
SerialVersionUID for serialization

See Also:
Constant Field Values

REDIRECTED_PATHINFO_NAME

public static final java.lang.String REDIRECTED_PATHINFO_NAME
Name of path info parameter used to indicate the redirected stage of a given user's initial Turbine request

See Also:
Constant Field Values

BASEDIR_KEY

public static final java.lang.String BASEDIR_KEY
The base directory key

See Also:
Constant Field Values

firstInit

private static boolean firstInit
In certain situations the init() method is called more than once, somtimes even concurrently. This causes bad things to happen, so we use this flag to prevent it.


initFailure

private static java.lang.Throwable initFailure
Whether init succeeded or not.


firstDoGet

private static boolean firstDoGet
Should initialization activities be performed during doGet() execution?


serverData

private static org.apache.turbine.util.ServerData serverData
Keep all the properties of the web server in a convenient data structure


applicationRoot

private static java.lang.String applicationRoot
The base from which the Turbine application will operate.


servletConfig

private static javax.servlet.ServletConfig servletConfig
Servlet config for this Turbine webapp.


servletContext

private static javax.servlet.ServletContext servletContext
Servlet context for this Turbine webapp.


webappRoot

private static java.lang.String webappRoot
The webapp root where the Turbine application is running in the servlet container. This might differ from the application root.


configuration

private static org.apache.commons.configuration.Configuration configuration
Our internal configuration object


templateService

private org.apache.turbine.services.template.TemplateService templateService
A reference to the Template Service


rundataService

private org.apache.turbine.services.rundata.RunDataService rundataService
A reference to the RunData Service


inputEncoding

private java.lang.String inputEncoding
Default Input encoding if the servlet container does not report an encoding


log

private static org.apache.commons.logging.Log log
Logging class from commons.logging

Constructor Detail

Turbine

public Turbine()
Method Detail

init

public final void init()
                throws javax.servlet.ServletException
This init method will load the default resources from a properties file. This method is called by init(ServletConfig config)


configure

private void configure(javax.servlet.ServletConfig config,
                       javax.servlet.ServletContext context)
                throws java.lang.Exception
Read the master configuration file in, configure logging and start up any early services.


createRuntimeDirectories

private static void createRuntimeDirectories(javax.servlet.ServletContext context,
                                             javax.servlet.ServletConfig config)
Create any directories that might be needed during runtime. Right now this includes:
  • The directory to write the log files to (relative to the web application root), or null for the default of /logs. The directory is specified via the TurbineConstants#LOGGING_ROOT parameter.


findInitParameter

protected static final java.lang.String findInitParameter(javax.servlet.ServletContext context,
                                                          javax.servlet.ServletConfig config,
                                                          java.lang.String name,
                                                          java.lang.String defaultValue)
Finds the specified servlet configuration/initialization parameter, looking first for a servlet-specific parameter, then for a global parameter, and using the provided default if not found.


init

public final void init(org.apache.turbine.util.RunData data)
Initializes the services which need RunData to initialize themselves (post startup).


getConfiguration

public static org.apache.commons.configuration.Configuration getConfiguration()
Return the current configuration with all keys included


getServerName

public static java.lang.String getServerName()
Return the server name.


getServerScheme

public static java.lang.String getServerScheme()
Return the server scheme.


getServerPort

public static java.lang.String getServerPort()
Return the server port.


getScriptName

public static java.lang.String getScriptName()
Get the script name. This is the initial script name. Actually this is probably not needed any more. I'll check. jvz.


getContextPath

public static java.lang.String getContextPath()
Return the context path.


getDefaultServerData

public static org.apache.turbine.util.ServerData getDefaultServerData()
Return all the Turbine Servlet information (Server Name, Port, Scheme in a ServerData structure. This is generated from the values set when initializing the Turbine and may not be correct if you're running in a clustered structure. This might be used if you need a DataURI and have no RunData object handy-


setTurbineServletConfig

public static void setTurbineServletConfig(javax.servlet.ServletConfig config)
Set the servlet config for this turbine webapp.


getTurbineServletConfig

public static javax.servlet.ServletConfig getTurbineServletConfig()
Get the servlet config for this turbine webapp.


setTurbineServletContext

public static void setTurbineServletContext(javax.servlet.ServletContext context)
Set the servlet context for this turbine webapp.


getTurbineServletContext

public static javax.servlet.ServletContext getTurbineServletContext()
Get the servlet context for this turbine webapp.


destroy

public final void destroy()
The Servlet destroy method. Invokes ServiceBroker tear down method.

Specified by:
destroy in interface javax.servlet.Servlet

doGet

public final void doGet(javax.servlet.http.HttpServletRequest req,
                        javax.servlet.http.HttpServletResponse res)
                 throws java.io.IOException,
                        javax.servlet.ServletException
The primary method invoked when the Turbine servlet is executed.


doPost

public final void doPost(javax.servlet.http.HttpServletRequest req,
                         javax.servlet.http.HttpServletResponse res)
                  throws java.io.IOException,
                         javax.servlet.ServletException
In this application doGet and doPost are the same thing.


loginAction

private void loginAction(org.apache.turbine.util.RunData data)
                  throws java.lang.Exception
This method is executed if the configured Login action should be executed by Turbine.

This Action must be performed before the Session validation or we get sent in an endless loop back to the Login screen before the action can be performed


logoutAction

private void logoutAction(org.apache.turbine.util.RunData data)
                   throws java.lang.Exception
This method is executed if the configured Logout action should be executed by Turbine.

This Action must be performed before the Session validation for the session validator to send us back to the Login screen.

The existing session is invalidated before the logout action is executed.


cleanupTemplateContext

private void cleanupTemplateContext(org.apache.turbine.util.RunData data)
                             throws java.lang.Exception
cleans the Velocity Context if available.


getServletInfo

public final java.lang.String getServletInfo()
Return the servlet info.

Specified by:
getServletInfo in interface javax.servlet.Servlet

handleException

private void handleException(org.apache.turbine.util.RunData data,
                             javax.servlet.http.HttpServletResponse res,
                             java.lang.Throwable t)
This method is about making sure that we catch and display errors to the screen in one fashion or another. What happens is that it will attempt to show the error using your user defined Error Screen. If that fails, then it will resort to just displaying the error and logging it all over the place including the servlet engine log file, the Turbine log file and on the screen.


saveServletInfo

public static void saveServletInfo(org.apache.turbine.util.RunData data)
Save some information about this servlet so that it can be utilized by object instances that do not have direct access to RunData.


setApplicationRoot

public static void setApplicationRoot(java.lang.String val)
Set the application root for the webapp.


getApplicationRoot

public static java.lang.String getApplicationRoot()
Get the application root for this Turbine webapp. This concept was started in 3.0 and will allow an app to be developed from a standard CVS layout. With a simple switch the app will work fully within the servlet container for deployment.


getRealPath

public static java.lang.String getRealPath(java.lang.String path)
Used to get the real path of configuration and resource information. This can be used by an app being developed in a standard CVS layout.


getServiceManager

private org.apache.turbine.services.ServiceManager getServiceManager()
Return an instance of the currently configured Service Manager