Docjar: A Java Source and Docuemnt Enginecom.*    java.*    javax.*    org.*    all    new    plug-in

Quick Search    Search Deep

ojb.broker.cache
Class MetaObjectCacheImpl  view MetaObjectCacheImpl download MetaObjectCacheImpl.java

java.lang.Object
  extended byojb.broker.cache.MetaObjectCacheImpl
All Implemented Interfaces:
ObjectCache

public class MetaObjectCacheImpl
extends java.lang.Object
implements ObjectCache

This cache makes it possible to have separate cache implementations for each class. When an object is cached / looked up the MetaObjectCacheImpl checks if a special ObjectCache has been set for this class. It recursively looks up the superclasses of the given object to look for a special cache. If no special cache is found it uses the ObjectCacheDefaultImpl to cache the object.
It is also possible to switch off caching for a specific class by setting the object cache to null.


Field Summary
private  java.util.Map cachesByClass
           
 
Constructor Summary
MetaObjectCacheImpl()
          Constructor for the MetaObjectCacheImpl object
 
Method Summary
 void cache(ojb.broker.Identity oid, java.lang.Object obj)
          Caches the given object using the given Identity as key
 void cache(java.lang.Object obj)
          Caches the given Object
 void clear()
          Clears the cache
private  ObjectCache getCache(java.lang.Class objectClass)
          Gets the cache for the given class
 java.lang.Object lookup(ojb.broker.Identity oid)
          Looks up the object from the cache
 void remove(java.lang.Object obj)
          Removes the given object from the cache
protected  void removeByOID(ojb.broker.Identity oid)
          Removes the object identified by the given Identity from the cache
 void setClassCache(java.lang.Class objectClass, ObjectCache cache)
          Sets the ObjectCache implementation to use for objects with the given type and subclasses
private  void setClassCache(java.lang.String className, ObjectCache cache)
          Sets the ObjectCache implementation for the given class name
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

cachesByClass

private java.util.Map cachesByClass
Constructor Detail

MetaObjectCacheImpl

public MetaObjectCacheImpl()
Constructor for the MetaObjectCacheImpl object

Method Detail

setClassCache

public void setClassCache(java.lang.Class objectClass,
                          ObjectCache cache)
Sets the ObjectCache implementation to use for objects with the given type and subclasses


cache

public void cache(java.lang.Object obj)
Caches the given Object

Specified by:
cache in interface ObjectCache

cache

public void cache(ojb.broker.Identity oid,
                  java.lang.Object obj)
Caches the given object using the given Identity as key

Specified by:
cache in interface ObjectCache

lookup

public java.lang.Object lookup(ojb.broker.Identity oid)
Looks up the object from the cache

Specified by:
lookup in interface ObjectCache

removeByOID

protected void removeByOID(ojb.broker.Identity oid)
Removes the object identified by the given Identity from the cache


remove

public void remove(java.lang.Object obj)
Removes the given object from the cache

Specified by:
remove in interface ObjectCache

clear

public void clear()
Clears the cache

Specified by:
clear in interface ObjectCache

setClassCache

private void setClassCache(java.lang.String className,
                           ObjectCache cache)
Sets the ObjectCache implementation for the given class name


getCache

private ObjectCache getCache(java.lang.Class objectClass)
Gets the cache for the given class