com.waveset.object
Class ChangeWatcher

java.lang.Object
  extended bycom.waveset.object.ChangeWatcher
All Implemented Interfaces:
CacheConsistencyNumberLoader, WavesetProperties.Listener

public class ChangeWatcher
extends java.lang.Object
implements WavesetProperties.Listener, CacheConsistencyNumberLoader

An object that periodically checks for changes in the repository by polling the "last modification counter" for types. The results are cached so we don't poll all the time, a set of parameters controls the frequency of the polling, which can be adjusted dynamically.

You normally have only one of these. Nothing prevents you from having more than one, but if you do you will be hitting the repository more often.


Field Summary
static java.lang.String code_id
           
 
Constructor Summary
ChangeWatcher(CacheConsistencyNumberLoader loader)
           
 
Method Summary
 void bumpCacheConsistencyNumber(Type type)
          Can be called to explicitly increment the cache consistency number.
 long getCacheConsistencyNumber(Type type)
          Get the cache consistency number currently in effect.
static void println(java.lang.String msg)
           
 void propertiesFileChanged()
           
 void setTrace(boolean b)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

code_id

public static final java.lang.String code_id
See Also:
Constant Field Values
Constructor Detail

ChangeWatcher

public ChangeWatcher(CacheConsistencyNumberLoader loader)
Method Detail

setTrace

public void setTrace(boolean b)

println

public static void println(java.lang.String msg)

getCacheConsistencyNumber

public long getCacheConsistencyNumber(Type type)
                               throws WavesetException
Get the cache consistency number currently in effect. We cache this for some number of seconds, then query the repository for a new one.

Note that this isn't synchronized so we make the usual case fast, all the update logic has been pushed down to queryCacheConsistencyNumber.

Specified by:
getCacheConsistencyNumber in interface CacheConsistencyNumberLoader
Throws:
WavesetException

bumpCacheConsistencyNumber

public void bumpCacheConsistencyNumber(Type type)
Can be called to explicitly increment the cache consistency number. Used in lieu of a repository query to force the caches to be reloaded. This is a temporary solution, until we can implement a persistent mechanism. The LocalSession is expected to call this whenever something is checked in.

Since we now check consistency for each type, we have to increment all the type numbers. This will go away eventually...


propertiesFileChanged

public void propertiesFileChanged()
Specified by:
propertiesFileChanged in interface WavesetProperties.Listener