arminw 2005/04/26 15:26:26
Modified: src/java/org/apache/ojb/broker/cache Tag: OJB_1_0_RELEASE
ObjectCacheDefaultImpl.java
ObjectCacheTwoLevelImpl.java
Log:
fix cache synchronization issue when use OJB in managed environment with
ObjectCacheDefaultImpl
minor improvement in TLCache
Revision Changes Path
No revision
No revision
1.24.2.5 +13 -3
db-ojb/src/java/org/apache/ojb/broker/cache/ObjectCacheDefaultImpl.java
Index: ObjectCacheDefaultImpl.java
===================================================================
RCS file:
/home/cvs/db-ojb/src/java/org/apache/ojb/broker/cache/ObjectCacheDefaultImpl.java,v
retrieving revision 1.24.2.4
retrieving revision 1.24.2.5
diff -u -r1.24.2.4 -r1.24.2.5
--- ObjectCacheDefaultImpl.java 19 Feb 2005 20:11:31 -0000 1.24.2.4
+++ ObjectCacheDefaultImpl.java 26 Apr 2005 22:26:26 -0000 1.24.2.5
@@ -348,16 +348,25 @@
public void beforeRollback(PBStateEvent event)
{
synchronizeWithTracedObjects();
+ identitiesInWork.clear();
}
public void beforeCommit(PBStateEvent event)
{
- identitiesInWork.clear();
+ // identitiesInWork.clear();
}
public void beforeClose(PBStateEvent event)
{
- identitiesInWork.clear();
+ /*
+ arminw: In managed environments listener method "beforeClose" is
called twice
+ (when the PB handle is closed and when the real PB instance is
closed/returned to pool).
+ We are only interested in the real close call when all work is done.
+ */
+ if(!broker.isInTransaction())
+ {
+ identitiesInWork.clear();
+ }
}
public void afterRollback(PBStateEvent event)
@@ -366,6 +375,7 @@
public void afterCommit(PBStateEvent event)
{
+ identitiesInWork.clear();
}
public void afterBegin(PBStateEvent event)
1.1.2.6 +3 -3
db-ojb/src/java/org/apache/ojb/broker/cache/Attic/ObjectCacheTwoLevelImpl.java
Index: ObjectCacheTwoLevelImpl.java
===================================================================
RCS file:
/home/cvs/db-ojb/src/java/org/apache/ojb/broker/cache/Attic/ObjectCacheTwoLevelImpl.java,v
retrieving revision 1.1.2.5
retrieving revision 1.1.2.6
diff -u -r1.1.2.5 -r1.1.2.6
--- ObjectCacheTwoLevelImpl.java 12 Mar 2005 01:13:05 -0000 1.1.2.5
+++ ObjectCacheTwoLevelImpl.java 26 Apr 2005 22:26:26 -0000 1.1.2.6
@@ -124,7 +124,7 @@
+ PersistenceBrokerImpl.class + " or of " +
DelegatingPersistenceBroker.class
+ " to setup application cache, but was " + broker);
}
- this.sessionCache = new HashMap();
+ this.sessionCache = new HashMap(100);
// this.enabledReadCache = false;
setupApplicationCache(broker, prop);
if(broker != null)
@@ -538,7 +538,7 @@
* Helper class to wrap cached objects using [EMAIL PROTECTED]
java.lang.ref.SoftReference}, which
* allows to release objects when they no longer referenced within the
PB session.
*/
- final class CacheEntry extends SoftReference implements Serializable
+ static final class CacheEntry extends SoftReference implements
Serializable
{
private int type;
private Identity oid;
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]