org.apache.turbine
Class Turbine

java.lang.Object
  |
  +--javax.servlet.GenericServlet
        |
        +--javax.servlet.http.HttpServlet
              |
              +--org.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,v 1.11 2002/03/13 19:44:19 mpoeschl Exp $
Author:
Jon S. Stevens, Brett McLaughlin, Greg Ritter, John D. McNally, Frank Y. Kim, Rafal Krzewski, Jason van Zyl, Sean Legassick, Martin Poeschl
See Also:
Serialized Form

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 java.lang.String contextPath
           
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.
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 static java.lang.String serverName
          Server information.
private static java.lang.String serverPort
           
private static java.lang.String serverScheme
           
private  TurbineServices services
          instance of turbine services
private static java.lang.String webappRoot
          The webapp root where the Turbine application is running.
 
Fields inherited from class javax.servlet.http.HttpServlet
HEADER_IFMODSINCE, HEADER_LASTMOD, LSTRING_FILE, lStrings, METHOD_DELETE, METHOD_GET, METHOD_HEAD, METHOD_OPTIONS, METHOD_POST, METHOD_PUT, METHOD_TRACE
 
Fields inherited from class javax.servlet.GenericServlet
config
 
Fields inherited from interface org.apache.turbine.TurbineConstants
ACTION_ACCESS_CONTROLLER, ACTION_CACHE_SIZE, ACTION_LOGIN, ACTION_LOGOUT, ACTION_SESSION_VALIDATOR, APPLICATION_ROOT, DB_ADAPTOR, DB_CONNECTION_LOG_INTERVAL, DB_CONNECTION_WAIT_TIMEOUT, DB_DRIVER, DB_EXPIRYTIME, DB_IDBROKER_CLEVERQUANTITY, DB_MAXCONNECTIONS, DB_PASSWORD, DB_URL, DB_USERNAME, DEFAULT_DOCUMENT_TYPE, LAYOUT_CACHE_SIZE, LAYOUT_DEFAULT, LOGIN_ERROR, LOGIN_MESSAGE, LOGIN_MESSAGE_NOSCREEN, LOGOUT_MESSAGE, MAIL_SERVER_KEY, MAPS_BUILDER, MODULE_CACHE, MODULE_PACKAGES, NAVIGATION_CACHE_SIZE, PAGE_CACHE_SIZE, PAGE_DEFAULT, PP_URL_CASE_FOLDING, SCHEDULED_JOB_CACHE_SIZE, SCHEDULER_LOG_FACILITY, SCREEN_CACHE_SIZE, SCREEN_ERROR, SCREEN_HOMEPAGE, SCREEN_INVALID_STATE, SCREEN_LOGIN, SQL_LOG_FACILITY, TEMPLATE_ERROR, TEMPLATE_HOMEPAGE, TEMPLATE_INVALID_STATE, TEMPLATE_LOGIN, USE_SSL, WEBAPP_ROOT
 
Constructor Summary
Turbine()
           
 
Method Summary
private static void createRuntimeDirectories()
          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.
static java.lang.String getApplicationRoot()
          Get the application root for this Turbine webapp.
static java.lang.String getContextPath()
          Return the context path.
static java.lang.String getRealPath(java.lang.String path)
          Used to get the real path of configuration and resource information.
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.
private  void handleException(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(RunData data)
          Initializes the services which need RunData to initialize themselves (post startup).
 void init(javax.servlet.ServletConfig config)
          This init method will load the default resources from a properties file.
 void log(java.lang.String msg)
          logs message using turbine's logging facility
 void log(java.lang.String message, java.lang.Throwable t)
          Writes an explanatory message and a stack trace for a given Throwable exception
 
Methods inherited from class javax.servlet.http.HttpServlet
, doDelete, doHead, doOptions, doPut, doTrace, getAllDeclaredMethods, getLastModified, maybeSetLastModified, service, service
 
Methods inherited from class javax.servlet.GenericServlet
getInitParameter, getInitParameterNames, getServletConfig, getServletContext, getServletName, init
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, registerNatives, 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

BASEDIR_KEY

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

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?

applicationRoot

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

webappRoot

private static java.lang.String webappRoot
The webapp root where the Turbine application is running.

services

private TurbineServices services
instance of turbine services

serverName

private static java.lang.String serverName
Server information. This information needs to be made available to processes that do not have access to RunData and the ServletService doesn't seem to be working in all cases.

serverScheme

private static java.lang.String serverScheme

serverPort

private static java.lang.String serverPort

contextPath

private static java.lang.String contextPath
Constructor Detail

Turbine

public Turbine()
Method Detail

init

public final void init(javax.servlet.ServletConfig config)
                throws javax.servlet.ServletException
This init method will load the default resources from a properties file.
Overrides:
init in class javax.servlet.GenericServlet
Parameters:
config - typical Servlet initialization parameter.
Throws:
javax.servlet.ServletException - a servlet exception.

createRuntimeDirectories

private static void createRuntimeDirectories()
Create any directories that might be needed during runtime. Right now this includes: i) directories for logging

init

public final void init(RunData data)
Initializes the services which need RunData to initialize themselves (post startup).
Parameters:
data - The first GET request.

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

getContextPath

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

destroy

public final void destroy()
The Servlet destroy method. Invokes ServiceBroker tear down method.
Overrides:
destroy in class javax.servlet.GenericServlet

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.
Overrides:
doGet in class javax.servlet.http.HttpServlet
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.
Overrides:
doPost in class javax.servlet.http.HttpServlet
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.
Overrides:
getServletInfo in class javax.servlet.GenericServlet
Returns:
a string with the servlet information.

handleException

private final void handleException(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.
Parameters:
data - A Turbine RunData object.
res - Servlet response.
e - The exception to report.

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:
String - path
String - path translated to the application root

log

public void log(java.lang.String msg)
logs message using turbine's logging facility
Overrides:
log in class javax.servlet.GenericServlet
Parameters:
msg - message to be logged

log

public void log(java.lang.String message,
                java.lang.Throwable t)
Writes an explanatory message and a stack trace for a given Throwable exception
Overrides:
log in class javax.servlet.GenericServlet
Parameters:
message - the message
t - the error


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