|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Object
|
+--ca.cbc.sportwire.servlet.data.DOMFile
|
+--ca.cbc.sportwire.servlet.data.JDOMFile
|
+--ca.cbc.sportwire.servlet.data.JDOMDB
JDOMDB is a JDOMFile that loads it's document via periodic updates from a database. Data results are refreshed according to a periodicity, and then cached in the global MRUCacheMap so that queries are removed from memory if no one actually accesses them, but are kept in reasonable sync with the database while they are popular.
This class is a merging of the JDOMFile and DBCacheBean, and as such, since both of those classes use the Thread run() method for different purposes, there had to be a lot of cut and paste; someday this class should be revisited to correct the inheritance issues
NOTE: This class creates a JdbcConnection db pool object and stashes it in the application-scoped ExtendedProperties to use for future calls.
Created: Sun Feb 10 15:12:05 EST 2002
| Field Summary | |
(package private) static org.apache.log4j.Category |
cat
Set up a reporting category in Log4J |
private JdbcConnections |
connectPool
|
private int |
interval
|
private boolean |
running
|
| Fields inherited from class ca.cbc.sportwire.servlet.data.JDOMFile |
builder, document, filename, saxclass, sc, xml |
| Fields inherited from interface ca.cbc.sportwire.servlet.data.DBCacheProperties |
DB_CACHE_DEFAULT_PERIOD, DB_REFRESH_PROPERTY, DBCACHE_POOL_PROPERTY, DBCACHE_TEXT_FILTER_DEFAULT, DBCACHE_TEXT_FILTER_PROPERTY |
| Fields inherited from interface ca.cbc.sportwire.servlet.data.GlobalCacheProperties |
CACHE_DEFAULT_PERIOD, CACHE_DEFAULT_TIMEOUT, CACHE_PERIOD, CACHE_TIMEOUT, MRU_PROPERTY, MRU_VAR, TTL_PROPERTY, TTL_VAR |
| Constructor Summary | |
protected |
JDOMDB(org.apache.velocity.context.Context context)
JDOMDB constructor extracts the global properties
from a Velocity page Context. |
protected |
JDOMDB(org.apache.commons.collections.ExtendedProperties sc)
constructor used withing Velocity to pre-build a query object using the default periodicities. |
protected |
JDOMDB(org.apache.commons.collections.ExtendedProperties sc,
java.lang.String query)
JDOMDB constructor to set up the connection
from the server properties and also set the query to start the
fetch. |
| Method Summary | |
void |
bump()
bump locks the object and does a notifyAll to
nudge any waiting data access methods |
protected JdbcConnections |
getConnectPool()
Get the connectPool; this class caches its XALAN connectPool |
static JDOMFile |
getInstance(org.apache.velocity.context.Context context)
getInstance attempts to fetch the matching
instance via the Velocity Context $globals
link to the TTL cache. |
static JDOMFile |
getInstance(org.apache.velocity.context.Context context,
java.lang.String sql)
getInstance gets the app config and also sets the
query in motion. |
static JDOMFile |
getInstance(org.apache.commons.collections.ExtendedProperties sc)
getInstance using the application properties
(needed for the JDBC and cache periodicity settings. |
static JDOMFile |
getInstance(org.apache.commons.collections.ExtendedProperties sc,
java.lang.String sql)
getInstance is the same as the version using the
Velocity page config, but gets the app config directly. |
java.lang.String |
getQuery()
Get the SQL query; since updates are done periodically, this must handle time-sensitive reports on the update schedule. |
protected static int |
getReloadPeriod(org.apache.commons.collections.ExtendedProperties sc)
getReloadPeriod computes the refresh period from
the properties, or sets it to the default
DB_CACHE_DEFAULT_PERIOD |
boolean |
isRunning()
Get the value of running. |
void |
run()
run implements the refresh timer; if the running
flag is true, the refresh is run, then the thread pauses for
interval seconds. |
protected void |
setConnectPool(org.apache.commons.collections.ExtendedProperties sc)
Retrieve the connectPool from the global properties, or create one and stash it if none exists. |
void |
setDocument(java.lang.String sql)
ignored because we need to setup the db connection before we start the thread |
void |
setInterval(int sec)
|
protected void |
setQuery(java.lang.String v)
Set the SQL query and begin the updates. |
void |
setResults()
Set the value of cached results by doing a database lookup using the statement; notes that a ResultSet falls out of scope with the Statement that created it so we make a copy to be used by the cache. |
void |
setRunning(boolean v)
running: can be set to false to terminate the
refresh thread. |
| Methods inherited from class ca.cbc.sportwire.servlet.data.JDOMFile |
getDocument, getFilename, getRootElement, getSaxclass, getXml, getXml, setFilename, setSaxclass, transform, transform, xpath, xpath |
| Methods inherited from class java.lang.Object |
|
| Field Detail |
static org.apache.log4j.Category cat
private JdbcConnections connectPool
private int interval
private boolean running
| Constructor Detail |
protected JDOMDB(org.apache.velocity.context.Context context)
throws java.io.IOException,
java.io.FileNotFoundException
JDOMDB constructor extracts the global properties
from a Velocity page Context.context - a Context valuejava.io.IOException - if an error occursjava.io.FileNotFoundException - is actually inherited due to bad design :(
protected JDOMDB(org.apache.commons.collections.ExtendedProperties sc)
throws java.io.IOException,
java.io.FileNotFoundException
sc - the ExtendedProperties app configjava.io.IOException - if an error occursjava.io.FileNotFoundException - is not likely, see above.
protected JDOMDB(org.apache.commons.collections.ExtendedProperties sc,
java.lang.String query)
throws java.io.IOException,
java.io.FileNotFoundException
JDOMDB constructor to set up the connection
from the server properties and also set the query to start the
fetch.sc - the ExtendedProperties app configquery - a String SQL statement.java.io.IOException - if an error occursjava.io.FileNotFoundException - | Method Detail |
protected JdbcConnections getConnectPool()
protected void setConnectPool(org.apache.commons.collections.ExtendedProperties sc)
sc - the ExtendedProperties app configpublic java.lang.String getQuery()
protected void setQuery(java.lang.String v)
v - String value of the SQL query.protected static int getReloadPeriod(org.apache.commons.collections.ExtendedProperties sc)
getReloadPeriod computes the refresh period from
the properties, or sets it to the default
DB_CACHE_DEFAULT_PERIODsc - an ExtendedProperties valueint value
public static JDOMFile getInstance(org.apache.velocity.context.Context context)
throws java.io.IOException,
java.io.FileNotFoundException
getInstance attempts to fetch the matching
instance via the Velocity Context $globals
link to the TTL cache.context - the Velocity page ContextJDOMFile valuejava.io.IOException - if an error occursjava.io.FileNotFoundException - if an error occurs
public static JDOMFile getInstance(org.apache.velocity.context.Context context,
java.lang.String sql)
throws java.io.IOException,
java.io.FileNotFoundException
getInstance gets the app config and also sets the
query in motion.context - a Velocity page Contextsql - a String SQL statementJDOMDB valuejava.io.IOException - if an error occursjava.io.FileNotFoundException - if an error occurs
public static JDOMFile getInstance(org.apache.commons.collections.ExtendedProperties sc)
throws java.io.IOException,
java.io.FileNotFoundException
getInstance using the application properties
(needed for the JDBC and cache periodicity settings.sc - an ExtendedProperties valueJDOMDB valuejava.io.IOException - if an error occursjava.io.FileNotFoundException - if an error occurs
public static JDOMFile getInstance(org.apache.commons.collections.ExtendedProperties sc,
java.lang.String sql)
throws java.io.IOException,
java.io.FileNotFoundException
getInstance is the same as the version using the
Velocity page config, but gets the app config directly. This
is used in pre-loading SQL beans specified in the
sportpage.conf file.sc - the ExtendedProperties app configsql - a String SQL statementJDOMDB valuejava.io.IOException - if an error occursjava.io.FileNotFoundException - if an error occurspublic void setDocument(java.lang.String sql)
setDocument in class JDOMFileca.cbc.sportwire.servlet.data.JDOMFilefilename - a String valuejava.io.FileNotFoundException - if an error occursjava.io.IOException - if an error occurspublic void setInterval(int sec)
public boolean isRunning()
isRunning in interface Stoppablepublic void setRunning(boolean v)
running: can be set to false to terminate the
refresh thread.setRunning in interface Stoppablev - Value to assign to running.public void bump()
bump locks the object and does a notifyAll to
nudge any waiting data access methodspublic void run()
run implements the refresh timer; if the running
flag is true, the refresh is run, then the thread pauses for
interval seconds.run in class JDOMFilepublic void setResults()
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
Javadocs generated Tue Apr 23 01:08:36 EDT 2002 by garym@maya.dyndns.org
Copyright © 2002 Canadian Broadcasting Corp