ojb.broker.cache
Interface ObjectCache

All Known Implementing Classes:
MetaObjectCacheImpl, ObjectCacheDefaultImpl, PermanentObjectCacheImpl

public interface ObjectCache

The ObjectCache stores all Objects loaded by the PersistenceBroker from a DB. When the PersistenceBroker tries to get an Object by its Primary key values it first lookups the cache if the object has been already loaded and cached. Using an ObjectCache has several advantages: - it increases performance as it reduces DB lookups. - it allows to perform circular lookups (as by crossreferenced objects) that would result in non-terminating loops without such a cache. - it maintains the uniqueness of objects as any Db row will be mapped to exactly one object. This interface allows to have userdefined Cache implementations. The ObjectCacheFactory is responsible for generating cache instances. by default it uses the OJB ObjectCacheDefaultImpl.

Author:
Thomas Mahler

Method Summary
 void cache(Identity oid, java.lang.Object obj)
          makes object obj persistent to the Objectcache under the key oid.
 void cache(java.lang.Object obj)
          Make object obj persistent to Objectcache.
 void clear()
          clear the ObjectCache.
 java.lang.Object lookup(Identity oid)
          Lookup object with Identity oid in objectTable.
 void remove(java.lang.Object obj)
          removes an Object from the cache.
 

Method Detail

cache

public void cache(java.lang.Object obj)
           throws ClassNotPersistenceCapableException
Make object obj persistent to Objectcache. compute objects identity and use it as key for the hashmap

ClassNotPersistenceCapableException

cache

public void cache(Identity oid,
                  java.lang.Object obj)
makes object obj persistent to the Objectcache under the key oid.


lookup

public java.lang.Object lookup(Identity oid)
Lookup object with Identity oid in objectTable. returns null if no matching id is found


remove

public void remove(java.lang.Object obj)
removes an Object from the cache.

Parameters:
obj - the Object (or the Identity of the object) to be removed.

clear

public void clear()
clear the ObjectCache.



Authors: Thomas Mahler and others. (C) 2000, 2001.
All rights reserved. Published under the Gnu Public License.
http://objectbridge.sourceforge.net
Version: 0.8.375, 2002-04-04