|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--ojb.broker.cache.ObjectCacheDefaultImpl
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. The cache uses soft-references which allows objects (softly) referenced by the cache to be reclaimed by the Java Garbage Collector when they are not longer referenced elsewhere.
Field Summary | |
protected java.util.Hashtable |
objectTable
the hashtable holding all cached object |
Constructor Summary | |
ObjectCacheDefaultImpl()
public Default Constructor |
Method Summary | |
void |
cache(Identity oid,
java.lang.Object obj)
makes object persistent to the Objectcache. |
void |
cache(java.lang.Object obj)
Make object obj persistent to Objectcache. |
void |
clear()
clear ObjectCache. |
void |
finalize()
|
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. |
Methods inherited from class java.lang.Object |
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
protected java.util.Hashtable objectTable
Constructor Detail |
public ObjectCacheDefaultImpl()
Method Detail |
public void cache(java.lang.Object obj) throws ClassNotPersistenceCapableException
cache
in interface ObjectCache
ClassNotPersistenceCapableException
public void clear()
clear
in interface ObjectCache
public void cache(Identity oid, java.lang.Object obj)
cache
in interface ObjectCache
public java.lang.Object lookup(Identity oid)
lookup
in interface ObjectCache
public void remove(java.lang.Object obj)
remove
in interface ObjectCache
obj
- the Object (or the Identity of the object) to be removed.public void finalize()
finalize
in class java.lang.Object
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |