org.apache.turbine
Class Turbine

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 543399 2007-06-01 06:15:17Z seade $
Author:
Jon S. Stevens, Brett McLaughlin, Greg Ritter, John D. McNally, Frank Y. Kim, Rafal Krzewski, Jason van Zyl, Sean Legassick, Martin Poeschl, Henning P. Schmiedehausen, Quinton McCombs, Eric Pugh, Scott Eade
See Also:
Serialized Form

Field Summary
static java.lang.String BASEDIR_KEY
          The base directory key
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
 
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_CONTEXT_PATH_KEY, 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, DEFAULT_SCRIPT_NAME_KEY, DEFAULT_SERVER_NAME_KEY, DEFAULT_SERVER_PORT_KEY, DEFAULT_SERVER_SCHEME_KEY, 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
 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 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.
 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.
 void init()
          This init method will load the default resources from a properties file.
 void init(RunData data)
          Initializes the services which need RunData to initialize themselves (post startup).
static void saveServletInfo(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

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
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)

Throws:
javax.servlet.ServletException - a servlet exception.

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(RunData data)
Initializes the services which need RunData to initialize themselves (post startup).

Parameters:
data - The first GET request.

getConfiguration

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

Returns:
a Configuration Object

getServerName

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

Returns:
String server name

getServerScheme

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

Returns:
String server scheme

getServerPort

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

Returns:
String 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.

Returns:
String initial script name.

getContextPath

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

Returns:
String context path

getDefaultServerData

public static 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. You can provide default values in your configuration for cases where access is requied before your application is first accessed by a user. This might be used if you need a DataURI and have no RunData object handy.

Returns:
An initialized ServerData object

setTurbineServletConfig

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

Parameters:
config - New servlet config

getTurbineServletConfig

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

Returns:
ServletConfig

setTurbineServletContext

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

Parameters:
context - New servlet context.

getTurbineServletContext

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

Returns:
ServletContext

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.

Parameters:
req - Servlet request.
res - Servlet response.
Throws:
java.io.IOException - a servlet exception.
javax.servlet.ServletException - a servlet exception.

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.

Parameters:
req - Servlet request.
res - Servlet response.
Throws:
java.io.IOException - a servlet exception.
javax.servlet.ServletException - a servlet exception.

getServletInfo

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

Specified by:
getServletInfo in interface javax.servlet.Servlet
Returns:
a string with the servlet information.

saveServletInfo

public static void saveServletInfo(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.

Parameters:
data -

setApplicationRoot

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

Parameters:
val - New app root.

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.

Returns:
String applicationRoot

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.

Parameters:
path - path translated to the application root
Returns:
the real path


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