org.progeeks.meta.util
Class MetaObjectCache

java.lang.Object
  extended by org.progeeks.util.Cache
      extended by org.progeeks.meta.util.MetaObjectCache

public class MetaObjectCache
extends Cache

Cache specific to storing and retrieving meta-objects based on their identity. Additionally, a context MetaObjectCache is provided for convenient access to a global cache.

Version:
$Revision: 1.3 $
Author:
Paul Speed

Constructor Summary
MetaObjectCache()
           
 
Method Summary
 MetaObject cacheMetaObject(MetaObject obj)
          Caches the specified meta-object based on its identity.
 MetaObject cacheMetaObject(MetaObject obj, boolean forceCache)
          Caches the specified meta-object based on its identity.
 void cacheObject(java.lang.Object id, java.lang.Object obj)
          Caches the specified object associated with the specified key.
static MetaObjectCache getContextCache()
          Returns the current thread's context meta-object cache.
static void setContextCache(MetaObjectCache cache)
          Sets the current thread's context meta-object cache.
 
Methods inherited from class org.progeeks.util.Cache
getCachedObject, uncacheObject
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

MetaObjectCache

public MetaObjectCache()
Method Detail

cacheMetaObject

public MetaObject cacheMetaObject(MetaObject obj)
Caches the specified meta-object based on its identity. If the meta-object has no identity then an IllegalArgumentException is thrown. Returns the meta-object specified or the already cached meta-object is this meta-object had been cached previously.


cacheMetaObject

public MetaObject cacheMetaObject(MetaObject obj,
                                  boolean forceCache)
Caches the specified meta-object based on its identity. If the meta-object has no identity then an IllegalArgumentException is thrown. If forceCache is true then the new object is forced into the cache and returned. Otherwise, if the object key already exists in the cache then it's cached version is returned. Otherwise, the new object is forced into the cache and returned.


cacheObject

public void cacheObject(java.lang.Object id,
                        java.lang.Object obj)
Caches the specified object associated with the specified key. Overridden to verify that the object is a MetaObject.

Overrides:
cacheObject in class Cache

getContextCache

public static MetaObjectCache getContextCache()
Returns the current thread's context meta-object cache. If one has not been specified then a global cache instance is returned.


setContextCache

public static void setContextCache(MetaObjectCache cache)
Sets the current thread's context meta-object cache.



Copyright © 2002-2003 Paul Speed. All Rights Reserved.