org.apache.turbine
Class Turbine

java.lang.Object
  extended by javax.servlet.GenericServlet
      extended by javax.servlet.http.HttpServlet
          extended by org.apache.turbine.Turbine
All Implemented Interfaces:
Serializable, javax.servlet.Servlet, javax.servlet.ServletConfig

public class Turbine
extends javax.servlet.http.HttpServlet

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 1096586 2011-04-25 20:31:43Z ludwig $
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, Peter Courcoux, Thomas Vandahl
See Also:
Serialized Form

Field Summary
static String BASEDIR_KEY
          The base directory key
static String REDIRECTED_PATHINFO_NAME
          Name of path info parameter used to indicate the redirected stage of a given user's initial Turbine request
 
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 String findInitParameter(javax.servlet.ServletContext context, javax.servlet.ServletConfig config, String name, 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 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 String getContextPath()
          Return the context path.
 String getDefaultInputEncoding()
          Returns the default input encoding for the servlet.
static ServerData getDefaultServerData()
          Return all the Turbine Servlet information (Server Name, Port, Scheme in a ServerData structure.
static String getRealPath(String path)
          Used to get the real path of configuration and resource information.
static String getScriptName()
          Get the script name.
static String getServerName()
          Return the server name.
static String getServerPort()
          Return the server port.
static String getServerScheme()
          Return the server scheme.
 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(PipelineData data)
          Initializes the services which need PipelineData to initialize themselves (post startup).
static void saveServletInfo(PipelineData 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(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 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 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)

Overrides:
init in class javax.servlet.GenericServlet
Throws:
javax.servlet.ServletException - a servlet exception.

findInitParameter

protected static final String findInitParameter(javax.servlet.ServletContext context,
                                                javax.servlet.ServletConfig config,
                                                String name,
                                                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(PipelineData data)
Initializes the services which need PipelineData 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 String getServerName()
Return the server name.

Returns:
String server name

getServerScheme

public static String getServerScheme()
Return the server scheme.

Returns:
String server scheme

getServerPort

public static String getServerPort()
Return the server port.

Returns:
String server port

getScriptName

public static 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 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
Overrides:
destroy in class javax.servlet.GenericServlet

doGet

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

Overrides:
doGet in class javax.servlet.http.HttpServlet
Parameters:
req - Servlet request.
res - Servlet response.
Throws:
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 IOException,
                         javax.servlet.ServletException
In this application doGet and doPost are the same thing.

Overrides:
doPost in class javax.servlet.http.HttpServlet
Parameters:
req - Servlet request.
res - Servlet response.
Throws:
IOException - a servlet exception.
javax.servlet.ServletException - a servlet exception.

getServletInfo

public final String getServletInfo()
Return the servlet info.

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

saveServletInfo

public static void saveServletInfo(PipelineData 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 - Turbine request data

setApplicationRoot

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

Parameters:
val - New app root.

getApplicationRoot

public static 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 String getRealPath(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

getDefaultInputEncoding

public String getDefaultInputEncoding()
Returns the default input encoding for the servlet.

Returns:
the default input encoding.


Copyright © 2000-2011 The Apache Software Foundation. All Rights Reserved.