ca.cbc.sportwire.servlet.pagehandlers
Class BasicPageHandler

java.lang.Object
  |
  +--ca.cbc.sportwire.servlet.pagehandlers.BasicPageHandler
All Implemented Interfaces:
PageHandler, SportPageProperties

public class BasicPageHandler
extends java.lang.Object
implements PageHandler, SportPageProperties

BasicPageHandler: sets up the basic environment of the SportPage templates, defining several context variables but otherwise doing nothing at all. This class was needed to implement topics where the pathinfo indicates a database request rather than a physical page.

Created: Tue Jan 8 17:02:02 2002
 $Log: BasicPageHandler.java,v $
 Revision 1.8  2002/02/11 20:57:21  garym
 added JDOMDB to return XML from database queries

 Revision 1.7  2002/01/29 21:08:02  garym
 beans now loaded after topic context is built

 Revision 1.6  2002/01/29 19:33:45  garym
 fixed concurrency bug with global config

 Revision 1.5  2002/01/26 06:46:29  garym
 authorization bug in lineups

 Revision 1.4  2002/01/24 19:50:20  garym
 Major restructuring of beans and pagehandlers

 Revision 1.3  2002/01/16 23:09:24  garym
 Implemented the JDBC pool support and sql property beans

 Revision 1.2  2002/01/14 21:51:46  garym
 bug fixes in topics and config files migration to Extended Properties

 Revision 1.1  2002/01/09 04:28:59  garym
 Added test unit stubs and new News support


 

Version:
$Id: BasicPageHandler.java,v 1.8 2002/02/11 20:57:21 garym Exp $
Author:
Gary Lawrence Murphy

Field Summary
private static PageHandler _instance
           
(package private) static org.apache.log4j.Category cat
           
protected  java.lang.String handler
          topic: variable
 
Fields inherited from interface ca.cbc.sportwire.servlet.data.SportPageProperties
BEAN_SUFFIX, BEANFACTORY_VAR, CONTEXT_VAR, DATE_VAR, DEFAULT_EXTS, DEFAULT_INDEXES, DEFAULT_PAGE_SUFFIX, DEFAULT_SAX_DRIVER_CLASS, DEFAULT_TIMEZONE, DEFAULT_TOPIC, DOM_VAR, ERROR_TEMPLATE_VAR, EXCEPTION_VAR, EXTENSIONS_VAR, FALSE, GLOBAL_VAR, HOME_PROPERTY, INCLUDE_EXTS_PROPERTY, INCLUDE_VAR, INDEX_INDICATOR_VAR, INDEX_TEMPLATE_VAR, LAYOUT_TEMPLATE_VAR, MACRO_LIB_PROPERTY, MISSING_TEMPLATE_VAR, OUTPUT_VAR, PAGE_EXPIRE, PAGE_TEMPLATE_VAR, PANIC_404_PAGE, PANIC_404_PROPERTY, PANIC_500_PAGE, PANIC_500_PROPERTY, PARAM_PARSER_VAR, PATH_VAR, REQUEST_VAR, RESPONSE_VAR, SAX_CLASS_PROPERTY, SERVLET_DEBUG, SERVLET_LOGCONF_PROPERTY, SQL_SUFFIX, TEMPLATE_PATHS_PROPERTY, TIMEZONE_PROPERTY, TRUE, URI_VAR, VELOCITY_LOGFILE_DEFAULT, VELOCITY_LOGFILE_PROPERTY, XML_EXTS, XML_EXTS_PROPERTY, XML_PATHS_PROPERTY, XML_SUFFIX, XSL_EXTS, XSL_EXTS_PROPERTY, XSL_PATHS_PROPERTY
 
Constructor Summary
protected BasicPageHandler()
          BasicPageHandler constructor
 
Method Summary
private static java.util.List getExts(org.apache.velocity.context.Context context)
           
private static java.lang.String getIndexPage(java.lang.String base, org.apache.velocity.context.Context context)
           
static PageHandler getInstance()
          getInstance: returns the singleton -- each page handler subclass must implement this
protected  void setProperties(org.apache.commons.collections.ExtendedProperties sc, java.lang.String topic, org.apache.velocity.context.Context context)
          setProperties adds the values for the topic.* properties; these should define the "layout" template and its components, for example: layout=default/layout.vm banner=default/banner.vm altheader=default/altheader.vm page=default/news.vm sidebar=default/side.vm missingpage=default/side.vm errorpage=default/side.vm The 404 and 500 properties are used in the SportPageServlet to set the template layout file when the template fails to parse due to file-not-found or other server error.
protected static void setProxyCaching(org.apache.velocity.context.Context context)
          setProxyCaching: inserts cache-busting headers compatible with a wide range of proxy servers; must be used before any out.println statements - not used by the DefaultPageHandler, but available for any subclasses to use.
protected static void setProxyCaching(org.apache.velocity.context.Context context, int sec)
          setProxyCaching:
protected  void setTopic(org.apache.commons.collections.ExtendedProperties sc, java.lang.String pathinfo, org.apache.velocity.context.Context context)
          setTopic: loads the properties for default.* and then loads the properties for the topic.* moving up the pathinfo so that deeper topics can subclass.
 void setupPage(org.apache.commons.collections.ExtendedProperties sc, java.lang.String pathinfo, org.apache.velocity.context.Context context)
          setupPage: -- NOTE: This means a PageHandler class extending a class extending this one cannot get at the property changes made by the middle class! This was done because DOMPageHandler had to set the $page to $index, so the BioPageHandler could not then set it's own default page template after the super.setupPage; alternative implementations are welcome.
protected  void setVariable(java.lang.String var, java.lang.Object value, org.apache.velocity.context.Context context)
          setVariable adds the item to the context, trapping vars that end with specific suffixes, for example, .bean becomes a javabean, .sql becomes a DBCacheBean and .xml becomes a DOMFile
 void trapDirectories(org.apache.commons.collections.ExtendedProperties sc, java.lang.String pathinfo, org.apache.velocity.context.Context context)
          trapDirectories: detect directory pathinfo and if so, set the INDEX_INDICATOR true and set the index page template
 
Methods inherited from class java.lang.Object
, clone, equals, finalize, getClass, hashCode, notify, notifyAll, registerNatives, toString, wait, wait, wait
 

Field Detail

cat

static org.apache.log4j.Category cat

_instance

private static PageHandler _instance

handler

protected java.lang.String handler
topic: variable
Constructor Detail

BasicPageHandler

protected BasicPageHandler()
BasicPageHandler constructor
Method Detail

getInstance

public static PageHandler getInstance()
getInstance: returns the singleton -- each page handler subclass must implement this
Returns:
the PageHandler value

setVariable

protected void setVariable(java.lang.String var,
                           java.lang.Object value,
                           org.apache.velocity.context.Context context)
setVariable adds the item to the context, trapping vars that end with specific suffixes, for example, .bean becomes a javabean, .sql becomes a DBCacheBean and .xml becomes a DOMFile
Parameters:
var - a String variable name
value - an Object value
context - a Velocity session Context

setProperties

protected void setProperties(org.apache.commons.collections.ExtendedProperties sc,
                             java.lang.String topic,
                             org.apache.velocity.context.Context context)
setProperties adds the values for the topic.* properties; these should define the "layout" template and its components, for example: The 404 and 500 properties are used in the SportPageServlet to set the template layout file when the template fails to parse due to file-not-found or other server error.
Parameters:
sc - the ExtendedProperties server config
topic - a String of dot-delimited tokens
context - a Velocity Context map

setTopic

protected void setTopic(org.apache.commons.collections.ExtendedProperties sc,
                        java.lang.String pathinfo,
                        org.apache.velocity.context.Context context)
setTopic: loads the properties for default.* and then loads the properties for the topic.* moving up the pathinfo so that deeper topics can subclass.
Parameters:
sc - the ExtendedProperties server config
pathinfo - a String value
context - a Context value

setProxyCaching

protected static void setProxyCaching(org.apache.velocity.context.Context context)
setProxyCaching: inserts cache-busting headers compatible with a wide range of proxy servers; must be used before any out.println statements - not used by the DefaultPageHandler, but available for any subclasses to use.
Parameters:
context - a Context value

setProxyCaching

protected static void setProxyCaching(org.apache.velocity.context.Context context,
                                      int sec)
setProxyCaching:
Parameters:
context - a Context value
sec - an int value

getExts

private static java.util.List getExts(org.apache.velocity.context.Context context)

getIndexPage

private static java.lang.String getIndexPage(java.lang.String base,
                                             org.apache.velocity.context.Context context)

trapDirectories

public void trapDirectories(org.apache.commons.collections.ExtendedProperties sc,
                            java.lang.String pathinfo,
                            org.apache.velocity.context.Context context)
trapDirectories: detect directory pathinfo and if so, set the INDEX_INDICATOR true and set the index page template
Parameters:
pathinfo - a String value
context - a Context value

setupPage

public void setupPage(org.apache.commons.collections.ExtendedProperties sc,
                      java.lang.String pathinfo,
                      org.apache.velocity.context.Context context)
setupPage: -- NOTE: This means a PageHandler class extending a class extending this one cannot get at the property changes made by the middle class! This was done because DOMPageHandler had to set the $page to $index, so the BioPageHandler could not then set it's own default page template after the super.setupPage; alternative implementations are welcome.
Specified by:
setupPage in interface PageHandler
Parameters:
sc - a Properties value
pathinfo - a String value
context - a Context value