|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectjava.lang.Thread
live.cache.CacheThread
This class starts a background thread on the server that keeps the cache updated. The cache is accessable from the live.constants.Attributes.servletContext.cache attribute of the ServletContext, and this thread is accessable from the Attributes.servletContext.cacheThread attribute. This object needs to be accessable so that the user can trigger cache updates from a refresh button.
Field Summary | |
private ServletContext |
context
|
private boolean |
continueRunning
Tells whether the thread should be running |
(package private) Exception |
exception
|
private static long |
HOURS
The number of milliseconds in an hour |
private static long |
MINUTES
The number of milliseconds in a minute |
private Date |
nextUpdate
The time the nextUpdate is scheduled for |
private static long |
SECONDS
The number of milliseconds in a second |
static long |
SLEEP_TIME_MS
This is how long the thread sleeps before waking up and checking if it is supposed to do an update. |
static long |
UPDATE_DELTA_MS
This is the number of milliseconds before the cache will automatically update. |
Fields inherited from class java.lang.Thread |
MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY |
Constructor Summary | |
CacheThread()
|
Method Summary | |
void |
contextDestroyed(ServletContextEvent event)
Called automatically when the server ends. |
void |
contextInitialized(ServletContextEvent event)
Called automatically when the server starts. |
private void |
doUpdateCache()
This function actually carries out the cache update. |
Exception |
getError()
Returns the exception thrown |
void |
run()
This function enters an infinite loop that checks for new updates for the server ever so ofter. |
void |
scheduleUpdate()
This function updates the cache. |
void |
scheduleUpdate(Date nextUpdate)
This function schedules the next cache update for the specified parameter. |
Methods inherited from class java.lang.Thread |
activeCount, checkAccess, countStackFrames, currentThread, destroy, dumpStack, enumerate, getContextClassLoader, getName, getPriority, getThreadGroup, holdsLock, interrupt, interrupted, isAlive, isDaemon, isInterrupted, join, join, join, resume, setContextClassLoader, setDaemon, setName, setPriority, sleep, sleep, start, stop, stop, suspend, toString, yield |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
private static final long SECONDS
private static final long MINUTES
private static final long HOURS
public static final long UPDATE_DELTA_MS
public static final long SLEEP_TIME_MS
private ServletContext context
private Date nextUpdate
private boolean continueRunning
Exception exception
Constructor Detail |
public CacheThread()
Method Detail |
public void run()
run
in interface Runnable
public void contextInitialized(ServletContextEvent event)
contextInitialized
in interface ServletContextListener
event
- public void contextDestroyed(ServletContextEvent event)
contextDestroyed
in interface ServletContextListener
event
- public void scheduleUpdate()
public void scheduleUpdate(Date nextUpdate)
nextUpdate
- The time to start the next cache update, within
SLEEP_TIME_MSpublic Exception getError()
private void doUpdateCache()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |