|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectorg.apache.ojb.broker.cache.TwoLevelCache
A cache that delegates to another cache in case of misses, and maintains that second-level cache with clones. Work in progress! Known problems:
clearSecondLevel(),
thus the usage of this class will infiltrate the (test) code even
in case this cache is not used at all.
ObjectCachePerBrokerImpl| Nested Class Summary | |
(package private) static class |
TwoLevelCache.NoCloneMethod
|
| Field Summary | |
protected Logger |
logger
|
protected java.util.Map |
objectTable
the hashtable holding all cached objects |
| Constructor Summary | |
TwoLevelCache(PersistenceBroker broker,
java.util.Properties props)
OJB calls this constructor by reflection. |
|
| Method Summary | |
void |
afterBegin(PBStateEvent event)
Called after a PersistenceBroker transaction was started. |
void |
afterCommit(PBStateEvent event)
Called after a PersistenceBroker commit was called. |
void |
afterOpen(PBStateEvent event)
Called after the PersistenceBroker
instance was obtained from pool. |
void |
afterRollback(PBStateEvent event)
Called after a PersistenceBroker rollback was called. |
void |
beforeBegin(PBStateEvent event)
Called before a PersistenceBroker transaction was started. |
void |
beforeClose(PBStateEvent event)
We clear the cache |
void |
beforeCommit(PBStateEvent event)
Called before a PersistenceBroker commit was called. |
void |
beforeRollback(PBStateEvent event)
Called before a PersistenceBroker rollback was called. |
void |
cache(Identity oid,
java.lang.Object obj)
If this method is being called while retrieving the object from database, then the references and collections of obj are filled. |
void |
clear()
Clear ObjectCache. |
static void |
clearSecondLevel()
clear the second level cache, which is shared by all instances in the same VM. |
protected java.lang.Object |
clone(java.lang.Object in)
this method is invoked when an object in inserted or retrieved from the second level. |
protected DescriptorRepository |
getDescriptorRepository()
|
protected java.lang.Object |
getProxy(java.lang.Class referencedClass,
java.lang.Class referencedProxy,
java.lang.Object[] pkVals)
|
protected void |
initCacheCollectionField(CollectionDescriptor colDesc,
java.lang.Object cacheObj,
java.lang.Object origObject)
Sets the value of one collection field when an object is inserted into the cache. |
protected void |
initLookedUpCollections(java.lang.Object obj,
java.lang.Object cacheObj)
Initializes the the non-embedded collection fields after the object has been retrieved from the cache. |
java.lang.Object |
lookup(Identity oid)
Does an extra lookup in the secondLevelCache if the first lookup fails. |
void |
remove(Identity oid)
Removes an Object from the cache. |
java.lang.String |
toString()
|
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Field Detail |
protected java.util.Map objectTable
protected final Logger logger
| Constructor Detail |
public TwoLevelCache(PersistenceBroker broker,
java.util.Properties props)
props - ignored| Method Detail |
protected final DescriptorRepository getDescriptorRepository()
public void clear()
clear in interface ObjectCachepublic static void clearSecondLevel()
public void cache(Identity oid,
java.lang.Object obj)
cache in interface ObjectCache
protected final java.lang.Object getProxy(java.lang.Class referencedClass,
java.lang.Class referencedProxy,
java.lang.Object[] pkVals)
protected java.lang.Object clone(java.lang.Object in)
throws java.lang.CloneNotSupportedException
in - some object
java.lang.CloneNotSupportedException
protected void initLookedUpCollections(java.lang.Object obj,
java.lang.Object cacheObj)
obj - the freshly retrieved objectcacheObj - its copy in the cache
protected void initCacheCollectionField(CollectionDescriptor colDesc,
java.lang.Object cacheObj,
java.lang.Object origObject)
colDesc - cacheObj - the copy of the object in the cacheorigObject - the copy of the object in the scope of some PersistenceBrokerpublic java.lang.Object lookup(Identity oid)
lookup in interface ObjectCacheObjectCachePerBrokerImpl.lookup(org.apache.ojb.broker.Identity)public java.lang.String toString()
public void remove(Identity oid)
remove in interface ObjectCacheoid - Identity of the object to be removed.public void beforeClose(PBStateEvent event)
beforeClose in interface PBStateListenerpublic void afterOpen(PBStateEvent event)
PBStateListenerPersistenceBroker
instance was obtained from pool.
afterOpen in interface PBStateListenerpublic void beforeBegin(PBStateEvent event)
PBStateListener
beforeBegin in interface PBStateListenerpublic void afterBegin(PBStateEvent event)
PBStateListener
afterBegin in interface PBStateListenerpublic void beforeCommit(PBStateEvent event)
PBStateListener
beforeCommit in interface PBStateListenerpublic void afterCommit(PBStateEvent event)
PBStateListener
afterCommit in interface PBStateListenerpublic void beforeRollback(PBStateEvent event)
PBStateListener
beforeRollback in interface PBStateListenerpublic void afterRollback(PBStateEvent event)
PBStateListener
afterRollback in interface PBStateListener
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||