org.jasig.portal.tools.checks
Class CheckingContextListener

java.lang.Object
  extended by org.jasig.portal.tools.checks.CheckingContextListener
All Implemented Interfaces:
java.util.EventListener, javax.servlet.ServletContextListener

public class CheckingContextListener
extends java.lang.Object
implements javax.servlet.ServletContextListener

This context listener executes SafeDelegatingCheckRunner, logs its results, and exposes its results in the ServletContext. The intent is that the ICheckRunner delegate of SafeDelegatingCheckRunner, configured in Spring, be configured to run useful runtime sanity checks that will help uPortal deployers to understand what went wrong in their deployments when dependencies are not present. The current implementation logs successes only via Commons Logging whereas it logs failures via Commons Logging and via the Servlet API's logging mechanism and to System.err. This overkill of logging is intended to give the primary intended audience -- new uPortal deployers who may not yet be comfortable with configuring uPortal logging -- the maximum chance of encountering the output. The intent is that in a healthy happy production uPortal deployment, no checks will fail and so this overkill of logging won't be a problem. Subclassing this class: this class is designed to be subclassed to replace the implementation of the method that logs the results from the SafeDelegatingCheckRunner. In this way you can implement some other logging strategy.

Since:
uPortal 2.5
Version:
$Revision: 1.3 $ $Date: 2005/05/20 01:49:22 $

Field Summary
protected  org.apache.commons.logging.Log log
           
static java.lang.String RESULTS_SC_KEY
          The name of the servlet context attribute which this listener will set at context initialization to contain the List of CheckAndResult instances representing the results of running the configured checks.
 
Constructor Summary
CheckingContextListener()
           
 
Method Summary
 void contextDestroyed(javax.servlet.ServletContextEvent sce)
           
 void contextInitialized(javax.servlet.ServletContextEvent sce)
           
protected  void logResults(java.util.List results, javax.servlet.ServletContext servletContext)
          Log the results reported by the check runner.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

RESULTS_SC_KEY

public static final java.lang.String RESULTS_SC_KEY
The name of the servlet context attribute which this listener will set at context initialization to contain the List of CheckAndResult instances representing the results of running the configured checks.

See Also:
Constant Field Values

log

protected final org.apache.commons.logging.Log log
Constructor Detail

CheckingContextListener

public CheckingContextListener()
Method Detail

contextInitialized

public final void contextInitialized(javax.servlet.ServletContextEvent sce)
Specified by:
contextInitialized in interface javax.servlet.ServletContextListener

contextDestroyed

public void contextDestroyed(javax.servlet.ServletContextEvent sce)
Specified by:
contextDestroyed in interface javax.servlet.ServletContextListener

logResults

protected void logResults(java.util.List results,
                          javax.servlet.ServletContext servletContext)
Log the results reported by the check runner. You can subclass this class and override this method to change the logging behavior. You can also, by overriding this method and throwing a RuntimeException, veto the loading of the context. The default implementation of this method is safe such that it will not throw. Since the rest of contextInitialized is also safe, the default implementation of this ContextListener is safe and will not, no matter how abjectly the checks fail, itself abort the context initialization.

Parameters:
results - List of CheckAndResult instances
servletContext - the context in which we're running