org.jwarp.service.web
Class JWarpServlet

org.jwarp.service.web.JWarpServlet

public class JWarpServlet

The AAppController class is the central processing unit. The class is conforming the Java serlvet API and controls initialisation of the different application areas. Such areas are:
- Loading of all text configurations
- Loading and initialising of all DB connections needed
- Initialising of all internal structures
- Loading of all ActionControllers and Actions
- Dispatching of commands to the registered Actions.
- Output of error mesages if necessary.

Version:
1.0
Author:
A. Tresch, M.Schaefer

Field Summary
protected  IConfiguration config
          Configuration manager that holds further DB and connection setup.
protected  IContext context
          The application's/servlet's context
protected  WebContext contextPrototype
          WebContext prototype for making the context params
protected  boolean debugging
          Variable for switching on and off extensive debugging messages
protected  int errorNumber
          If the application status is STATUS_RUNTIME_ERROR or STATUS_CONFIG_ERROR then this variable contains the xact error number.
protected  ILogWriter log
          Log file access writer for the application.
protected  java.lang.String name
          The name of this servlet.
protected  ServerData serverData
          The base url for this application
protected  short status
          current application status number.
static short STATUS_CONFIG_ERROR
          Status value that flags that the initialisation of the
application failed because user data was false or missing.
static short STATUS_CONFIGURED
          Status value signalling that the application is ready to run.
static short STATUS_CONFIGURING
          Status value signalling that the application is ready to run.
static short STATUS_CREATED
          Status value signalling that the application was created but is not configured yet.
static short STATUS_RUNNING
          Status value signalling that the application is up and running.
static short STATUS_RUNTIME_ERROR
          Status value that flags that some runtime error occurred during start or run.
static short STATUS_STARTING
          Status value signalling that the application is starting up..
static short STATUS_STOPPED
          Status value signalling that the application was stopped.
static short STATUS_STOPPING
          Status value sugnalling that the application is going down.
protected  ITicket systemTicket
          The ticket for system access to the context.
protected  IWebService webService
           
 
Constructor Summary
JWarpServlet()
           
 
Method Summary
 void configure(org.jdom.Element config)
           
 void destroy()
          Servlet destroy method.
 java.lang.String getAppName()
          Get the servlet name.
 IConfiguration getConfig()
          This method returns the config object for the application configuration.
 int getError()
          Get the number of the current error (if any).
 java.lang.String getErrorMessage()
          Get the error message of the current error (if any)
 ILogWriter getMainLog()
          Return the controllers log object
 ServerData getServerData()
           
 short getStatus()
          This method return the actual status of the application The status constants from the class are used for a more detailed description.
 void handleException(java.lang.Exception e, WebContext c)
           
 void init(org.jwarp.service.web.ServletConfig config)
          Servlet initialisation.
 boolean isDebugging()
          This method returns if the application actually is running in debugging mode and so printing more detailed information on errors
 void reload()
          Reloads the configuration file and reinitialises the PoolManager.
 void service(org.jwarp.service.web.HttpServletRequest req, javax.servlet.http.HttpServletResponse res)
          Servlet service method.
 void setDebugging(boolean debugging)
          With this method debugging mode can be switched on and off
 

Field Detail

name

protected java.lang.String name
The name of this servlet. This name can be set within the XML configuration.

debugging

protected boolean debugging
Variable for switching on and off extensive debugging messages

serverData

protected ServerData serverData
The base url for this application

context

protected IContext context
The application's/servlet's context

contextPrototype

protected WebContext contextPrototype
WebContext prototype for making the context params

STATUS_CREATED

public static final short STATUS_CREATED
Status value signalling that the application was created but is not configured yet.

STATUS_CONFIGURING

public static final short STATUS_CONFIGURING
Status value signalling that the application is ready to run.

STATUS_CONFIGURED

public static final short STATUS_CONFIGURED
Status value signalling that the application is ready to run.

STATUS_STARTING

public static final short STATUS_STARTING
Status value signalling that the application is starting up..

STATUS_RUNNING

public static final short STATUS_RUNNING
Status value signalling that the application is up and running.

STATUS_STOPPING

public static final short STATUS_STOPPING
Status value sugnalling that the application is going down.

STATUS_STOPPED

public static final short STATUS_STOPPED
Status value signalling that the application was stopped.

STATUS_CONFIG_ERROR

public static final short STATUS_CONFIG_ERROR
Status value that flags that the initialisation of the
application failed because user data was false or missing.

STATUS_RUNTIME_ERROR

public static final short STATUS_RUNTIME_ERROR
Status value that flags that some runtime error occurred during start or run.

errorNumber

protected int errorNumber
If the application status is STATUS_RUNTIME_ERROR or STATUS_CONFIG_ERROR then this variable contains the xact error number.

config

protected IConfiguration config
Configuration manager that holds further DB and connection setup.

systemTicket

protected ITicket systemTicket
The ticket for system access to the context.

status

protected short status
current application status number. Possible values are:
JWebServer.STATUS_CREATEDThe application is created but not configured yet
JWebServer.STATUS_CONFIGUREDThe application is configured and ready to run.
JWebServer.STATUS_STARTINGThe application is starting.
JWebServer.STATUS_RUNNINGThe application is up and running.
JWebServer.STATUS_STOPPINGThe application is running the shutdown proecedure.
JWebServer.STATUS_STOPPEDThe application has been stopped running.
JWebServer.STATUS_CONFIG_ERRORThe application's configuration is invalid.
JWebServer.STATUS_RUNTIME_ERRORThe application encountered a fatal error during startup or run.


log

protected ILogWriter log
Log file access writer for the application.

webService

protected IWebService webService
Constructor Detail

JWarpServlet

public JWarpServlet()
Method Detail

init

public void init(org.jwarp.service.web.ServletConfig config)
          throws org.jwarp.service.web.ServletException
Servlet initialisation. Overrides the standard Servlet-init.
Performs the initialisation for JavaWeb. The following tasks are performed:
  1. Getting the INI_FILE parameter and initialising the defaultPropertyFile-property.
  2. If not available the property is set to the value of DEBUG_PROP_FILE.
  3. Creating and initialising of the log writer object stored in the logWriter-property
  4. Loading the file configuration as defined by the defaultPropertyFile-property. Here also
  5. other configuration loading mechanisms can be possible.
  6. It is checked if any JDBC drivers are provided in the App.PoolManager.Drivers-property. If so a new PoolManager is created.
  7. The action controller modules are created and loaded.
  8. A new session init object is created and initialised.

configure

public void configure(org.jdom.Element config)
               throws ConfigurationException

isDebugging

public final boolean isDebugging()
This method returns if the application actually is running in debugging mode and so printing more detailed information on errors

setDebugging

public final void setDebugging(boolean debugging)
With this method debugging mode can be switched on and off

getErrorMessage

public final java.lang.String getErrorMessage()
Get the error message of the current error (if any)
Returns:
The error message

getError

public final int getError()
Get the number of the current error (if any). Zero means no error. You can look up the message by calling getErrorMessage
Returns:
The error number

destroy

public void destroy()
Servlet destroy method. Overrides the standard Servlet destroy() method. By default if
a PoolManager object is created its release-methos its called to release all db connections.
This method does not terminate until the service count reaches zero. Not that we assume that client servicing threads will terminate at some point. If they do not, then this method will not terminate and the shutdown will require manual intervention i.e. kill process.

service

public void service(org.jwarp.service.web.HttpServletRequest req,
                    javax.servlet.http.HttpServletResponse res)
             throws org.jwarp.service.web.ServletException,
                    java.io.IOException
Servlet service method. This is the main entry-point for JavaWeb. it does the following steps:
  1. if there is a new session, it will call the sssion-init object.
  2. the HttpRequest is wrapped into a JavawebRequest which provides more flexibility
  3. it calls the dispatch-method of the supplied ActionController

reload

public void reload()
            throws NotSupportedException
Reloads the configuration file and reinitialises the PoolManager.

getConfig

public final IConfiguration getConfig()
This method returns the config object for the application configuration.

getStatus

public final short getStatus()
This method return the actual status of the application The status constants from the class are used for a more detailed description.

getAppName

public final java.lang.String getAppName()
Get the servlet name.

getMainLog

public final ILogWriter getMainLog()
Return the controllers log object

getServerData

public ServerData getServerData()

handleException

public void handleException(java.lang.Exception e,
                            WebContext c)

©   O R C A   S y s t e m s