Author: doogie
Date: Mon Nov 23 02:59:22 2009
New Revision: 883220
URL: http://svn.apache.org/viewvc?rev=883220&view=rev
Log:
Move utilCacheTable.put out of the constructors.
Modified:
ofbiz/trunk/framework/base/src/org/ofbiz/base/util/cache/UtilCache.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=883220&r1=883219&r2=883220&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 02:59:22 2009
@@ -116,10 +116,6 @@
setPropertiesParams(cacheName);
createCache();
-
- synchronized (utilCacheTable) {
- utilCacheTable.put(name, this);
- }
}
private UtilCache(String cacheName, int maxSize, long expireTime, boolean
useSoftReference) {
@@ -161,9 +157,6 @@
setPropertiesParams("default");
setPropertiesParams(cacheName);
createCache();
- synchronized (utilCacheTable) {
- utilCacheTable.put(name, this);
- }
}
/** This constructor takes a name for the cache, puts itself in the
utilCacheTable.
@@ -176,9 +169,6 @@
setPropertiesParams("default");
setPropertiesParams(cacheName);
createCache();
- synchronized (utilCacheTable) {
- utilCacheTable.put(name, this);
- }
}
/** Default constructor, all members stay at default values as defined in
cache.properties, or the defaults in this file if cache.properties is not
found, or there are no 'default' entries in it.
@@ -188,9 +178,6 @@
name = "default" + this.getNextDefaultIndex("default");
createCache();
- synchronized (utilCacheTable) {
- utilCacheTable.put(name, this);
- }
}
protected String getNextDefaultIndex(String cacheName) {
@@ -703,7 +690,7 @@
}
public static <K, V> UtilCache<K, V> createUtilCache(String cacheName, int
maxSize, int maxInMemory, long expireTime, boolean useSoftReference, boolean
useFileSystemStore) {
- return new UtilCache<K, V>(cacheName, maxSize, maxInMemory,
expireTime, useSoftReference, useFileSystemStore);
+ return storeCache(new UtilCache<K, V>(cacheName, maxSize, maxInMemory,
expireTime, useSoftReference, useFileSystemStore));
}
public static <K,V> UtilCache<K, V> createUtilCache(String cacheName, int
maxSize, long expireTime, boolean useSoftReference) {
@@ -715,19 +702,26 @@
}
public static <K,V> UtilCache<K, V> createUtilCache(int maxSize, long
expireTime) {
- return new UtilCache<K, V>(maxSize, expireTime);
+ return storeCache(new UtilCache<K, V>(maxSize, expireTime));
}
public static <K,V> UtilCache<K, V> createUtilCache(String cacheName,
boolean useSoftReference) {
- return new UtilCache<K, V>(cacheName, useSoftReference);
+ return storeCache(new UtilCache<K, V>(cacheName, useSoftReference));
}
public static <K,V> UtilCache<K, V> createUtilCache(String cacheName) {
- return new UtilCache<K, V>(cacheName);
+ return storeCache(new UtilCache<K, V>(cacheName));
}
public static <K,V> UtilCache<K, V> createUtilCache() {
- return new UtilCache<K, V>();
+ return storeCache(new UtilCache<K, V>());
+ }
+
+ private static <K, V> UtilCache<K, V> storeCache(UtilCache<K, V> cache) {
+ synchronized (utilCacheTable) {
+ utilCacheTable.put(cache.getName(), cache);
+ }
+ return cache;
}
@SuppressWarnings("unchecked")