|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--java.lang.Thread | +--ca.cbc.sportwire.util.PeriodicData
PeriodicData.java: Base class for all periodically
refreshed or expired data times. These objects have a timer thread
which will invoke a refresh()
method to rebuild or
re-populate the object state.
This might be easier with the java.util.TimerTask class, except that we needed a means to free unscheduled events and there's no mention in the TimerTask pages if the cancel actually deletes the object; we'll leave this as an exercise for later.
Created: Wed Jan 2 13:37:13 2002$Log: PeriodicData.java,v $ Revision 1.8 2002/02/13 19:18:08 garym fixed postgres workaround on numeric Revision 1.7 2002/02/11 07:09:25 garym TTL will now test for Stoppable instead of Periodic Revision 1.6 2002/01/24 19:49:25 garym added path search and debug statements Revision 1.5 2002/01/18 03:09:28 garym Extended unit tests for TTLCacheMap; implemented email unit test reports Revision 1.4 2002/01/16 23:09:25 garym Implemented the JDBC pool support and sql property beans Revision 1.3 2002/01/15 08:28:50 garym implemented MRU cache for the JDOMFile objects 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/04 18:37:20 garym PeriodicData moved into sportwire.util package Revision 1.1 2002/01/03 03:36:25 garym Abstracted periodic-refresh data cache objects
Field Summary | |
(package private) static org.apache.log4j.Category |
cat
Set up a reporting category in Log4J |
private int |
interval
|
private boolean |
running
|
Fields inherited from class java.lang.Thread |
contextClassLoader, daemon, eetop, group, inheritableThreadLocals, inheritedAccessControlContext, MAX_PRIORITY, MIN_PRIORITY, name, NORM_PRIORITY, priority, single_step, stillborn, stopThreadPermission, target, threadInitNumber, threadLocals, threadQ, userDaemon |
Constructor Summary | |
PeriodicData()
PeriodicData base constructor does nothing. |
|
PeriodicData(int seconds)
PeriodicData constructor accepting the interval as
an integer seconds value |
|
PeriodicData(java.lang.String secProp)
PeriodicData constructor requires the string
representation of the refresh rate; the refresh rate is
typically provided by calling this constructor from a subclass
with the refresh taken from a properties object such as
super( properties.getProperty("refresh.sec",
"30") . |
Method Summary | |
void |
bump()
bump : can be used to nudge any waiting access
methods. |
boolean |
isRunning()
Detect if the object is still live. |
protected abstract void |
refresh()
refresh : abstract method invoked by the timer. |
void |
run()
run implements the refresh timer; if the running
flag is true, the refresh is run, then the thread pauses for
interval seconds. |
void |
setInterval(int sec)
setInterval : set the refresh interval for the
periodic data item. |
void |
setRunning(boolean v)
setRunning : can be set to
false to terminate the thread. |
Methods inherited from class java.lang.Thread |
|
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
static org.apache.log4j.Category cat
private int interval
private boolean running
Constructor Detail |
public PeriodicData()
PeriodicData
base constructor does nothing.public PeriodicData(java.lang.String secProp)
PeriodicData
constructor requires the string
representation of the refresh rate; the refresh rate is
typically provided by calling this constructor from a subclass
with the refresh taken from a properties object such as
super( properties.getProperty("refresh.sec",
"30")
. Note: the constructor does not
start the thread method. This allows subclasses to do more
setup before the first refresh is called.secProp
- a String
valuepublic PeriodicData(int seconds)
PeriodicData
constructor accepting the interval as
an integer seconds valueseconds
- an int
valueMethod Detail |
protected abstract void refresh()
refresh
: abstract method invoked by the timer.public void setInterval(int sec)
setInterval
: set the refresh interval for the
periodic data item.sec
- an int
valuepublic boolean isRunning()
isRunning
in interface Stoppable
public void setRunning(boolean v)
setRunning
: can be set to
false to terminate the thread.setRunning
in interface Stoppable
v
- Value to assign to running.public void bump()
bump
: can be used to nudge any waiting access
methods. just locks the object and calls notifyAll()public 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 java.lang.Thread
|
||||||||||
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