svn commit: r883225 - in /ofbiz/trunk/framework: base/src/org/ofbiz/base/util/cache/UtilCache.java entity/src/org/ofbiz/entity/cache/AbstractCache.java

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

svn commit: r883225 - in /ofbiz/trunk/framework: base/src/org/ofbiz/base/util/cache/UtilCache.java entity/src/org/ofbiz/entity/cache/AbstractCache.java

doogie-3
Author: doogie
Date: Mon Nov 23 03:03:20 2009
New Revision: 883225

URL: http://svn.apache.org/viewvc?rev=883225&view=rev
Log:
No longer access utilCacheTable from AbstractCache; this nescessatited
creating a getOrCreateUtilCache helper method.

Modified:
    ofbiz/trunk/framework/base/src/org/ofbiz/base/util/cache/UtilCache.java
    ofbiz/trunk/framework/entity/src/org/ofbiz/entity/cache/AbstractCache.java

Modified: ofbiz/trunk/framework/base/src/org/ofbiz/base/util/cache/UtilCache.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/base/src/org/ofbiz/base/util/cache/UtilCache.java?rev=883225&r1=883224&r2=883225&view=diff
==============================================================================
--- ofbiz/trunk/framework/base/src/org/ofbiz/base/util/cache/UtilCache.java (original)
+++ ofbiz/trunk/framework/base/src/org/ofbiz/base/util/cache/UtilCache.java Mon Nov 23 03:03:20 2009
@@ -695,6 +695,20 @@
         cache.clear();
     }
 
+    @SuppressWarnings("unchecked")
+    public static <K, V> UtilCache<K, V> getOrCreateUtilCache(String cacheName, int maxSize, int maxInMemory, long expireTime, boolean useSoftReference, boolean useFileSystemStore, String... names) {
+        UtilCache<K, V> cache;
+        synchronized (utilCacheTable) {
+            cache = (UtilCache<K, V>) utilCacheTable.get(cacheName);
+            if (cache == null) {
+                cache = new UtilCache<K, V>(cacheName, maxSize, maxInMemory, expireTime, useSoftReference, useFileSystemStore);
+                cache.setPropertiesParams(names);
+                utilCacheTable.put(cacheName, cache);
+            }
+        }
+        return cache;
+    }
+
     public static <K, V> UtilCache<K, V> createUtilCache(String cacheName, int maxSize, int maxInMemory, long expireTime, boolean useSoftReference, boolean useFileSystemStore, String... names) {
         UtilCache<K, V> cache = new UtilCache<K, V>(cacheName, maxSize, maxInMemory, expireTime, useSoftReference, useFileSystemStore);
         cache.setPropertiesParams(names);

Modified: ofbiz/trunk/framework/entity/src/org/ofbiz/entity/cache/AbstractCache.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/entity/src/org/ofbiz/entity/cache/AbstractCache.java?rev=883225&r1=883224&r2=883225&view=diff
==============================================================================
--- ofbiz/trunk/framework/entity/src/org/ofbiz/entity/cache/AbstractCache.java (original)
+++ ofbiz/trunk/framework/entity/src/org/ofbiz/entity/cache/AbstractCache.java Mon Nov 23 03:03:20 2009
@@ -76,12 +76,6 @@
 
     protected UtilCache<K, V> getOrCreateCache(String entityName) {
         String name = getCacheName(entityName);
-        synchronized (UtilCache.utilCacheTable) {
-            UtilCache<K, V> cache = UtilCache.findCache(name);
-            if (cache == null) {
-                cache = UtilCache.createUtilCache(name, 0, 0, 0, true, false, getCacheNames(entityName));
-            }
-            return cache;
-        }
+        return UtilCache.getOrCreateUtilCache(name, 0, 0, 0, true, false, getCacheNames(entityName));
     }
 }