Author: jacopoc
Date: Thu Jul 7 17:00:05 2016 New Revision: 1751817 URL: http://svn.apache.org/viewvc?rev=1751817&view=rev Log: OFBIZ-7760 Removed from UtilCache the ability to persist entries in the file system. This feature has been contributed a long time ago as an experimental feature but never really matured into a production ready artifact: since it was contributed, no users asked about how to use it, or tested it, or reported bugs or enhancement requests. More importantly, the feature has always been disabled in the OFBiz framework (i.e. the widget code and the entity engine code were not using it). This removal should not impact our user base; however, after the removal, an entry to the Attic will be created to keep track of it and to make it easier, to interested users, to get this code, improve it (e.g. by making it dependent on a live external jar, for example MapDB instead of JDBM) and possibly contribute it back to the project. The most compelling reason for its removal is that the feature was based on a snapshot, unreleased version of JDBM, which is now a mostly dead project: for licensing reasons we are no more allowed to bundle jars in our releases. Additionally, having code that relies an old jar from a no more active project represents a maintenance issue for the community. Removed: ofbiz/trunk/framework/base/lib/jdbm-1.0-SNAPSHOT.jar ofbiz/trunk/framework/base/src/org/ofbiz/base/util/cache/JdbmRecordManager.java ofbiz/trunk/framework/base/src/org/ofbiz/base/util/cache/JdbmSerializer.java Modified: ofbiz/trunk/LICENSE ofbiz/trunk/build.gradle ofbiz/trunk/framework/base/config/cache.properties ofbiz/trunk/framework/base/src/org/ofbiz/base/util/cache/UtilCache.java ofbiz/trunk/framework/base/src/org/ofbiz/base/util/cache/test/UtilCacheTests.java ofbiz/trunk/framework/entity/src/org/ofbiz/entity/cache/AbstractCache.java ofbiz/trunk/framework/service/src/org/ofbiz/service/rmi/ExampleRemoteClient.java ofbiz/trunk/framework/webtools/groovyScripts/cache/EditUtilCache.groovy ofbiz/trunk/framework/webtools/groovyScripts/cache/FindUtilCache.groovy ofbiz/trunk/framework/webtools/widget/CacheForms.xml ofbiz/trunk/framework/widget/src/org/ofbiz/widget/cache/AbstractCache.java ofbiz/trunk/specialpurpose/pos/src/org/ofbiz/pos/config/ButtonEventConfig.java Modified: ofbiz/trunk/LICENSE URL: http://svn.apache.org/viewvc/ofbiz/trunk/LICENSE?rev=1751817&r1=1751816&r2=1751817&view=diff ============================================================================== --- ofbiz/trunk/LICENSE (original) +++ ofbiz/trunk/LICENSE Thu Jul 7 17:00:05 2016 @@ -1841,57 +1841,6 @@ JPython version 1.1.x [ACCEPT BUTTON] ========================================================================= -The JDBM library is licensed under the JDBM LICENSE v1.00 as follows. -This license is nearly equivalent to the BSD License. -framework/base/lib/jdbm-1.0-SNAPSHOT.jar -========================================================================= -/** - * JDBM LICENSE v1.00 - * - * Redistribution and use of this software and associated documentation - * ("Software"), with or without modification, are permitted provided - * that the following conditions are met: - * - * 1. Redistributions of source code must retain copyright - * statements and notices. Redistributions must also contain a - * copy of this document. - * - * 2. Redistributions in binary form must reproduce the - * above copyright notice, this list of conditions and the - * following disclaimer in the documentation and/or other - * materials provided with the distribution. - * - * 3. The name "JDBM" must not be used to endorse or promote - * products derived from this Software without prior written - * permission of Cees de Groot. For written permission, - * please contact [hidden email]. - * - * 4. Products derived from this Software may not be called "JDBM" - * nor may "JDBM" appear in their names without prior written - * permission of Cees de Groot. - * - * 5. Due credit should be given to the JDBM Project - * (http://jdbm.sourceforge.net/). - * - * THIS SOFTWARE IS PROVIDED BY THE JDBM PROJECT AND CONTRIBUTORS - * ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT - * NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND - * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL - * CEES DE GROOT OR ANY CONTRIBUTORS BE LIABLE FOR ANY DIRECT, - * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, - * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED - * OF THE POSSIBILITY OF SUCH DAMAGE. - * - * Copyright 2000 (C) Cees de Groot. All Rights Reserved. - * Contributions are Copyright (C) 2000 by their associated contributors. - * - * $Id: LICENSE.txt,v 1.1 2000/05/05 23:59:52 boisvert Exp $ - */ -========================================================================= The following library distributed with Apache OFBiz is licensed under the COMMON DEVELOPMENT AND DISTRIBUTION LICENSE (CDDL): framework/base/lib/juel-2.1.1.jar (contains the javax.el package) Modified: ofbiz/trunk/build.gradle URL: http://svn.apache.org/viewvc/ofbiz/trunk/build.gradle?rev=1751817&r1=1751816&r2=1751817&view=diff ============================================================================== --- ofbiz/trunk/build.gradle (original) +++ ofbiz/trunk/build.gradle Thu Jul 7 17:00:05 2016 @@ -398,12 +398,6 @@ eclipse.classpath.file.whenMerged { clas tasks.eclipse.dependsOn(cleanEclipse) // ========== Clean up tasks ========== -task cleanCache(group: cleanupGroup, description: 'Clean the UtilCache file') << { - def props = retrievePropsFromFile('framework/base/config/cache.properties') - if(props['cache.file.store']) { - delete props['cache.file.store']+'.db' - } -} task cleanCatalina(group: cleanupGroup, description: 'Clean Catalina data in runtime/catalina/work') << { delete './runtime/catalina/work' } Modified: ofbiz/trunk/framework/base/config/cache.properties URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/base/config/cache.properties?rev=1751817&r1=1751816&r2=1751817&view=diff ============================================================================== --- ofbiz/trunk/framework/base/config/cache.properties (original) +++ ofbiz/trunk/framework/base/config/cache.properties Thu Jul 7 17:00:05 2016 @@ -22,7 +22,6 @@ #### # Default Settings -#cache.file.store=runtime/data/utilcache # Sets the maximum number of entries that can be placed in the cache. A # setting of zero indicates no maximum. #default.maxSize=0 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=1751817&r1=1751816&r2=1751817&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 Thu Jul 7 17:00:05 2016 @@ -39,9 +39,6 @@ import java.util.concurrent.TimeUnit; import java.util.concurrent.atomic.AtomicInteger; import java.util.concurrent.atomic.AtomicLong; -import jdbm.helper.FastIterator; -import jdbm.htree.HTree; - import org.ofbiz.base.concurrent.ExecutionPool; import org.ofbiz.base.util.Debug; import org.ofbiz.base.util.ObjectType; @@ -107,21 +104,11 @@ public class UtilCache<K, V> implements /** Specifies whether or not to use soft references for this cache, defaults to false */ protected boolean useSoftReference = false; - /** Specifies whether or not to use file base stored for this cache, defaults to false */ - protected boolean useFileSystemStore = false; - private String fileStore = "runtime/data/utilcache"; - /** The set of listeners to receive notifications when items are modified (either deliberately or because they were expired). */ protected Set<CacheListener<K, V>> listeners = new CopyOnWriteArraySet<CacheListener<K, V>>(); - protected transient HTree<Object, V> fileTable = null; protected ConcurrentMap<Object, CacheLine<V>> memoryTable = null; - protected JdbmRecordManager jdbmMgr; - - // weak ref on this - private static final ConcurrentMap<String, JdbmRecordManager> fileManagers = new ConcurrentHashMap<String, JdbmRecordManager>(); - /** Constructor which specifies the cacheName as well as the sizeLimit, expireTime and useSoftReference. * The passed sizeLimit, expireTime and useSoftReference will be overridden by values from cache.properties if found. * @param sizeLimit The sizeLimit member is set to this value @@ -129,13 +116,12 @@ public class UtilCache<K, V> implements * @param cacheName The name of the cache. * @param useSoftReference Specifies whether or not to use soft references for this cache. */ - private UtilCache(String cacheName, int sizeLimit, int maxInMemory, long expireTimeMillis, boolean useSoftReference, boolean useFileSystemStore, String propName, String... propNames) { + private UtilCache(String cacheName, int sizeLimit, int maxInMemory, long expireTimeMillis, boolean useSoftReference, String propName, String... propNames) { this.name = cacheName; this.sizeLimit = sizeLimit; this.maxInMemory = maxInMemory; this.expireTimeNanos = TimeUnit.NANOSECONDS.convert(expireTimeMillis, TimeUnit.MILLISECONDS); this.useSoftReference = useSoftReference; - this.useFileSystemStore = useFileSystemStore; setPropertiesParams(propName); setPropertiesParams(propNames); int maxMemSize = this.maxInMemory; @@ -148,34 +134,6 @@ public class UtilCache<K, V> implements .listener(this) .build(); } - if (this.useFileSystemStore) { - // create the manager the first time it is needed - jdbmMgr = fileManagers.get(fileStore); - if (jdbmMgr == null) { - Debug.logImportant("Creating file system cache store for cache with name: " + cacheName, module); - try { - String ofbizHome = System.getProperty("ofbiz.home"); - if (ofbizHome == null) { - Debug.logError("No ofbiz.home property set in environment", module); - } else { - jdbmMgr = new JdbmRecordManager(ofbizHome + "/" + fileStore); - } - } catch (IOException e) { - Debug.logError(e, "Error creating file system cache store for cache with name: " + cacheName, module); - } - fileManagers.putIfAbsent(fileStore, jdbmMgr); - } - jdbmMgr = fileManagers.get(fileStore); - if (jdbmMgr != null) { - try { - this.fileTable = HTree.createInstance(jdbmMgr); - jdbmMgr.setNamedObject(cacheName, this.fileTable.getRecid()); - jdbmMgr.commit(); - } catch (IOException e) { - Debug.logError(e, module); - } - } - } } private static String getNextDefaultIndex(String cacheName) { @@ -233,14 +191,6 @@ public class UtilCache<K, V> implements if (value != null) { useSoftReference = "true".equals(value); } - value = getPropertyParam(res, propNames, "useFileSystemStore"); - if (value != null) { - useFileSystemStore = "true".equals(value); - } - value = getPropertyParam(res, new String[0], "cache.file.store"); - if (value != null) { - fileStore = value; - } } } @@ -253,31 +203,12 @@ public class UtilCache<K, V> implements return key == ObjectType.NULL ? null : (K) key; } - private void addAllFileTableKeys(Set<Object> keys) throws IOException { - FastIterator<Object> iter = fileTable.keys(); - Object key = null; - while ((key = iter.next()) != null) { - keys.add(key); - } - } - public Object getCacheLineTable() { throw new UnsupportedOperationException(); } public boolean isEmpty() { - if (fileTable != null) { - try { - synchronized (this) { - return fileTable.keys().next() == null; - } - } catch (IOException e) { - Debug.logError(e, module); - return false; - } - } else { - return memoryTable.isEmpty(); - } + return memoryTable.isEmpty(); } /** Puts or loads the passed element into the cache @@ -382,17 +313,6 @@ public class UtilCache<K, V> implements Object nulledKey = fromKey(key); CacheLine<V> oldCacheLine = memoryTable.put(nulledKey, createCacheLine(key, value, expireTimeNanos)); V oldValue = oldCacheLine == null ? null : cancel(oldCacheLine); - if (fileTable != null) { - try { - synchronized (this) { - if (oldValue == null) oldValue = fileTable.get(nulledKey); - fileTable.put(nulledKey, value); - jdbmMgr.commit(); - } - } catch (IOException e) { - Debug.logError(e, module); - } - } if (oldValue == null) { noteAddition(key, value); return null; @@ -405,29 +325,13 @@ public class UtilCache<K, V> implements V putIfAbsentInternal(K key, V value, long expireTimeNanos) { Object nulledKey = fromKey(key); V oldValue; - if (fileTable != null) { - try { - synchronized (this) { - oldValue = fileTable.get(nulledKey); - if (oldValue == null) { - memoryTable.put(nulledKey, createCacheLine(key, value, expireTimeNanos)); - fileTable.put(nulledKey, value); - jdbmMgr.commit(); - } - } - } catch (IOException e) { - Debug.logError(e, module); - oldValue = null; - } + CacheLine<V> newCacheLine = createCacheLine(key, value, expireTimeNanos); + CacheLine<V> oldCacheLine = memoryTable.putIfAbsent(nulledKey, newCacheLine); + if (oldCacheLine == null) { + oldValue = null; } else { - CacheLine<V> newCacheLine = createCacheLine(key, value, expireTimeNanos); - CacheLine<V> oldCacheLine = memoryTable.putIfAbsent(nulledKey, newCacheLine); - if (oldCacheLine == null) { - oldValue = null; - } else { - oldValue = oldCacheLine.getValue(); - cancel(newCacheLine); - } + oldValue = oldCacheLine.getValue(); + cancel(newCacheLine); } if (oldValue == null) { noteAddition(key, value); @@ -446,27 +350,7 @@ public class UtilCache<K, V> implements Object nulledKey = fromKey(key); CacheLine<V> line = memoryTable.get(nulledKey); if (line == null) { - if (fileTable != null) { - V value; - try { - synchronized (this) { - value = fileTable.get(nulledKey); - } - } catch (IOException e) { - Debug.logError(e, module); - value = null; - } - if (value == null) { - missCountNotFound.incrementAndGet(); - return null; - } else { - hitCount.incrementAndGet(); - } - memoryTable.put(nulledKey, createCacheLine(UtilGenerics.<K>cast(key), value, expireTimeNanos)); - return value; - } else { - missCountNotFound.incrementAndGet(); - } + missCountNotFound.incrementAndGet(); } else { if (countGet) hitCount.incrementAndGet(); } @@ -474,28 +358,11 @@ public class UtilCache<K, V> implements } public Collection<V> values() { - if (fileTable != null) { - List<V> values = new LinkedList<V>(); - try { - synchronized (this) { - FastIterator<V> iter = fileTable.values(); - V value = iter.next(); - while (value != null) { - values.add(value); - value = iter.next(); - } - } - } catch (IOException e) { - Debug.logError(e, module); - } - return values; - } else { - List<V> valuesList = new LinkedList<V>(); - for (CacheLine<V> line: memoryTable.values()) { - valuesList.add(line.getValue()); - } - return valuesList; + List<V> valuesList = new LinkedList<V>(); + for (CacheLine<V> line: memoryTable.values()) { + valuesList.add(line.getValue()); } + return valuesList; } private long findSizeInBytes(Object o) { @@ -525,24 +392,8 @@ public class UtilCache<K, V> implements public long getSizeInBytes() { long totalSize = 0; - if (fileTable != null) { - try { - synchronized (this) { - FastIterator<V> iter = fileTable.values(); - V value = iter.next(); - while (value != null) { - totalSize += findSizeInBytes(value); - value = iter.next(); - } - } - } catch (IOException e) { - Debug.logError(e, module); - return 0; - } - } else { - for (CacheLine<V> line: memoryTable.values()) { - totalSize += findSizeInBytes(line.getValue()); - } + for (CacheLine<V> line: memoryTable.values()) { + totalSize += findSizeInBytes(line.getValue()); } return totalSize; } @@ -564,27 +415,8 @@ public class UtilCache<K, V> implements Object nulledKey = fromKey(key); CacheLine<V> oldCacheLine; V oldValue; - if (fileTable != null) { - try { - synchronized (this) { - try { - oldValue = fileTable.get(nulledKey); - } catch (IOException e) { - oldValue = null; - throw e; - } - fileTable.remove(nulledKey); - jdbmMgr.commit(); - } - } catch (IOException e) { - oldValue = null; - Debug.logError(e, module); - } - oldCacheLine = memoryTable.remove(nulledKey); - } else { - oldCacheLine = memoryTable.remove(nulledKey); - oldValue = oldCacheLine != null ? oldCacheLine.getValue() : null; - } + oldCacheLine = memoryTable.remove(nulledKey); + oldValue = oldCacheLine != null ? oldCacheLine.getValue() : null; if (oldCacheLine != null) { cancel(oldCacheLine); } @@ -604,51 +436,17 @@ public class UtilCache<K, V> implements if (!memoryTable.remove(nulledKey, existingCacheLine)) { return; } - if (fileTable != null) { - try { - synchronized (this) { - fileTable.remove(nulledKey); - jdbmMgr.commit(); - } - } catch (IOException e) { - Debug.logError(e, module); - } - } noteRemoval(UtilGenerics.<K>cast(key), existingCacheLine.getValue()); } /** Removes all elements from this cache */ public synchronized void erase() { - if (fileTable != null) { - // FIXME: erase from memory too - synchronized (this) { - Set<Object> keys = new HashSet<Object>(); - try { - addAllFileTableKeys(keys); - } catch (IOException e) { - Debug.logError(e, module); - } - for (Object key: keys) { - try { - V value = fileTable.get(key); - noteRemoval(toKey(key), value); - removeHitCount.incrementAndGet(); - fileTable.remove(key); - jdbmMgr.commit(); - } catch (IOException e) { - Debug.logError(e, module); - } - } - } - memoryTable.clear(); - } else { - Iterator<Map.Entry<Object, CacheLine<V>>> it = memoryTable.entrySet().iterator(); - while (it.hasNext()) { - Map.Entry<Object, CacheLine<V>> entry = it.next(); - noteRemoval(toKey(entry.getKey()), entry.getValue().getValue()); - removeHitCount.incrementAndGet(); - it.remove(); - } + Iterator<Map.Entry<Object, CacheLine<V>>> it = memoryTable.entrySet().iterator(); + while (it.hasNext()) { + Map.Entry<Object, CacheLine<V>> entry = it.next(); + noteRemoval(toKey(entry.getKey()), entry.getValue().getValue()); + removeHitCount.incrementAndGet(); + it.remove(); } } @@ -803,30 +601,11 @@ public class UtilCache<K, V> implements return this.useSoftReference; } - public boolean getUseFileSystemStore() { - return this.useFileSystemStore; - } - /** Returns the number of elements currently in the cache * @return The number of elements currently in the cache */ public int size() { - if (fileTable != null) { - int size = 0; - try { - synchronized (this) { - FastIterator<Object> iter = fileTable.keys(); - while (iter.next() != null) { - size++; - } - } - } catch (IOException e) { - Debug.logError(e, module); - } - return size; - } else { - return memoryTable.size(); - } + return memoryTable.size(); } /** Returns a boolean specifying whether or not an element with the specified key is in the cache. @@ -836,26 +615,7 @@ public class UtilCache<K, V> implements public boolean containsKey(Object key) { Object nulledKey = fromKey(key); CacheLine<V> line = memoryTable.get(nulledKey); - if (line == null) { - if (fileTable != null) { - try { - synchronized (this) { - FastIterator<Object> iter = fileTable.keys(); - Object checkKey = null; - while ((checkKey = iter.next()) != null) { - if (nulledKey.equals(checkKey)) { - return true; - } - } - } - } catch (IOException e) { - Debug.logError(e, module); - } - } - return false; - } else { - return true; - } + return line != null; } /** @@ -867,27 +627,14 @@ public class UtilCache<K, V> implements // note that this must be a HashSet and not a FastSet in order to have a null value Set<Object> keys; - if (fileTable != null) { - keys = new HashSet<Object>(); - try { - synchronized (this) { - addAllFileTableKeys(keys); - } - } catch (IOException e) { - Debug.logError(e, module); - } - if (keys.remove(ObjectType.NULL)) { - keys.add(null); - } + if (memoryTable.containsKey(ObjectType.NULL)) { + keys = new HashSet<Object>(memoryTable.keySet()); + keys.remove(ObjectType.NULL); + keys.add(null); } else { - if (memoryTable.containsKey(ObjectType.NULL)) { - keys = new HashSet<Object>(memoryTable.keySet()); - keys.remove(ObjectType.NULL); - keys.add(null); - } else { - keys = memoryTable.keySet(); - } + keys = memoryTable.keySet(); } + return Collections.unmodifiableSet(UtilGenerics.<Set<? extends K>>cast(keys)); } @@ -920,19 +667,9 @@ public class UtilCache<K, V> implements int keyIndex = 0; for (K key: getCacheLineKeys()) { Object nulledKey = fromKey(key); - if (fileTable != null) { - try { - synchronized (this) { - lineInfos.add(createLineInfo(keyIndex, key, fileTable.get(nulledKey))); - } - } catch (IOException e) { - Debug.logError(e, module); - } - } else { - CacheLine<V> line = memoryTable.get(nulledKey); - if (line != null) { - lineInfos.add(createLineInfo(keyIndex, key, line)); - } + CacheLine<V> line = memoryTable.get(nulledKey); + if (line != null) { + lineInfos.add(createLineInfo(keyIndex, key, line)); } keyIndex++; } @@ -997,53 +734,53 @@ public class UtilCache<K, V> implements } @SuppressWarnings("unchecked") - public static <K, V> UtilCache<K, V> getOrCreateUtilCache(String name, int sizeLimit, int maxInMemory, long expireTime, boolean useSoftReference, boolean useFileSystemStore, String... names) { + public static <K, V> UtilCache<K, V> getOrCreateUtilCache(String name, int sizeLimit, int maxInMemory, long expireTime, boolean useSoftReference, String... names) { UtilCache<K, V> existingCache = (UtilCache<K, V>) utilCacheTable.get(name); if (existingCache != null) return existingCache; String cacheName = name + getNextDefaultIndex(name); - UtilCache<K, V> newCache = new UtilCache<K, V>(cacheName, sizeLimit, maxInMemory, expireTime, useSoftReference, useFileSystemStore, name, names); + UtilCache<K, V> newCache = new UtilCache<K, V>(cacheName, sizeLimit, maxInMemory, expireTime, useSoftReference, name, names); utilCacheTable.putIfAbsent(name, newCache); return (UtilCache<K, V>) utilCacheTable.get(name); } - public static <K, V> UtilCache<K, V> createUtilCache(String name, int sizeLimit, int maxInMemory, long expireTime, boolean useSoftReference, boolean useFileSystemStore, String... names) { + public static <K, V> UtilCache<K, V> createUtilCache(String name, int sizeLimit, int maxInMemory, long expireTime, boolean useSoftReference, String... names) { String cacheName = name + getNextDefaultIndex(name); - return storeCache(new UtilCache<K, V>(cacheName, sizeLimit, maxInMemory, expireTime, useSoftReference, useFileSystemStore, name, names)); + return storeCache(new UtilCache<K, V>(cacheName, sizeLimit, maxInMemory, expireTime, useSoftReference, name, names)); } - public static <K, V> UtilCache<K, V> createUtilCache(String name, int sizeLimit, int maxInMemory, long expireTime, boolean useSoftReference, boolean useFileSystemStore) { + public static <K, V> UtilCache<K, V> createUtilCache(String name, int sizeLimit, int maxInMemory, long expireTime, boolean useSoftReference) { String cacheName = name + getNextDefaultIndex(name); - return storeCache(new UtilCache<K, V>(cacheName, sizeLimit, maxInMemory, expireTime, useSoftReference, useFileSystemStore, name)); + return storeCache(new UtilCache<K, V>(cacheName, sizeLimit, maxInMemory, expireTime, useSoftReference, name)); } public static <K,V> UtilCache<K, V> createUtilCache(String name, int sizeLimit, long expireTime, boolean useSoftReference) { String cacheName = name + getNextDefaultIndex(name); - return storeCache(new UtilCache<K, V>(cacheName, sizeLimit, sizeLimit, expireTime, useSoftReference, false, name)); + return storeCache(new UtilCache<K, V>(cacheName, sizeLimit, sizeLimit, expireTime, useSoftReference, name)); } public static <K,V> UtilCache<K, V> createUtilCache(String name, int sizeLimit, long expireTime) { String cacheName = name + getNextDefaultIndex(name); - return storeCache(new UtilCache<K, V>(cacheName, sizeLimit, sizeLimit, expireTime, false, false, name)); + return storeCache(new UtilCache<K, V>(cacheName, sizeLimit, sizeLimit, expireTime, false, name)); } public static <K,V> UtilCache<K, V> createUtilCache(int sizeLimit, long expireTime) { String cacheName = "specified" + getNextDefaultIndex("specified"); - return storeCache(new UtilCache<K, V>(cacheName, sizeLimit, sizeLimit, expireTime, false, false, "specified")); + return storeCache(new UtilCache<K, V>(cacheName, sizeLimit, sizeLimit, expireTime, false, "specified")); } public static <K,V> UtilCache<K, V> createUtilCache(String name, boolean useSoftReference) { String cacheName = name + getNextDefaultIndex(name); - return storeCache(new UtilCache<K, V>(cacheName, 0, 0, 0, useSoftReference, false, "default", name)); + return storeCache(new UtilCache<K, V>(cacheName, 0, 0, 0, useSoftReference, "default", name)); } public static <K,V> UtilCache<K, V> createUtilCache(String name) { String cacheName = name + getNextDefaultIndex(name); - return storeCache(new UtilCache<K, V>(cacheName, 0, 0, 0, false, false, "default", name)); + return storeCache(new UtilCache<K, V>(cacheName, 0, 0, 0, false, "default", name)); } public static <K,V> UtilCache<K, V> createUtilCache() { String cacheName = "default" + getNextDefaultIndex("default"); - return storeCache(new UtilCache<K, V>(cacheName, 0, 0, 0, false, false, "default")); + return storeCache(new UtilCache<K, V>(cacheName, 0, 0, 0, false, "default")); } private static <K, V> UtilCache<K, V> storeCache(UtilCache<K, V> cache) { Modified: ofbiz/trunk/framework/base/src/org/ofbiz/base/util/cache/test/UtilCacheTests.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/base/src/org/ofbiz/base/util/cache/test/UtilCacheTests.java?rev=1751817&r1=1751816&r2=1751817&view=diff ============================================================================== --- ofbiz/trunk/framework/base/src/org/ofbiz/base/util/cache/test/UtilCacheTests.java (original) +++ ofbiz/trunk/framework/base/src/org/ofbiz/base/util/cache/test/UtilCacheTests.java Thu Jul 7 17:00:05 2016 @@ -160,11 +160,11 @@ public class UtilCacheTests extends Gene super(name); } - private <K, V> UtilCache<K, V> createUtilCache(int sizeLimit, int maxInMemory, long ttl, boolean useSoftReference, boolean useFileSystemStore) { - return UtilCache.createUtilCache(getClass().getName() + "." + getName(), sizeLimit, maxInMemory, ttl, useSoftReference, useFileSystemStore); + private <K, V> UtilCache<K, V> createUtilCache(int sizeLimit, int maxInMemory, long ttl, boolean useSoftReference) { + return UtilCache.createUtilCache(getClass().getName() + "." + getName(), sizeLimit, maxInMemory, ttl, useSoftReference); } - private static <K, V> void assertUtilCacheSettings(UtilCache<K, V> cache, Integer sizeLimit, Integer maxInMemory, Long expireTime, Boolean useSoftReference, Boolean useFileSystemStore) { + private static <K, V> void assertUtilCacheSettings(UtilCache<K, V> cache, Integer sizeLimit, Integer maxInMemory, Long expireTime, Boolean useSoftReference) { if (sizeLimit != null) { assertEquals(cache.getName() + ":sizeLimit", sizeLimit.intValue(), cache.getSizeLimit()); } @@ -177,9 +177,6 @@ public class UtilCacheTests extends Gene if (useSoftReference != null) { assertEquals(cache.getName() + ":useSoftReference", useSoftReference.booleanValue(), cache.getUseSoftReference()); } - if (useFileSystemStore != null) { - assertEquals(cache.getName() + ":useFileSystemStore", useFileSystemStore.booleanValue(), cache.getUseFileSystemStore()); - } assertEquals("initial empty", true, cache.isEmpty()); assertEquals("empty keys", Collections.emptySet(), cache.getCacheLineKeys()); assertEquals("empty values", Collections.emptyList(), cache.values()); @@ -189,18 +186,18 @@ public class UtilCacheTests extends Gene public void testCreateUtilCache() { String name = getClass().getName() + "." + getName(); - assertUtilCacheSettings(UtilCache.createUtilCache(), null, null, null, null, null); - assertUtilCacheSettings(UtilCache.createUtilCache(name), null, null, null, null, null); - assertUtilCacheSettings(UtilCache.createUtilCache(name, false), null, null, null, Boolean.FALSE, null); - assertUtilCacheSettings(UtilCache.createUtilCache(name, true), null, null, null, Boolean.TRUE, null); - assertUtilCacheSettings(UtilCache.createUtilCache(5, 15000), 5, null, 15000L, null, null); - assertUtilCacheSettings(UtilCache.createUtilCache(name, 6, 16000), 6, null, 16000L, null, null); - assertUtilCacheSettings(UtilCache.createUtilCache(name, 7, 17000, false), 7, null, 17000L, Boolean.FALSE, null); - assertUtilCacheSettings(UtilCache.createUtilCache(name, 8, 18000, true), 8, null, 18000L, Boolean.TRUE, null); - assertUtilCacheSettings(UtilCache.createUtilCache(name, 9, 5, 19000, false, false), 9, 5, 19000L, Boolean.FALSE, null); - assertUtilCacheSettings(UtilCache.createUtilCache(name, 10, 6, 20000, false, true), 10, 6, 20000L, Boolean.FALSE, null); - assertUtilCacheSettings(UtilCache.createUtilCache(name, 11, 7, 21000, false, false, "a", "b"), 11, 7, 21000L, Boolean.FALSE, Boolean.FALSE); - assertUtilCacheSettings(UtilCache.createUtilCache(name, 12, 8, 22000, false, true, "c", "d"), 12, 8, 22000L, Boolean.FALSE, Boolean.TRUE); + assertUtilCacheSettings(UtilCache.createUtilCache(), null, null, null, null); + assertUtilCacheSettings(UtilCache.createUtilCache(name), null, null, null, null); + assertUtilCacheSettings(UtilCache.createUtilCache(name, false), null, null, null, Boolean.FALSE); + assertUtilCacheSettings(UtilCache.createUtilCache(name, true), null, null, null, Boolean.TRUE); + assertUtilCacheSettings(UtilCache.createUtilCache(5, 15000), 5, null, 15000L, null); + assertUtilCacheSettings(UtilCache.createUtilCache(name, 6, 16000), 6, null, 16000L, null); + assertUtilCacheSettings(UtilCache.createUtilCache(name, 7, 17000, false), 7, null, 17000L, Boolean.FALSE); + assertUtilCacheSettings(UtilCache.createUtilCache(name, 8, 18000, true), 8, null, 18000L, Boolean.TRUE); + assertUtilCacheSettings(UtilCache.createUtilCache(name, 9, 5, 19000, false), 9, 5, 19000L, Boolean.FALSE); + assertUtilCacheSettings(UtilCache.createUtilCache(name, 10, 6, 20000, false), 10, 6, 20000L, Boolean.FALSE); + assertUtilCacheSettings(UtilCache.createUtilCache(name, 11, 7, 21000, false, "a", "b"), 11, 7, 21000L, Boolean.FALSE); + assertUtilCacheSettings(UtilCache.createUtilCache(name, 12, 8, 22000, false, "c", "d"), 12, 8, 22000L, Boolean.FALSE); } public static <K, V> void assertKey(String label, UtilCache<K, V> cache, K key, V value, V other, int size, Map<K, V> map) { @@ -249,7 +246,7 @@ public class UtilCacheTests extends Gene for (int i = 0; i < 2; i++) { assertTrue("UtilCacheTable.keySet", UtilCache.getUtilCacheTableKeySet().contains(cache.getName())); assertSame("UtilCache.findCache", cache, UtilCache.findCache(cache.getName())); - assertSame("UtilCache.getOrCreateUtilCache", cache, UtilCache.getOrCreateUtilCache(cache.getName(), cache.getSizeLimit(), cache.getMaxInMemory(), cache.getExpireTime(), cache.getUseSoftReference(), cache.getUseFileSystemStore())); + assertSame("UtilCache.getOrCreateUtilCache", cache, UtilCache.getOrCreateUtilCache(cache.getName(), cache.getSizeLimit(), cache.getMaxInMemory(), cache.getExpireTime(), cache.getUseSoftReference())); assertNoSingleKey(cache, "one"); long origByteSize = cache.getSizeInBytes(); @@ -316,18 +313,13 @@ public class UtilCacheTests extends Gene UtilCache.clearCache(":::" + cache.getName()); } - public void testBasicDisk() throws Exception { - UtilCache<String, String> cache = createUtilCache(5, 0, 0, false, true); - basicTest(cache); - } - public void testSimple() throws Exception { - UtilCache<String, String> cache = createUtilCache(5, 0, 0, false, false); + UtilCache<String, String> cache = createUtilCache(5, 0, 0, false); basicTest(cache); } public void testPutIfAbsent() throws Exception { - UtilCache<String, String> cache = createUtilCache(5, 5, 2000, false, false); + UtilCache<String, String> cache = createUtilCache(5, 5, 2000, false); Listener<String, String> gotListener = createListener(cache); Listener<String, String> wantedListener = new Listener<String, String>(); wantedListener.noteKeyAddition(cache, "two", "dos"); @@ -340,7 +332,7 @@ public class UtilCacheTests extends Gene } public void testPutIfAbsentAndGet() throws Exception { - UtilCache<String, String> cache = createUtilCache(5, 5, 2000, false, false); + UtilCache<String, String> cache = createUtilCache(5, 5, 2000, false); Listener<String, String> gotListener = createListener(cache); Listener<String, String> wantedListener = new Listener<String, String>(); wantedListener.noteKeyAddition(cache, "key", "value"); @@ -366,7 +358,7 @@ public class UtilCacheTests extends Gene public void testChangeMemSize() throws Exception { int size = 5; long ttl = 2000; - UtilCache<String, Serializable> cache = createUtilCache(size, size, ttl, false, false); + UtilCache<String, Serializable> cache = createUtilCache(size, size, ttl, false); Map<String, Serializable> map = new HashMap<String, Serializable>(); for (int i = 0; i < size; i++) { String s = Integer.toString(i); @@ -420,13 +412,13 @@ public class UtilCacheTests extends Gene } public void testExpire() throws Exception { - UtilCache<String, Serializable> cache = createUtilCache(5, 5, 2000, false, false); + UtilCache<String, Serializable> cache = createUtilCache(5, 5, 2000, false); expireTest(cache, 5, 2000); long start = System.currentTimeMillis(); useAllMemory(); long end = System.currentTimeMillis(); long ttl = end - start + 1000; - cache = createUtilCache(1, 1, ttl, true, false); + cache = createUtilCache(1, 1, ttl, true); expireTest(cache, 1, ttl); assertFalse("not empty", cache.isEmpty()); useAllMemory(); 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=1751817&r1=1751816&r2=1751817&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 Thu Jul 7 17:00:05 2016 @@ -77,6 +77,6 @@ public abstract class AbstractCache<K, V protected UtilCache<K, V> getOrCreateCache(String entityName) { String name = getCacheName(entityName); - return UtilCache.getOrCreateUtilCache(name, 0, 0, 0, true, false, getCacheNames(entityName)); + return UtilCache.getOrCreateUtilCache(name, 0, 0, 0, true, getCacheNames(entityName)); } } Modified: ofbiz/trunk/framework/service/src/org/ofbiz/service/rmi/ExampleRemoteClient.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/service/src/org/ofbiz/service/rmi/ExampleRemoteClient.java?rev=1751817&r1=1751816&r2=1751817&view=diff ============================================================================== --- ofbiz/trunk/framework/service/src/org/ofbiz/service/rmi/ExampleRemoteClient.java (original) +++ ofbiz/trunk/framework/service/src/org/ofbiz/service/rmi/ExampleRemoteClient.java Thu Jul 7 17:00:05 2016 @@ -38,7 +38,6 @@ import org.ofbiz.service.GenericServiceE * * The following third-party libraries (can be found in OFBiz) also need to be on the client's classpath: * commons-collections.jar - * jdbm.jar * log4j.jar * * Copy the truststore file framework/base/config/ofbizrmi-truststore.jks to the client Modified: ofbiz/trunk/framework/webtools/groovyScripts/cache/EditUtilCache.groovy URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/webtools/groovyScripts/cache/EditUtilCache.groovy?rev=1751817&r1=1751816&r2=1751817&view=diff ============================================================================== --- ofbiz/trunk/framework/webtools/groovyScripts/cache/EditUtilCache.groovy (original) +++ ofbiz/trunk/framework/webtools/groovyScripts/cache/EditUtilCache.groovy Thu Jul 7 17:00:05 2016 @@ -41,7 +41,6 @@ if (cacheName) { cache.maxInMemory = UtilFormatOut.formatQuantity(utilCache.getMaxInMemory()); cache.expireTime = UtilFormatOut.formatQuantity(utilCache.getExpireTime()); cache.useSoftReference = utilCache.getUseSoftReference().toString(); - cache.useFileSystemStore = utilCache.getUseFileSystemStore().toString(); exp = utilCache.getExpireTime(); hrs = Math.floor(exp / (60 * 60 * 1000)); Modified: ofbiz/trunk/framework/webtools/groovyScripts/cache/FindUtilCache.groovy URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/webtools/groovyScripts/cache/FindUtilCache.groovy?rev=1751817&r1=1751816&r2=1751817&view=diff ============================================================================== --- ofbiz/trunk/framework/webtools/groovyScripts/cache/FindUtilCache.groovy (original) +++ ofbiz/trunk/framework/webtools/groovyScripts/cache/FindUtilCache.groovy Thu Jul 7 17:00:05 2016 @@ -42,8 +42,6 @@ names.each { cacheName -> cache.maxInMemory = UtilFormatOut.formatQuantity(utilCache.getMaxInMemory()); cache.expireTime = UtilFormatOut.formatQuantity(utilCache.getExpireTime()); cache.useSoftReference = utilCache.getUseSoftReference().toString(); - cache.useFileSystemStore = utilCache.getUseFileSystemStore().toString(); - cache.useFileSystemStore = utilCache.getUseFileSystemStore().toString(); cache.cacheMemory = utilCache.getSizeInBytes(); totalCacheMemory += cache.cacheMemory; cacheList.add(cache); Modified: ofbiz/trunk/framework/webtools/widget/CacheForms.xml URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/webtools/widget/CacheForms.xml?rev=1751817&r1=1751816&r2=1751817&view=diff ============================================================================== --- ofbiz/trunk/framework/webtools/widget/CacheForms.xml (original) +++ ofbiz/trunk/framework/webtools/widget/CacheForms.xml Thu Jul 7 17:00:05 2016 @@ -37,7 +37,6 @@ under the License. <field name="maxInMemory" title="${uiLabelMap.WebtoolsMaxInMemory}" sort-field="true"><display/></field> <field name="expireTime" title="${uiLabelMap.WebtoolsExpireTime}" sort-field="true"><display/></field> <field name="useSoftReference" title="${uiLabelMap.WebtoolsUseSoftRef}" sort-field="true"><display/></field> - <field name="useFileSystemStore" title="${uiLabelMap.WebtoolsUseFileStore}" sort-field="true"><display/></field> <field name="cacheMemory" title="${uiLabelMap.WebtoolsCacheMemory}" sort-field="true"><display/></field> <field name="cacheMenu" title=" " use-when="hasUtilCacheEdit"><include-menu name="ListCacheForm" location="component://webtools/widget/Menus.xml"/></field> </grid> @@ -73,7 +72,6 @@ under the License. <option key="true" description="${uiLabelMap.CommonTrue}"/> </drop-down> </field> - <field name="useFileSystemStore" title="${uiLabelMap.WebtoolsUseFileStore}"><display/></field> <field name="submitButton" title="${uiLabelMap.CommonApply}"><submit button-type="button"/></field> </form> </forms> Modified: ofbiz/trunk/framework/widget/src/org/ofbiz/widget/cache/AbstractCache.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/widget/src/org/ofbiz/widget/cache/AbstractCache.java?rev=1751817&r1=1751816&r2=1751817&view=diff ============================================================================== --- ofbiz/trunk/framework/widget/src/org/ofbiz/widget/cache/AbstractCache.java (original) +++ ofbiz/trunk/framework/widget/src/org/ofbiz/widget/cache/AbstractCache.java Thu Jul 7 17:00:05 2016 @@ -50,6 +50,6 @@ public abstract class AbstractCache { protected UtilCache<WidgetContextCacheKey, GenericWidgetOutput> getOrCreateCache(String widgetName) { String name = getCacheName(widgetName); - return UtilCache.getOrCreateUtilCache(name, 0, 0, 0, true, false, name); + return UtilCache.getOrCreateUtilCache(name, 0, 0, 0, true, name); } } Modified: ofbiz/trunk/specialpurpose/pos/src/org/ofbiz/pos/config/ButtonEventConfig.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/specialpurpose/pos/src/org/ofbiz/pos/config/ButtonEventConfig.java?rev=1751817&r1=1751816&r2=1751817&view=diff ============================================================================== --- ofbiz/trunk/specialpurpose/pos/src/org/ofbiz/pos/config/ButtonEventConfig.java (original) +++ ofbiz/trunk/specialpurpose/pos/src/org/ofbiz/pos/config/ButtonEventConfig.java Thu Jul 7 17:00:05 2016 @@ -43,7 +43,7 @@ public class ButtonEventConfig implement public static final String module = ButtonEventConfig.class.getName(); public static final String BUTTON_EVENT_CONFIG = "buttonevents.xml"; - private static transient UtilCache<String, ButtonEventConfig> buttonConfig = UtilCache.createUtilCache("pos.ButtonEvent", 0, 0, 0, false, true); + private static transient UtilCache<String, ButtonEventConfig> buttonConfig = UtilCache.createUtilCache("pos.ButtonEvent", 0, 0, 0, false); protected String buttonName = null; protected String className = null; |
Free forum by Nabble | Edit this page |