org.deegree_impl.tools
Class Cache_Impl

java.lang.Object
  extended byjava.util.TimerTask
      extended byorg.deegree_impl.tools.Cache_Impl
All Implemented Interfaces:
Cache, java.lang.Runnable
Direct Known Subclasses:
WMSCache

public class Cache_Impl
extends java.util.TimerTask
implements Cache

This class provides a cache for feature collections created by the wms filter services.

-----------------------------------------------------

Author:
Andreas Poth

Field Summary
protected  java.util.Map data
           
protected  java.util.Map lastCallTime
           
private  int maxCacheSize
           
private  int maxLifeTime
           
private  int updateInterval
           
 
Fields inherited from class java.util.TimerTask
 
Constructor Summary
Cache_Impl()
           
Cache_Impl(int maxEntries)
           
Cache_Impl(int maxEntries, int maxLifeTime)
           
 
Method Summary
 void clear()
          removes all entries from the cache
protected  java.lang.Object deleteOldest()
          removes the feature collection from the cache that hasn't been called for the longest time.
 java.lang.Object get(java.lang.Object identifier)
          gets an entry from the cache.
 int getCurrentSize()
          returns the actual amount of entries within the cache
 int getMaxEntries()
          returns the number of entries maximal allowed within the cache
 int getMaxLifeTime()
          returns the maximal time a feature collection is stored within the cache without being called
 int getUpdateInterval()
          returns the time interval the internal thread is looking for feature collection that exeeds the max life time
 void push(java.lang.Object identifier, java.lang.Object data)
          pushes a new entry to the cache.
 java.lang.Object remove(java.lang.Object identifier)
          removes an entry from the cache.
 void run()
           
 void setMaxEntries(int maxCacheSize)
          sets the maximal number of objects that will be stored within the cache.
 void setMaxLifeTime(int maxLifeTime)
          sets the maximal time a feature collection is stored within the cache without being called
 void setUpdateInterval(int updateInterval)
          sets the time interval the internal thread is looking for feature collection that exeeds the max life time
 java.lang.String toString()
           
 
Methods inherited from class java.util.TimerTask
cancel, scheduledExecutionTime
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

data

protected java.util.Map data

lastCallTime

protected java.util.Map lastCallTime

maxLifeTime

private int maxLifeTime

updateInterval

private int updateInterval

maxCacheSize

private int maxCacheSize
Constructor Detail

Cache_Impl

public Cache_Impl()

Cache_Impl

public Cache_Impl(int maxEntries)

Cache_Impl

public Cache_Impl(int maxEntries,
                  int maxLifeTime)
Method Detail

get

public java.lang.Object get(java.lang.Object identifier)
gets an entry from the cache. The entry that shall be returned will be identified by the submitted identifier. If no entry for a submitted identifier can be found within the cache the method shall return null.

Specified by:
get in interface Cache

push

public void push(java.lang.Object identifier,
                 java.lang.Object data)
pushes a new entry to the cache. Each entry is marked by an unique identifier

Specified by:
push in interface Cache

deleteOldest

protected java.lang.Object deleteOldest()
removes the feature collection from the cache that hasn't been called for the longest time.


getCurrentSize

public int getCurrentSize()
returns the actual amount of entries within the cache

Specified by:
getCurrentSize in interface Cache

getMaxLifeTime

public int getMaxLifeTime()
returns the maximal time a feature collection is stored within the cache without being called

Specified by:
getMaxLifeTime in interface Cache

setMaxLifeTime

public void setMaxLifeTime(int maxLifeTime)
sets the maximal time a feature collection is stored within the cache without being called

Specified by:
setMaxLifeTime in interface Cache

getUpdateInterval

public int getUpdateInterval()
returns the time interval the internal thread is looking for feature collection that exeeds the max life time


setUpdateInterval

public void setUpdateInterval(int updateInterval)
sets the time interval the internal thread is looking for feature collection that exeeds the max life time


getMaxEntries

public int getMaxEntries()
returns the number of entries maximal allowed within the cache

Specified by:
getMaxEntries in interface Cache

setMaxEntries

public void setMaxEntries(int maxCacheSize)
sets the maximal number of objects that will be stored within the cache. Is the cache if completly filled and a new object shall be added the object that hasn't been called for the longest time will be removed.

Specified by:
setMaxEntries in interface Cache

clear

public void clear()
removes all entries from the cache

Specified by:
clear in interface Cache

remove

public java.lang.Object remove(java.lang.Object identifier)
removes an entry from the cache. The entry that shall be removed will be identified by the submitted identifier. The removed entry will be returned. If no entry for a submitted identifier can be found within the cache the method shall return null.

Specified by:
remove in interface Cache

toString

public java.lang.String toString()

run

public void run()
Specified by:
run in interface java.lang.Runnable