Overview | Package | Class | Tree | Deprecated | Index | Help
| SolarMetric Kodo JDO 2.5.8 generated on January 11 2004
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## com.solarmetric.kodo.runtime.datacache
Class AbstractCacheImpl

    java.lang.Object
      |
      +--com.solarmetric.kodo.runtime.datacache.AbstractCacheImpl

All Implemented Interfaces:
  Configurable, DataCache

Direct Known Subclasses:
  CacheImpl, TangosolCache

public abstract class AbstractCacheImpl
extends Object
implements DataCache, Configurable

Abstract `DataCache` implementation that provides various locking, logging, etc. functionality common across cache implementations.

Field Summary
`protected Map` | `cache` A map in which that this cache implementation stores data.
`protected static org.apache.commons.logging.Log` | `s_log`

Constructor Summary
`AbstractCacheImpl()`

Method Summary
`protected abstract boolean` | `addExistingUpdates()` Return `true` if updates to data already in the cache (either in `batchUpdate(java.util.Collection, java.util.Collection, java.util.Collection, java.util.Collection)` or the `updateValue(com.solarmetric.kodo.runtime.PCData)`) should be put back into the cache.
`void` | `addExpirationListener(com.solarmetric.util.Listener listen)` Add a new expiration event listener to this cache.
`void` | `batchUpdate(Collection additions, Collection newUpdates, Collection existingUpdates, Collection deletes)` Perform a batch update of the cache.
`void` | `clear()` Remove all data from this cache.
`void` | `close()` Close this cache, dropping all hard references and releasing any resources that this cache maintains.
`boolean` | `containsKey(Object key)` Returns `true` if this cache contains data corresponding to `key`; otherwise returns `false`.
`void` | `endConfiguration()` Invoked upon completion of configuration of this object
`PCData` | `get(Object key)` Return the cached object for the given key.
`String` | `getCacheStatisticsString()` Returns a localized string containing the number of hits, the number of misses, and the hit ratio (`hits / (hits+misses)`).
`int` | `getHitCount()` Returns the number of cache hits for invocations of the `get(java.lang.Object)` method.
`Map` | `getMap()` Returns the underlying `Map` that this `CacheImpl` is using.
`int` | `getMissCount()` Returns the number of cache misses for invocations of the `get(java.lang.Object)` method.
`String` | `getName()` Returns a string name that can be used by end-user-visible code to identify this cache.
`boolean` | `getRecordCacheStatistics()` Returns `true` if cache statistics recording is currently on; otherwise returns `false`.
`boolean` | `isDecorator()` Returns `true` if this cache is a decorator that wraps another cache.
`protected void` | `keyExpired(Object key)` Invoked when a key is expired from this cache.
`protected abstract Map` | `newMap()` Returns a new `Map` for use as the underlying data cache.
`PCData` | `put(PCData data)` Set the cached value for the given key.
`PCData` | `remove(Object key)` Remove the value stored under the given key.
`void` | `removeAll(Collection keys)`
`DataCache` | `removeDecorator()` Returns an undecorated version of this cache.
`DataCache` | `removeDecorators()` Returns the lowest cache in the chain of caches in this object.
`void` | `removeExpirationListener(com.solarmetric.util.Listener listen)` Remove an expiration event listener from this cache.
`void` | `setName(String name)` Sets a string name to be used to identify this cache to end-user needs.
`void` | `setRecordCacheStatistics(boolean record)` Turns cache statistics recording on or off.
`void` | `startConfiguration()` Invoked before configuration is begun on this object
`String` | `toString()`
`void` | `updateValue(PCData data)` Determine what to based on `addExistingUpdates()`.

Methods inherited from class java.lang.Object
`, clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait`

Methods inherited from interface com.solarmetric.kodo.runtime.datacache.DataCache
`pin, unpin`

Field Detail

### s_log

    protected static final org.apache.commons.logging.Log s_log

### cache

    protected Map cache

  A map in which that this cache implementation stores data.

Constructor Detail

### AbstractCacheImpl

    public AbstractCacheImpl()

Method Detail

### getMap

    public Map getMap()

  Returns the underlying `Map` that this `CacheImpl` is using. This is not an unmodifiable view on the map, so care should be taken with this reference. Implementations should probably not mess with the contents of the cache, but should only use this reference to obtain cache metrics.

### newMap

    protected abstract Map newMap()

  Returns a new `Map` for use as the underlying data cache.

### keyExpired

    protected void keyExpired(Object key)

  Invoked when a key is expired from this cache. Propagates the expiration event on to all expiration listeners registered with this class.

### addExistingUpdates

    protected abstract boolean addExistingUpdates()

  Return `true` if updates to data already in the cache (either in `batchUpdate(java.util.Collection, java.util.Collection, java.util.Collection, java.util.Collection)` or the `updateValue(com.solarmetric.kodo.runtime.PCData)`) should be put back into the cache.

### batchUpdate

    public void batchUpdate(Collection additions,
                            Collection newUpdates,
                            Collection existingUpdates,
                            Collection deletes)

  Description copied from interface: `DataCache`

  Perform a batch update of the cache. Add all `PCData` objects in `additions` and in `newUpdates`, make the appropriate modifications to all PCDatas in `existingUpdates`, and delete all OIDs in `deletes`.

  All changes made to cached data must be cached via this method. It is this method that is responsible for performing any side-effects that should happen on meaningful cache changes.

  Implementations should bear in mind that the `deletes` collection may contain oids that are also in the `additions` map. This is possible because it is valid for a user to delete an object with a particular oid and then add that object in the same batch.

  Specified by:
    `batchUpdate` in interface `DataCache`
  Following copied from interface: `com.solarmetric.kodo.runtime.datacache.DataCache`
  Parameters:
    `additions` - A collection of `PCData` objects. These represent data that have been newly created, and thus must be added to the cache.
    `newUpdates` - A collection of `PCData` objects. These represent data that have been modified but were not originally in the cache, and thus must be added to the cache.
    `existingUpdates` - A collection of `PCData` objects. These represent data that have been modified and were originally loaded from the cache. It is up to the cache implementation to decide if these values must be re-enlisted in the cache. Some caches may return live data from `DataCache.get(java.lang.Object)` invocations, in which case these values need not be re-enlisted.
    `deletes` - A collection of object IDs that have been deleted and must therefore be dropped from the cache.

### get

    public PCData get(Object key)

  Description copied from interface: `DataCache`
  Return the cached object for the given key. Modifying the returned object may or may not change the cached value; the `DataCache.updateValue(com.solarmetric.kodo.runtime.PCData)` method should be used to re-cache any changed objects.
  Specified by:
    `get` in interface `DataCache`
  Following copied from interface: `com.solarmetric.kodo.runtime.datacache.DataCache`
  Returns:
    the object matching the given key, or null if none

### put

    public PCData put(PCData data)

  Description copied from interface: `DataCache`
  Set the cached value for the given key. This does not result in an update of other caches. Rather, it should only be used for loading clean data into the cache. Meaningful changes to the state of the cache should be made via the `DataCache.batchUpdate(java.util.Collection, java.util.Collection, java.util.Collection, java.util.Collection)` method.
  Specified by:
    `put` in interface `DataCache`
  Following copied from interface: `com.solarmetric.kodo.runtime.datacache.DataCache`
  Returns:
    The previously cached value, or `null` if the key was not previously cached. See `Map.put(java.lang.Object, java.lang.Object)` for more information.

### updateValue

    public void updateValue(PCData data)

  Determine what to based on `addExistingUpdates()`.
  Specified by:
    `updateValue` in interface `DataCache`

### remove

    public PCData remove(Object key)

  Description copied from interface: `DataCache`
  Remove the value stored under the given key. This does not result in an update of other caches. Rather, it should only be used for removing data into the cache. Meaningful changes to the state of the cache should be made via the `DataCache.batchUpdate(java.util.Collection, java.util.Collection, java.util.Collection, java.util.Collection)` method.
  Specified by:
    `remove` in interface `DataCache`
  Following copied from interface: `com.solarmetric.kodo.runtime.datacache.DataCache`
  Returns:
    The previously cached value, or `null` if the key was not previously cached. See `Map.remove(java.lang.Object)` for more information.

### removeAll

    public void removeAll(Collection keys)

### clear

    public void clear()

  Description copied from interface: `DataCache`
  Remove all data from this cache. This does not result in an update of other caches. Rather, it should only be used for clearing the cache. Meaningful changes to the state of the cache should be made via the `DataCache.batchUpdate(java.util.Collection, java.util.Collection, java.util.Collection, java.util.Collection)` method.
  Specified by:
    `clear` in interface `DataCache`

### close

    public void close()

  Description copied from interface: `DataCache`
  Close this cache, dropping all hard references and releasing any resources that this cache maintains.
  Specified by:
    `close` in interface `DataCache`

### containsKey

    public boolean containsKey(Object key)

  Description copied from interface: `DataCache`
  Returns `true` if this cache contains data corresponding to `key`; otherwise returns `false`.
  Specified by:
    `containsKey` in interface `DataCache`

### setName

    public void setName(String name)

  Description copied from interface: `DataCache`
  Sets a string name to be used to identify this cache to end-user needs.
  Specified by:
    `setName` in interface `DataCache`

### getName

    public String getName()

  Description copied from interface: `DataCache`
  Returns a string name that can be used by end-user-visible code to identify this cache.
  Specified by:
    `getName` in interface `DataCache`

### isDecorator

    public boolean isDecorator()

  Description copied from interface: `DataCache`
  Returns `true` if this cache is a decorator that wraps another cache. Otherwise, returns `false`.
  Specified by:
    `isDecorator` in interface `DataCache`

### removeDecorator

    public DataCache removeDecorator()

  Description copied from interface: `DataCache`
  Returns an undecorated version of this cache. If this cache is not a decorator, returns `this`.
  Specified by:
    `removeDecorator` in interface `DataCache`

### removeDecorators

    public DataCache removeDecorators()

  Description copied from interface: `DataCache`
  Returns the lowest cache in the chain of caches in this object. If this cache is not a decorator, returns `this`. This is equivalent to repeatedly invoking `DataCache.removeDecorator()` until the returned DataCache returns `false` from `DataCache.isDecorator()`.
  Specified by:
    `removeDecorators` in interface `DataCache`

### addExpirationListener

    public void addExpirationListener(com.solarmetric.util.Listener listen)

  Description copied from interface: `DataCache`
  Add a new expiration event listener to this cache.
  Specified by:
    `addExpirationListener` in interface `DataCache`

### removeExpirationListener

    public void removeExpirationListener(com.solarmetric.util.Listener listen)

  Description copied from interface: `DataCache`
  Remove an expiration event listener from this cache.
  Specified by:
    `removeExpirationListener` in interface `DataCache`

### getHitCount

    public int getHitCount()

  Returns the number of cache hits for invocations of the `get(java.lang.Object)` method. This number is cleared when cache statistics recording is first enabled (when `setRecordCacheStatistics(boolean)` is invoked with `true`, and recording was previously off) and when `#clearCacheStatistics` is invoked.

### getMissCount

    public int getMissCount()

  Returns the number of cache misses for invocations of the `get(java.lang.Object)` method. This number is cleared when cache statistics recording is disabled (when `setRecordCacheStatistics(boolean)` is invoked with `false`).

### setRecordCacheStatistics

    public void setRecordCacheStatistics(boolean record)

  Turns cache statistics recording on or off. If cache statistics recording is on and the cache logging category is set to log info messages, then a cache statistics statement (generated by `getCacheStatisticsString()`) will be logged when closing the cache.

### getRecordCacheStatistics

    public boolean getRecordCacheStatistics()

  Returns `true` if cache statistics recording is currently on; otherwise returns `false`.

### getCacheStatisticsString

    public String getCacheStatisticsString()

  Returns a localized string containing the number of hits, the number of misses, and the hit ratio (`hits / (hits+misses)`).

### toString

    public String toString()

  Overrides:
    `toString` in class `Object`

### startConfiguration

    public void startConfiguration()

  Description copied from interface: `Configurable`
  Invoked before configuration is begun on this object
  Specified by:
    `startConfiguration` in interface `Configurable`

### endConfiguration

    public void endConfiguration()

  Description copied from interface: `Configurable`
  Invoked upon completion of configuration of this object
  Specified by:
    `endConfiguration` in interface `Configurable`

Overview | Package | Class | Tree | Deprecated | Index | Help
| SolarMetric Kodo JDO 2.5.8 generated on January 11 2004
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

Copyright 2001,2002,2003 SolarMetric, Inc. All Rights Reserved.