org.glite.security.voms.database.cache
Class TimedCacheable

java.lang.Object
  extended byorg.glite.security.voms.database.cache.TimedCacheable
All Implemented Interfaces:
Cacheable, java.lang.Cloneable
Direct Known Subclasses:
DBACL

public abstract class TimedCacheable
extends java.lang.Object
implements Cacheable

Utility class to help creating Cacheables which should be periodically refreshed from the database.

Author:
Karoly Lorentey
See Also:
RowCache

Constructor Summary
protected TimedCacheable()
          Create a new TimedCacheable instance with the default refresh period.
protected TimedCacheable(long period)
          Create a new TimedCacheable instance with the specified refresh period.
 
Method Summary
 java.lang.Object clone()
          Return a copy of this instance.
abstract  java.lang.Object[] getKeys()
          Return the keys that are used to refer to this instance in RowCache.
 boolean needsRefresh()
          Returns true if the configured amount of time has elapsed since the last refresh.
 void refresh()
          Flags this Cacheable as uptodate.
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

TimedCacheable

protected TimedCacheable(long period)
Create a new TimedCacheable instance with the specified refresh period. If the period is zero, then the instance will be refreshed every time it is retrieved from the cache. If it is -1, then it will never be refreshed after the first refresh.


TimedCacheable

protected TimedCacheable()
Create a new TimedCacheable instance with the default refresh period.

Method Detail

needsRefresh

public boolean needsRefresh()
Returns true if the configured amount of time has elapsed since the last refresh.

Specified by:
needsRefresh in interface Cacheable

refresh

public void refresh()
             throws GeneralDatabaseException
Flags this Cacheable as uptodate. All refresh() overrides in derived classes must call TimedCacheable.refresh() to update the timestamp.

Specified by:
refresh in interface Cacheable
Throws:
GeneralDatabaseException

getKeys

public abstract java.lang.Object[] getKeys()
Description copied from interface: Cacheable
Return the keys that are used to refer to this instance in RowCache.

Specified by:
getKeys in interface Cacheable

clone

public java.lang.Object clone()
Description copied from interface: Cacheable
Return a copy of this instance. The copy must not share mutable data with the original instance.

Specified by:
clone in interface Cacheable