SolarMetric Kodo JDO 3.2.4 generated on January 7 2005

kodo.datacache
Class DelegatingDataCache

java.lang.Object
  |
  +--kodo.datacache.DelegatingDataCache
All Implemented Interfaces:
com.solarmetric.util.Closeable, DataCache

public class DelegatingDataCache
extends Object
implements DataCache

Base class for data cache decorators that delegate to another data cache for some operations.

Since:
3.0

Fields inherited from interface kodo.datacache.DataCache
DEFAULT_NAME
 
Constructor Summary
DelegatingDataCache(DataCache cache)
          Constructor.
 
Method Summary
 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 oid; otherwise returns false.
 boolean equals(Object other)
           
 PCData get(Object key)
          Return the cached object for the given oid.
 DataCache getDelegate()
          Return the wrapped data cache.
 DataCache getInnermostDelegate()
          Return the base underlying native data cache.
 String getName()
          Returns a string name that can be used by end-user-visible code to identify this cache.
 int hashCode()
           
 boolean pin(Object key)
          Pin the value stored under oid into the cache.
 PCData put(PCData value)
          Set the cached value for the given instance.
 void registerListener(ExpirationListener listen)
          Add a new expiration event listener to this cache.
 PCData remove(Object key)
          Remove the value stored under the given oid.
 boolean removeListener(ExpirationListener 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.
 boolean unpin(Object key)
          Unpin the value stored under oid into the cache.
 void updateValue(PCData value)
          Update the cached value for the given instance.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DelegatingDataCache

public DelegatingDataCache(DataCache cache)
Constructor. Supply delegate.
Method Detail

getDelegate

public DataCache getDelegate()
Return the wrapped data cache.

getInnermostDelegate

public DataCache getInnermostDelegate()
Return the base underlying native data cache.

hashCode

public int hashCode()
Overrides:
hashCode in class Object

equals

public boolean equals(Object other)
Overrides:
equals in class Object

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: kodo.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 oid. Modifying the returned object may or may not change the cached value; the DataCache.updateValue(kodo.runtime.PCData) method should be used to re-cache any changed objects.
Specified by:
get in interface DataCache
Following copied from interface: kodo.datacache.DataCache
Returns:
the object matching the given oid, or null if none

put

public PCData put(PCData value)
Description copied from interface: DataCache
Set the cached value for the given instance. 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: kodo.datacache.DataCache
Returns:
The previously cached value, or null if the value was not previously cached. See Map.put(java.lang.Object, java.lang.Object) for more information.

updateValue

public void updateValue(PCData value)
Description copied from interface: DataCache

Update the cached value for the given instance. 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.

A cache implementation may or may not return a live object from DataCache.get(java.lang.Object) invocations. If an object retrieved from a DataCache.get(java.lang.Object) operation needs to be updated, this method can be invoked instead of invoking DataCache.put(kodo.runtime.PCData). The DataCache implementation can then make optimizations based on how its DataCache.get(java.lang.Object) method works.

Specified by:
updateValue in interface DataCache

remove

public PCData remove(Object key)
Description copied from interface: DataCache
Remove the value stored under the given oid. 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: kodo.datacache.DataCache
Returns:
The previously cached value, or null if the oid was not previously cached. See Map.remove(java.lang.Object) for more information.

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

pin

public boolean pin(Object key)
Description copied from interface: DataCache
Pin the value stored under oid into the cache. This method guarantees that oid's value will not be dropped by the caching algorithm. This method does not affect the behavior of DataCache.remove(java.lang.Object).
Specified by:
pin in interface DataCache
Following copied from interface: kodo.datacache.DataCache
Returns:
true if oid's value was pinned into the cache; false if the oid is not in the cache.

unpin

public boolean unpin(Object key)
Description copied from interface: DataCache
Unpin the value stored under oid into the cache. This method reverses a previous invocation of DataCache.pin(java.lang.Object). This method does not remove anything from the cache; it merely makes oid's value a candidate for flushing from the cache.
Specified by:
unpin in interface DataCache
Following copied from interface: kodo.datacache.DataCache
Returns:
true if oid's value was unpinned from the cache; false if the oid is not in the cache.

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 oid; 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

registerListener

public void registerListener(ExpirationListener listen)
Description copied from interface: DataCache
Add a new expiration event listener to this cache.
Specified by:
registerListener in interface DataCache

removeListener

public boolean removeListener(ExpirationListener listen)
Description copied from interface: DataCache
Remove an expiration event listener from this cache.
Specified by:
removeListener in interface DataCache

SolarMetric Kodo JDO 3.2.4 generated on January 7 2005

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