com.boylesoftware.cb2.presentation.servlet
Class CB2Application

java.lang.Object
  extended bycom.boylesoftware.cb2.presentation.servlet.CB2Application
All Implemented Interfaces:
StatusProvider

public final class CB2Application
extends java.lang.Object
implements StatusProvider

This web-application wide singleton represents this CB2 based application. When you use Struts modules you may end up with setting up CB2 plugin multiple times and then the plugin will install it's request processor (ControllerServlet) multiple times for different modules. Regardless of how many modules and CB2 request processors you have they all will share one CB2Application instance, which will provide them with access to the application context and business logic level.

This class is not of any interest to the user application code.

Version:
$Id: CB2Application.java,v 1.6 2004/04/30 18:54:08 levahim Exp $
Author:
Lev Himmelfarb

Field Summary
 
Fields inherited from interface com.boylesoftware.cb2.StatusProvider
TIMESTAMP_FORMAT
 
Method Summary
 ApplicationContext getApplicationContext()
          Gets our application context.
 BLManager getBLManager()
          Gets our business logic level manager.
 EventStatistics getEventStats(java.lang.String eventName)
          Interface method implementation.
 int getNumberOfErrors()
          Gets the number of registered errors in all user sessions.
 int getNumberOfSessions()
          Gets number of currently registered user sessions.
 byte[] getStats()
          Retrieves information about the servlet container and user sessions and returns it as an XML text.
 boolean isLocked()
          Tells if the application is locked by a setLock call.
 void setLock(boolean lock)
          Sets the application "locked" status.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

getApplicationContext

public ApplicationContext getApplicationContext()
Gets our application context.

Returns:
reference to our application context.

getBLManager

public BLManager getBLManager()
Gets our business logic level manager.

Returns:
reference to out BL manager.

getStats

public byte[] getStats()
                throws java.io.UnsupportedEncodingException
Retrieves information about the servlet container and user sessions and returns it as an XML text.

Specified by:
getStats in interface StatusProvider
Returns:
XML for the servlet container and user sessions info.
Throws:
java.io.UnsupportedEncodingException - if UTF-8 is not supported on this platform, which is practically impossible.

getEventStats

public EventStatistics getEventStats(java.lang.String eventName)
Interface method implementation. Accepts the following event names:

Specified by:
getEventStats in interface StatusProvider
Parameters:
eventName - implementation specific event name, for which current statistics are requested.
Returns:
statistics information for the specified event or null if the event is unknown.

isLocked

public boolean isLocked()
Tells if the application is locked by a setLock call.

Returns:
true if the application is locked.

setLock

public void setLock(boolean lock)
Sets the application "locked" status. When the application is locked the request processor does not let any requests into actions, instead it immediately sends a Service Unavailable error code back to the browser (or alternatively forwards to the configured by lockedUrl CB2 plugin property page).

Parameters:
lock - the new lock state -- true locks the application, false unlocks it.

getNumberOfSessions

public int getNumberOfSessions()
Gets number of currently registered user sessions. This method can be used for statistics reports.

Returns:
number of sessions.

getNumberOfErrors

public int getNumberOfErrors()
Gets the number of registered errors in all user sessions. This method can be used for statistics reports.

Returns:
total number of errors in all sessions.


Copyright © 2002,2003,2004 - Boyle Software, Inc.