ca.cbc.sportwire.xmldbms
Class MapServer

java.lang.Object
  |
  +--ca.cbc.sportwire.xmldbms.MapServer
All Implemented Interfaces:
WireFeederProperties

public class MapServer
extends java.lang.Object
implements WireFeederProperties

MapServer.java: keeps a cache of the current Map files. Maps are loaded and compiled as needed, and recompiled if the source file changes. Map files are located under the same path as the DocType SystemID (dtd) relative to MAP_PATH_PROPERTY.

NOTE: The map server requires a database connection.

Created: Mon Nov 19 14:02:33 2001
 $Log: MapServer.java,v $
 Revision 1.10  2002/04/05 21:35:10  garym
 implement config option paths for xsl and map files

 Revision 1.9  2002/03/04 03:37:31  garym
 Implement the basic ESPN tables

 Revision 1.8  2002/02/27 03:57:21  garym
 Added support for the more interesting sportwire DTDs

 Revision 1.7  2002/02/26 18:53:28  garym
 Added support for ESPN Schedule DTD

 Revision 1.6  2002/02/06 20:50:15  garym
 parses AFP hockey events into PostgreSQL

 Revision 1.5  2002/02/04 20:50:37  garym
 Sync'd feeder to SportPage properties model

 Revision 1.4  2001/11/27 06:58:27  garym
 Added support for schedule and event messages; by-passed Map re-use in MapServer

 Revision 1.3  2001/11/26 20:19:26  garym
 Stores OLDTEXT unless the text field is too long

 Revision 1.2  2001/11/21 05:35:35  garym
 Fixed race conditions in singletons; implement different Map hack

 Revision 1.1  2001/11/20 18:36:55  garym
 Added connection pools to the MapServer


 

Version:
$Id: MapServer.java,v 1.10 2002/04/05 21:35:10 garym Exp $
Author:
Gary Lawrence Murphy

Inner Class Summary
(package private)  class MapServer.MapInfo
           
 
Field Summary
private  java.util.Set active
           
private  java.util.Map cache
           
(package private) static org.apache.log4j.Category cat
          Set up a reporting category in Log4J
private  org.apache.commons.collections.ExtendedProperties config
           
private static MapServer instance
           
 
Fields inherited from interface ca.cbc.sportwire.WireFeederProperties
CONFIGFILE_DEFAULT, CONFIGFILE_PROPERTY, DEFAULT_FILENAME_XPATH, DEFAULT_SAX_DRIVER_CLASS, DEFAULT_XML_PATH, DEFAULT_XMLRPC_PORT, DOCHANDLER_DEFAULT, DOCHANDLER_PROPERTY, DOCWORKERS_DEFAULT, DOCWORKERS_PROPERTY, DTD_PATH_PROPERTY, FEED_REGEX_PROPERTY, FEEDCLASS_DEFAULT, FEEDCLASS_PROPERTY, FEEDFILTER_DEFAULT, FEEDFILTER_PROPERTY, FILENAME_XPATH_PROPERTY, IGNOREFILE_PROPERTY, LOGFILE_DEFAULT, LOGFILE_PROPERTY, MAP_PATH_PROPERTY, SAX_CLASS_PROPERTY, WATCHDOG_IDLE_DEFAULT, WATCHDOG_IDLE_PROPERTY, XML_PATH_PROPERTY, XMLRPC_PORT_PROPERTY, XSL_PATH_PROPERTY
 
Constructor Summary
private MapServer(org.apache.commons.collections.ExtendedProperties config)
           
 
Method Summary
 org.apache.commons.collections.ExtendedProperties getConfig()
          Get the value of config.
static MapServer getInstance(org.apache.commons.collections.ExtendedProperties config)
          getInstance:
 de.tudarmstadt.ito.xmldbms.Map getMap(java.lang.String systemId)
          getMap: lookup the SystemID string and return the corresponding Map file.
static java.io.File publicToMapFile(org.apache.commons.collections.ExtendedProperties conf, java.lang.String systemId)
          publicToMapFile: translate the fully qualified publicID into a MapFile path; for the present purposes, the publidID is a local file path ending in .dtd and are mapped to the same location with the suffix .map
 void releaseMap(de.tudarmstadt.ito.xmldbms.Map m)
           
 void setConfig(org.apache.commons.collections.ExtendedProperties v)
          Set the value of config.
 
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
Set up a reporting category in Log4J

instance

private static MapServer instance

cache

private java.util.Map cache

active

private java.util.Set active

config

private org.apache.commons.collections.ExtendedProperties config
Constructor Detail

MapServer

private MapServer(org.apache.commons.collections.ExtendedProperties config)
Method Detail

getConfig

public org.apache.commons.collections.ExtendedProperties getConfig()
Get the value of config.
Returns:
ExtendedProperties value of config.

setConfig

public void setConfig(org.apache.commons.collections.ExtendedProperties v)
Set the value of config.
Parameters:
v - Value to assign to config.

getInstance

public static MapServer getInstance(org.apache.commons.collections.ExtendedProperties config)
getInstance:
Returns:
a MapServer value

publicToMapFile

public static java.io.File publicToMapFile(org.apache.commons.collections.ExtendedProperties conf,
                                           java.lang.String systemId)
                                    throws java.io.FileNotFoundException
publicToMapFile: translate the fully qualified publicID into a MapFile path; for the present purposes, the publidID is a local file path ending in .dtd and are mapped to the same location with the suffix .map
Parameters:
systemId - a String value
Returns:
a File object describing the map file
Throws:
java.io.FileNotFoundException - if any serious error occurs

getMap

public de.tudarmstadt.ito.xmldbms.Map getMap(java.lang.String systemId)
                                      throws java.io.FileNotFoundException,
                                             java.sql.SQLException,
                                             java.lang.Exception
getMap: lookup the SystemID string and return the corresponding Map file. This caches the compiled map files, recompiling those with datestamps later than the cached map. This method is synchronized to prevent multiple pending first-requests for the same systemId. Returned Maps are added to the active list; when requesting a map, this method will wait until any previous request for that map is unblocked with releaseMap(). Returned Maps will have a working Connection that is closed when the map is released.
Parameters:
systemId - a String value
Returns:
a Map value
Throws:
java.sql.SQLException - if no connection to database
java.io.FileNotFoundException - if an error occurs

releaseMap

public void releaseMap(de.tudarmstadt.ito.xmldbms.Map m)