openjpa-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From curti...@apache.org
Subject svn commit: r964617 - in /openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/datacache: ConcurrentDataCache.java ConcurrentQueryCache.java
Date Thu, 15 Jul 2010 21:40:03 GMT
Author: curtisr7
Date: Thu Jul 15 21:40:02 2010
New Revision: 964617

URL: http://svn.apache.org/viewvc?rev=964617&view=rev
Log:
OPENJPA-1378: Refactor cache init code.

Modified:
    openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/datacache/ConcurrentDataCache.java
    openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/datacache/ConcurrentQueryCache.java

Modified: openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/datacache/ConcurrentDataCache.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/datacache/ConcurrentDataCache.java?rev=964617&r1=964616&r2=964617&view=diff
==============================================================================
--- openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/datacache/ConcurrentDataCache.java
(original)
+++ openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/datacache/ConcurrentDataCache.java
Thu Jul 15 21:40:02 2010
@@ -95,7 +95,14 @@ public class ConcurrentDataCache
     public void initialize(DataCacheManager mgr) {
         super.initialize(mgr);
         conf.getRemoteCommitEventManager().addInternalListener(this);
+        // Wait to instantiate _cache so that we know the proper value of _cache
         _cache = newCacheMap();
+        if (_cacheSize != Integer.MIN_VALUE) {
+            _cache.setCacheSize(_cacheSize);
+        }
+        if (_softRefs != Integer.MIN_VALUE) {
+            _cache.setSoftReferenceSize(_softRefs);
+        }
     }
 
     public void unpinAll(Class<?> cls, boolean subs) {
@@ -122,12 +129,7 @@ public class ConcurrentDataCache
                 keyRemoved(key, expired);
             }
         };
-        if (_cacheSize != Integer.MIN_VALUE) {
-            res.setCacheSize(_cacheSize);
-        }
-        if (_softRefs != Integer.MIN_VALUE) {
-            res.setSoftReferenceSize(_softRefs);
-        }
+        
         return res;
     }
 

Modified: openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/datacache/ConcurrentQueryCache.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/datacache/ConcurrentQueryCache.java?rev=964617&r1=964616&r2=964617&view=diff
==============================================================================
--- openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/datacache/ConcurrentQueryCache.java
(original)
+++ openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/datacache/ConcurrentQueryCache.java
Thu Jul 15 21:40:02 2010
@@ -95,6 +95,12 @@ public class ConcurrentQueryCache
         super.initialize(mgr);
         conf.getRemoteCommitEventManager().addInternalListener(this);
         _cache = newCacheMap();
+        if (_cacheSize != Integer.MIN_VALUE) {
+            _cache.setCacheSize(_cacheSize);
+        }
+        if (_softRefs != Integer.MIN_VALUE) {
+            _cache.setSoftReferenceSize(_softRefs);
+        }
     }
 
     public void writeLock() {
@@ -112,12 +118,7 @@ public class ConcurrentQueryCache
      */
     protected CacheMap newCacheMap() {
         CacheMap res = new CacheMap(_lru);
-        if (_cacheSize != Integer.MIN_VALUE) {
-            res.setCacheSize(_cacheSize);
-        }
-        if (_softRefs != Integer.MIN_VALUE) {
-            res.setSoftReferenceSize(_softRefs);
-        }
+        
         return res;
     }
 



Mime
View raw message