org.apache.fulcrum.cache.impl
Class EHCacheService

java.lang.Object
  extended by org.apache.avalon.framework.logger.AbstractLogEnabled
      extended by org.apache.fulcrum.cache.impl.EHCacheService
All Implemented Interfaces:
Runnable, org.apache.avalon.framework.activity.Disposable, org.apache.avalon.framework.activity.Initializable, org.apache.avalon.framework.component.Component, org.apache.avalon.framework.configuration.Configurable, org.apache.avalon.framework.logger.LogEnabled, org.apache.avalon.framework.thread.ThreadSafe, GlobalCacheService

public class EHCacheService
extends org.apache.avalon.framework.logger.AbstractLogEnabled
implements GlobalCacheService, Runnable, org.apache.avalon.framework.configuration.Configurable, org.apache.avalon.framework.activity.Disposable, org.apache.avalon.framework.activity.Initializable, org.apache.avalon.framework.thread.ThreadSafe

Default implementation of EHCacheService

Author:
Eric Pugh, Thomas Vandahl

Field Summary
static long DEFAULT_CACHE_CHECK_FREQUENCY
          Cache check frequency in Millis (1000 Millis = 1 second).
 
Fields inherited from interface org.apache.fulcrum.cache.GlobalCacheService
ROLE
 
Constructor Summary
EHCacheService()
           
 
Method Summary
 void addObject(String id, CachedObject o)
          Adds an object to the cache.
 void configure(org.apache.avalon.framework.configuration.Configuration config)
           
 void dispose()
           
 void flushCache()
          Flush the cache of all objects.
 List getCachedObjects()
          Returns a copy of the non-expired CachedObjects in the cache as a list.
 int getCacheSize()
          Returns the current size of the cache.
 List getKeys()
          Returns a copy of keys to objects in the cache as a list.
 int getNumberOfObjects()
          Returns the number of objects in the cache.
 CachedObject getObject(String id)
          Gets a cached object given its id (a String).
 void initialize()
           
 void removeObject(String id)
          Removes an object from the cache.
 void run()
          Circle through the cache and refresh stale objects.
 
Methods inherited from class org.apache.avalon.framework.logger.AbstractLogEnabled
enableLogging, getLogger, setupLogger, setupLogger, setupLogger
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DEFAULT_CACHE_CHECK_FREQUENCY

public static final long DEFAULT_CACHE_CHECK_FREQUENCY
Cache check frequency in Millis (1000 Millis = 1 second). Value must be > 0. Default = 5 seconds

See Also:
Constant Field Values
Constructor Detail

EHCacheService

public EHCacheService()
Method Detail

configure

public void configure(org.apache.avalon.framework.configuration.Configuration config)
               throws org.apache.avalon.framework.configuration.ConfigurationException
Specified by:
configure in interface org.apache.avalon.framework.configuration.Configurable
Throws:
org.apache.avalon.framework.configuration.ConfigurationException
See Also:
Configurable.configure(org.apache.avalon.framework.configuration.Configuration)

initialize

public void initialize()
                throws Exception
Specified by:
initialize in interface org.apache.avalon.framework.activity.Initializable
Throws:
Exception
See Also:
Initializable.initialize()

dispose

public void dispose()
Specified by:
dispose in interface org.apache.avalon.framework.activity.Disposable
See Also:
Disposable.dispose()

addObject

public void addObject(String id,
                      CachedObject o)
Description copied from interface: GlobalCacheService
Adds an object to the cache.

Specified by:
addObject in interface GlobalCacheService
Parameters:
id - The String id for the object.
o - The object to add to the cache.
See Also:
GlobalCacheService.addObject(java.lang.String, org.apache.fulcrum.cache.CachedObject)

flushCache

public void flushCache()
Description copied from interface: GlobalCacheService
Flush the cache of all objects.

Specified by:
flushCache in interface GlobalCacheService
See Also:
GlobalCacheService.flushCache()

getCachedObjects

public List getCachedObjects()
Description copied from interface: GlobalCacheService
Returns a copy of the non-expired CachedObjects in the cache as a list.

Specified by:
getCachedObjects in interface GlobalCacheService
Returns:
A List of CachedObject objects held in the cache
See Also:
GlobalCacheService.getCachedObjects()

getCacheSize

public int getCacheSize()
                 throws IOException
Description copied from interface: GlobalCacheService
Returns the current size of the cache.

Specified by:
getCacheSize in interface GlobalCacheService
Returns:
int representing current cache size in number of bytes
Throws:
IOException
See Also:
GlobalCacheService.getCacheSize()

getKeys

public List getKeys()
Description copied from interface: GlobalCacheService
Returns a copy of keys to objects in the cache as a list. Note that keys to expired objects are not returned.

Specified by:
getKeys in interface GlobalCacheService
Returns:
A List of String's representing the keys to objects in the cache.
See Also:
GlobalCacheService.getKeys()

getNumberOfObjects

public int getNumberOfObjects()
Description copied from interface: GlobalCacheService
Returns the number of objects in the cache.

Specified by:
getNumberOfObjects in interface GlobalCacheService
Returns:
int The current number of objects in the cache.
See Also:
GlobalCacheService.getNumberOfObjects()

getObject

public CachedObject getObject(String id)
                       throws ObjectExpiredException
Description copied from interface: GlobalCacheService
Gets a cached object given its id (a String).

Specified by:
getObject in interface GlobalCacheService
Parameters:
id - The String id for the object.
Returns:
A CachedObject.
Throws:
ObjectExpiredException
See Also:
GlobalCacheService.getObject(java.lang.String)

removeObject

public void removeObject(String id)
Description copied from interface: GlobalCacheService
Removes an object from the cache.

Specified by:
removeObject in interface GlobalCacheService
Parameters:
id - The String id for the object.
See Also:
GlobalCacheService.removeObject(java.lang.String)

run

public void run()
Circle through the cache and refresh stale objects. Frequency is determined by the cacheCheckFrequency property.

Specified by:
run in interface Runnable


Copyright © 2004-2010 The Apache Software Foundation. All Rights Reserved.