Modified: commons/proper/jcs/trunk/commons-jcs-core/src/main/java/org/apache/commons/jcs/engine/match/KeyMatcherPatternImpl.java URL: http://svn.apache.org/viewvc/commons/proper/jcs/trunk/commons-jcs-core/src/main/java/org/apache/commons/jcs/engine/match/KeyMatcherPatternImpl.java?rev=1593843&r1=1593842&r2=1593843&view=diff ============================================================================== --- commons/proper/jcs/trunk/commons-jcs-core/src/main/java/org/apache/commons/jcs/engine/match/KeyMatcherPatternImpl.java (original) +++ commons/proper/jcs/trunk/commons-jcs-core/src/main/java/org/apache/commons/jcs/engine/match/KeyMatcherPatternImpl.java Sun May 11 19:43:30 2014 @@ -19,16 +19,15 @@ package org.apache.commons.jcs.engine.ma * under the License. */ -import java.io.Serializable; +import org.apache.commons.jcs.engine.match.behavior.IKeyMatcher; + import java.util.HashSet; import java.util.Set; import java.util.regex.Matcher; import java.util.regex.Pattern; -import org.apache.commons.jcs.engine.match.behavior.IKeyMatcher; - /** This implementation of the KeyMatcher uses standard Java Pattern matching. */ -public class KeyMatcherPatternImpl<K extends Serializable> +public class KeyMatcherPatternImpl<K> implements IKeyMatcher<K> { /** Serial version */
Modified: commons/proper/jcs/trunk/commons-jcs-core/src/main/java/org/apache/commons/jcs/engine/match/behavior/IKeyMatcher.java URL: http://svn.apache.org/viewvc/commons/proper/jcs/trunk/commons-jcs-core/src/main/java/org/apache/commons/jcs/engine/match/behavior/IKeyMatcher.java?rev=1593843&r1=1593842&r2=1593843&view=diff ============================================================================== --- commons/proper/jcs/trunk/commons-jcs-core/src/main/java/org/apache/commons/jcs/engine/match/behavior/IKeyMatcher.java (original) +++ commons/proper/jcs/trunk/commons-jcs-core/src/main/java/org/apache/commons/jcs/engine/match/behavior/IKeyMatcher.java Sun May 11 19:43:30 2014 @@ -23,7 +23,7 @@ import java.io.Serializable; import java.util.Set; /** Key matchers need to implement this interface. */ -public interface IKeyMatcher<K extends Serializable> extends Serializable +public interface IKeyMatcher<K> extends Serializable { /** * Creates a pattern and find matches on the array. Modified: commons/proper/jcs/trunk/commons-jcs-core/src/main/java/org/apache/commons/jcs/engine/memory/AbstractDoubleLinkedListMemoryCache.java URL: http://svn.apache.org/viewvc/commons/proper/jcs/trunk/commons-jcs-core/src/main/java/org/apache/commons/jcs/engine/memory/AbstractDoubleLinkedListMemoryCache.java?rev=1593843&r1=1593842&r2=1593843&view=diff ============================================================================== --- commons/proper/jcs/trunk/commons-jcs-core/src/main/java/org/apache/commons/jcs/engine/memory/AbstractDoubleLinkedListMemoryCache.java (original) +++ commons/proper/jcs/trunk/commons-jcs-core/src/main/java/org/apache/commons/jcs/engine/memory/AbstractDoubleLinkedListMemoryCache.java Sun May 11 19:43:30 2014 @@ -50,7 +50,7 @@ import org.apache.commons.logging.LogFac * the list will be the one removed when the list fills. For instance LRU should more items to the * front as they are used. FIFO should simply add new items to the front of the list. */ -public abstract class AbstractDoubleLinkedListMemoryCache<K extends Serializable, V extends Serializable> +public abstract class AbstractDoubleLinkedListMemoryCache<K, V> extends AbstractMemoryCache<K, V> { /** Don't change. */ @@ -511,7 +511,7 @@ public abstract class AbstractDoubleLink } log.debug( "verifycache: checking via keysets!" ); - for (Serializable val : map.keySet()) + for (Object val : map.keySet()) { found = false; Modified: commons/proper/jcs/trunk/commons-jcs-core/src/main/java/org/apache/commons/jcs/engine/memory/AbstractMemoryCache.java URL: http://svn.apache.org/viewvc/commons/proper/jcs/trunk/commons-jcs-core/src/main/java/org/apache/commons/jcs/engine/memory/AbstractMemoryCache.java?rev=1593843&r1=1593842&r2=1593843&view=diff ============================================================================== --- commons/proper/jcs/trunk/commons-jcs-core/src/main/java/org/apache/commons/jcs/engine/memory/AbstractMemoryCache.java (original) +++ commons/proper/jcs/trunk/commons-jcs-core/src/main/java/org/apache/commons/jcs/engine/memory/AbstractMemoryCache.java Sun May 11 19:43:30 2014 @@ -43,7 +43,7 @@ import org.apache.commons.logging.LogFac * This keeps a static reference to a memory shrinker clock daemon. If this region is configured to * use the shrinker, the clock daemon will be setup to run the shrinker on this region. */ -public abstract class AbstractMemoryCache<K extends Serializable, V extends Serializable> +public abstract class AbstractMemoryCache<K, V> implements IMemoryCache<K, V> { /** Log instance */ Modified: commons/proper/jcs/trunk/commons-jcs-core/src/main/java/org/apache/commons/jcs/engine/memory/behavior/IMemoryCache.java URL: http://svn.apache.org/viewvc/commons/proper/jcs/trunk/commons-jcs-core/src/main/java/org/apache/commons/jcs/engine/memory/behavior/IMemoryCache.java?rev=1593843&r1=1593842&r2=1593843&view=diff ============================================================================== --- commons/proper/jcs/trunk/commons-jcs-core/src/main/java/org/apache/commons/jcs/engine/memory/behavior/IMemoryCache.java (original) +++ commons/proper/jcs/trunk/commons-jcs-core/src/main/java/org/apache/commons/jcs/engine/memory/behavior/IMemoryCache.java Sun May 11 19:43:30 2014 @@ -30,7 +30,7 @@ import org.apache.commons.jcs.engine.con import org.apache.commons.jcs.engine.stats.behavior.IStats; /** For the framework. Insures methods a MemoryCache needs to access. */ -public interface IMemoryCache<K extends Serializable, V extends Serializable> +public interface IMemoryCache<K, V> { /** * Initialize the memory cache Modified: commons/proper/jcs/trunk/commons-jcs-core/src/main/java/org/apache/commons/jcs/engine/memory/lru/LRUMemoryCache.java URL: http://svn.apache.org/viewvc/commons/proper/jcs/trunk/commons-jcs-core/src/main/java/org/apache/commons/jcs/engine/memory/lru/LRUMemoryCache.java?rev=1593843&r1=1593842&r2=1593843&view=diff ============================================================================== --- commons/proper/jcs/trunk/commons-jcs-core/src/main/java/org/apache/commons/jcs/engine/memory/lru/LRUMemoryCache.java (original) +++ commons/proper/jcs/trunk/commons-jcs-core/src/main/java/org/apache/commons/jcs/engine/memory/lru/LRUMemoryCache.java Sun May 11 19:43:30 2014 @@ -37,7 +37,7 @@ import org.apache.commons.jcs.engine.mem * The LRUMemoryCache is most efficient when the first element is selected. The smaller the region, * the better the chance that this will be the case. < .04 ms per put, p3 866, 1/10 of that per get */ -public class LRUMemoryCache<K extends Serializable, V extends Serializable> +public class LRUMemoryCache<K, V> extends AbstractDoubleLinkedListMemoryCache<K, V> { /** Don't change */ Modified: commons/proper/jcs/trunk/commons-jcs-core/src/main/java/org/apache/commons/jcs/engine/memory/shrinking/ShrinkerThread.java URL: http://svn.apache.org/viewvc/commons/proper/jcs/trunk/commons-jcs-core/src/main/java/org/apache/commons/jcs/engine/memory/shrinking/ShrinkerThread.java?rev=1593843&r1=1593842&r2=1593843&view=diff ============================================================================== --- commons/proper/jcs/trunk/commons-jcs-core/src/main/java/org/apache/commons/jcs/engine/memory/shrinking/ShrinkerThread.java (original) +++ commons/proper/jcs/trunk/commons-jcs-core/src/main/java/org/apache/commons/jcs/engine/memory/shrinking/ShrinkerThread.java Sun May 11 19:43:30 2014 @@ -19,9 +19,6 @@ package org.apache.commons.jcs.engine.me * under the License. */ -import java.io.Serializable; -import java.util.Set; - import org.apache.commons.jcs.engine.behavior.ICacheElement; import org.apache.commons.jcs.engine.behavior.IElementAttributes; import org.apache.commons.jcs.engine.control.CompositeCache; @@ -30,12 +27,14 @@ import org.apache.commons.jcs.engine.mem import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; +import java.util.Set; + /** * A background memory shrinker. Memory problems and concurrent modification exception caused by * acting directly on an iterator of the underlying memory cache should have been solved. * @version $Id$ */ -public class ShrinkerThread<K extends Serializable, V extends Serializable> +public class ShrinkerThread<K, V> implements Runnable { /** The logger */ Modified: commons/proper/jcs/trunk/commons-jcs-core/src/main/java/org/apache/commons/jcs/engine/memory/util/MemoryElementDescriptor.java URL: http://svn.apache.org/viewvc/commons/proper/jcs/trunk/commons-jcs-core/src/main/java/org/apache/commons/jcs/engine/memory/util/MemoryElementDescriptor.java?rev=1593843&r1=1593842&r2=1593843&view=diff ============================================================================== --- commons/proper/jcs/trunk/commons-jcs-core/src/main/java/org/apache/commons/jcs/engine/memory/util/MemoryElementDescriptor.java (original) +++ commons/proper/jcs/trunk/commons-jcs-core/src/main/java/org/apache/commons/jcs/engine/memory/util/MemoryElementDescriptor.java Sun May 11 19:43:30 2014 @@ -19,15 +19,13 @@ package org.apache.commons.jcs.engine.me * under the License. */ -import java.io.Serializable; - import org.apache.commons.jcs.engine.behavior.ICacheElement; import org.apache.commons.jcs.utils.struct.DoubleLinkedListNode; /** * This wrapper is needed for double linked lists. */ -public class MemoryElementDescriptor<K extends Serializable, V extends Serializable> +public class MemoryElementDescriptor<K, V> extends DoubleLinkedListNode<ICacheElement<K, V>> { /** Don't change */ Modified: commons/proper/jcs/trunk/commons-jcs-core/src/main/java/org/apache/commons/jcs/utils/serialization/CompressingSerializer.java URL: http://svn.apache.org/viewvc/commons/proper/jcs/trunk/commons-jcs-core/src/main/java/org/apache/commons/jcs/utils/serialization/CompressingSerializer.java?rev=1593843&r1=1593842&r2=1593843&view=diff ============================================================================== --- commons/proper/jcs/trunk/commons-jcs-core/src/main/java/org/apache/commons/jcs/utils/serialization/CompressingSerializer.java (original) +++ commons/proper/jcs/trunk/commons-jcs-core/src/main/java/org/apache/commons/jcs/utils/serialization/CompressingSerializer.java Sun May 11 19:43:30 2014 @@ -45,7 +45,7 @@ public class CompressingSerializer * @throws IOException on i/o problem */ @Override - public <T extends Serializable> byte[] serialize( T obj ) + public <T> byte[] serialize( T obj ) throws IOException { byte[] uncompressed = serializeObject( obj ); @@ -60,7 +60,7 @@ public class CompressingSerializer * @return byte[] * @throws IOException on i/o problem */ - protected <T extends Serializable> byte[] serializeObject( T obj ) + protected <T> byte[] serializeObject( T obj ) throws IOException { ByteArrayOutputStream baos = new ByteArrayOutputStream(); @@ -87,7 +87,7 @@ public class CompressingSerializer * @throws ClassNotFoundException if class is not found during deserialization */ @Override - public <T extends Serializable> T deSerialize( byte[] data ) + public <T> T deSerialize( byte[] data ) throws IOException, ClassNotFoundException { if ( data == null ) @@ -106,7 +106,7 @@ public class CompressingSerializer * @throws IOException on i/o error * @throws ClassNotFoundException if class is not found during deserialization */ - protected <T extends Serializable> T deserializeObject( byte[] decompressedByteArray ) + protected <T> T deserializeObject( byte[] decompressedByteArray ) throws IOException, ClassNotFoundException { ByteArrayInputStream bais = new ByteArrayInputStream( decompressedByteArray ); Modified: commons/proper/jcs/trunk/commons-jcs-core/src/main/java/org/apache/commons/jcs/utils/serialization/SerializationConversionUtil.java URL: http://svn.apache.org/viewvc/commons/proper/jcs/trunk/commons-jcs-core/src/main/java/org/apache/commons/jcs/utils/serialization/SerializationConversionUtil.java?rev=1593843&r1=1593842&r2=1593843&view=diff ============================================================================== --- commons/proper/jcs/trunk/commons-jcs-core/src/main/java/org/apache/commons/jcs/utils/serialization/SerializationConversionUtil.java (original) +++ commons/proper/jcs/trunk/commons-jcs-core/src/main/java/org/apache/commons/jcs/utils/serialization/SerializationConversionUtil.java Sun May 11 19:43:30 2014 @@ -50,7 +50,7 @@ public class SerializationConversionUtil * @return null for null; * @throws IOException */ - public static <K extends Serializable, V extends Serializable> ICacheElementSerialized<K, V> getSerializedCacheElement( ICacheElement<K, V> element, + public static <K, V> ICacheElementSerialized<K, V> getSerializedCacheElement( ICacheElement<K, V> element, IElementSerializer elementSerializer ) throws IOException { @@ -104,7 +104,7 @@ public class SerializationConversionUtil * @throws IOException * @throws ClassNotFoundException */ - public static <K extends Serializable, V extends Serializable> ICacheElement<K, V> getDeSerializedCacheElement( ICacheElementSerialized<K, V> serialized, + public static <K, V> ICacheElement<K, V> getDeSerializedCacheElement( ICacheElementSerialized<K, V> serialized, IElementSerializer elementSerializer ) throws IOException, ClassNotFoundException { Modified: commons/proper/jcs/trunk/commons-jcs-core/src/main/java/org/apache/commons/jcs/utils/serialization/StandardSerializer.java URL: http://svn.apache.org/viewvc/commons/proper/jcs/trunk/commons-jcs-core/src/main/java/org/apache/commons/jcs/utils/serialization/StandardSerializer.java?rev=1593843&r1=1593842&r2=1593843&view=diff ============================================================================== --- commons/proper/jcs/trunk/commons-jcs-core/src/main/java/org/apache/commons/jcs/utils/serialization/StandardSerializer.java (original) +++ commons/proper/jcs/trunk/commons-jcs-core/src/main/java/org/apache/commons/jcs/utils/serialization/StandardSerializer.java Sun May 11 19:43:30 2014 @@ -46,7 +46,7 @@ public class StandardSerializer * @throws IOException */ @Override - public <T extends Serializable> byte[] serialize( T obj ) + public <T> byte[] serialize( T obj ) throws IOException { ByteArrayOutputStream baos = new ByteArrayOutputStream(); @@ -72,7 +72,7 @@ public class StandardSerializer * @throws ClassNotFoundException */ @Override - public <T extends Serializable> T deSerialize( byte[] data ) + public <T> T deSerialize( byte[] data ) throws IOException, ClassNotFoundException { ByteArrayInputStream bais = new ByteArrayInputStream( data ); Modified: commons/proper/jcs/trunk/commons-jcs-core/src/test/java/org/apache/commons/jcs/auxiliary/MockAuxiliaryCache.java URL: http://svn.apache.org/viewvc/commons/proper/jcs/trunk/commons-jcs-core/src/test/java/org/apache/commons/jcs/auxiliary/MockAuxiliaryCache.java?rev=1593843&r1=1593842&r2=1593843&view=diff ============================================================================== --- commons/proper/jcs/trunk/commons-jcs-core/src/test/java/org/apache/commons/jcs/auxiliary/MockAuxiliaryCache.java (original) +++ commons/proper/jcs/trunk/commons-jcs-core/src/test/java/org/apache/commons/jcs/auxiliary/MockAuxiliaryCache.java Sun May 11 19:43:30 2014 @@ -34,7 +34,7 @@ import org.apache.commons.jcs.engine.sta * <p> * @author Aaron Smuts */ -public class MockAuxiliaryCache<K extends Serializable, V extends Serializable> +public class MockAuxiliaryCache<K, V> extends AbstractAuxiliaryCache<K, V> { /** Don't change */ Modified: commons/proper/jcs/trunk/commons-jcs-core/src/test/java/org/apache/commons/jcs/auxiliary/MockAuxiliaryCacheFactory.java URL: http://svn.apache.org/viewvc/commons/proper/jcs/trunk/commons-jcs-core/src/test/java/org/apache/commons/jcs/auxiliary/MockAuxiliaryCacheFactory.java?rev=1593843&r1=1593842&r2=1593843&view=diff ============================================================================== --- commons/proper/jcs/trunk/commons-jcs-core/src/test/java/org/apache/commons/jcs/auxiliary/MockAuxiliaryCacheFactory.java (original) +++ commons/proper/jcs/trunk/commons-jcs-core/src/test/java/org/apache/commons/jcs/auxiliary/MockAuxiliaryCacheFactory.java Sun May 11 19:43:30 2014 @@ -42,7 +42,7 @@ public class MockAuxiliaryCacheFactory * @return AuxiliaryCache */ @Override - public <K extends Serializable, V extends Serializable> AuxiliaryCache<K, V> + public <K, V> AuxiliaryCache<K, V> createCache( AuxiliaryCacheAttributes attr, ICompositeCacheManager cacheMgr, ICacheEventLogger cacheEventLogger, IElementSerializer elementSerializer ) { Modified: commons/proper/jcs/trunk/commons-jcs-core/src/test/java/org/apache/commons/jcs/auxiliary/MockCacheEventLogger.java URL: http://svn.apache.org/viewvc/commons/proper/jcs/trunk/commons-jcs-core/src/test/java/org/apache/commons/jcs/auxiliary/MockCacheEventLogger.java?rev=1593843&r1=1593842&r2=1593843&view=diff ============================================================================== --- commons/proper/jcs/trunk/commons-jcs-core/src/test/java/org/apache/commons/jcs/auxiliary/MockCacheEventLogger.java (original) +++ commons/proper/jcs/trunk/commons-jcs-core/src/test/java/org/apache/commons/jcs/auxiliary/MockCacheEventLogger.java Sun May 11 19:43:30 2014 @@ -64,7 +64,7 @@ public class MockCacheEventLogger * @param event */ @Override - public <T extends Serializable> void logICacheEvent( ICacheEvent<T> event ) + public <T> void logICacheEvent( ICacheEvent<T> event ) { endICacheEventCalls++; } @@ -90,7 +90,7 @@ public class MockCacheEventLogger * @return ICacheEvent */ @Override - public <T extends Serializable> ICacheEvent<T> createICacheEvent( String source, String region, + public <T> ICacheEvent<T> createICacheEvent( String source, String region, String eventName, String optionalDetails, T key ) { startICacheEventCalls++; Modified: commons/proper/jcs/trunk/commons-jcs-core/src/test/java/org/apache/commons/jcs/auxiliary/remote/http/client/MockRemoteCacheDispatcher.java URL: http://svn.apache.org/viewvc/commons/proper/jcs/trunk/commons-jcs-core/src/test/java/org/apache/commons/jcs/auxiliary/remote/http/client/MockRemoteCacheDispatcher.java?rev=1593843&r1=1593842&r2=1593843&view=diff ============================================================================== --- commons/proper/jcs/trunk/commons-jcs-core/src/test/java/org/apache/commons/jcs/auxiliary/remote/http/client/MockRemoteCacheDispatcher.java (original) +++ commons/proper/jcs/trunk/commons-jcs-core/src/test/java/org/apache/commons/jcs/auxiliary/remote/http/client/MockRemoteCacheDispatcher.java Sun May 11 19:43:30 2014 @@ -44,7 +44,7 @@ public class MockRemoteCacheDispatcher */ @Override @SuppressWarnings("unchecked") - public <K extends Serializable, V extends Serializable, T> + public <K, V, T> RemoteCacheResponse<T> dispatchRequest( RemoteCacheRequest<K, V> remoteCacheRequest ) throws IOException { Modified: commons/proper/jcs/trunk/commons-jcs-core/src/test/java/org/apache/commons/jcs/engine/control/MockCompositeCacheManager.java URL: http://svn.apache.org/viewvc/commons/proper/jcs/trunk/commons-jcs-core/src/test/java/org/apache/commons/jcs/engine/control/MockCompositeCacheManager.java?rev=1593843&r1=1593842&r2=1593843&view=diff ============================================================================== --- commons/proper/jcs/trunk/commons-jcs-core/src/test/java/org/apache/commons/jcs/engine/control/MockCompositeCacheManager.java (original) +++ commons/proper/jcs/trunk/commons-jcs-core/src/test/java/org/apache/commons/jcs/engine/control/MockCompositeCacheManager.java Sun May 11 19:43:30 2014 @@ -32,7 +32,7 @@ public class MockCompositeCacheManager implements ICompositeCacheManager { /** The cache that was returned. */ - private CompositeCache<? extends Serializable, ? extends Serializable> cache; + private CompositeCache<?, ?> cache; /** Properties with which this manager was configured. This is exposed for other managers. */ private Properties configurationProperties; @@ -43,7 +43,7 @@ public class MockCompositeCacheManager */ @Override @SuppressWarnings("unchecked") - public <K extends Serializable, V extends Serializable> CompositeCache<K, V> getCache( String cacheName ) + public <K, V> CompositeCache<K, V> getCache( String cacheName ) { if ( cache == null ) { @@ -59,7 +59,7 @@ public class MockCompositeCacheManager /** * @param cache The cache to set. */ - public void setCache( CompositeCache<? extends Serializable, ? extends Serializable> cache ) + public void setCache( CompositeCache<?, ?> cache ) { this.cache = cache; } @@ -67,7 +67,7 @@ public class MockCompositeCacheManager /** * @return Returns the cache. */ - public CompositeCache<? extends Serializable, ? extends Serializable> getCache() + public CompositeCache<?, ?> getCache() { return cache; } Modified: commons/proper/jcs/trunk/commons-jcs-core/src/test/java/org/apache/commons/jcs/engine/control/MockElementSerializer.java URL: http://svn.apache.org/viewvc/commons/proper/jcs/trunk/commons-jcs-core/src/test/java/org/apache/commons/jcs/engine/control/MockElementSerializer.java?rev=1593843&r1=1593842&r2=1593843&view=diff ============================================================================== --- commons/proper/jcs/trunk/commons-jcs-core/src/test/java/org/apache/commons/jcs/engine/control/MockElementSerializer.java (original) +++ commons/proper/jcs/trunk/commons-jcs-core/src/test/java/org/apache/commons/jcs/engine/control/MockElementSerializer.java Sun May 11 19:43:30 2014 @@ -49,7 +49,7 @@ public class MockElementSerializer * */ @Override - public <T extends Serializable> T deSerialize( byte[] bytes ) + public <T> T deSerialize( byte[] bytes ) throws IOException, ClassNotFoundException { deSerializeCount++; @@ -63,7 +63,7 @@ public class MockElementSerializer * */ @Override - public <T extends Serializable> byte[] serialize( T obj ) + public <T> byte[] serialize( T obj ) throws IOException { serializeCount++; Modified: commons/proper/jcs/trunk/commons-jcs-core/src/test/java/org/apache/commons/jcs/engine/logging/MockCacheEventLogger.java URL: http://svn.apache.org/viewvc/commons/proper/jcs/trunk/commons-jcs-core/src/test/java/org/apache/commons/jcs/engine/logging/MockCacheEventLogger.java?rev=1593843&r1=1593842&r2=1593843&view=diff ============================================================================== --- commons/proper/jcs/trunk/commons-jcs-core/src/test/java/org/apache/commons/jcs/engine/logging/MockCacheEventLogger.java (original) +++ commons/proper/jcs/trunk/commons-jcs-core/src/test/java/org/apache/commons/jcs/engine/logging/MockCacheEventLogger.java Sun May 11 19:43:30 2014 @@ -64,7 +64,7 @@ public class MockCacheEventLogger * @return ICacheEvent */ @Override - public <T extends Serializable> ICacheEvent<T> createICacheEvent( String source, String region, String eventName, String optionalDetails, + public <T> ICacheEvent<T> createICacheEvent( String source, String region, String eventName, String optionalDetails, T key ) { return new CacheEvent<T>(); @@ -74,7 +74,7 @@ public class MockCacheEventLogger * @param event */ @Override - public <T extends Serializable> void logICacheEvent( ICacheEvent<T> event ) + public <T> void logICacheEvent( ICacheEvent<T> event ) { // TODO Auto-generated method stub } Modified: commons/proper/jcs/trunk/commons-jcs-jcache/pom.xml URL: http://svn.apache.org/viewvc/commons/proper/jcs/trunk/commons-jcs-jcache/pom.xml?rev=1593843&r1=1593842&r2=1593843&view=diff ============================================================================== --- commons/proper/jcs/trunk/commons-jcs-jcache/pom.xml (original) +++ commons/proper/jcs/trunk/commons-jcs-jcache/pom.xml Sun May 11 19:43:30 2014 @@ -52,6 +52,12 @@ <dependency> <groupId>org.apache.commons</groupId> + <artifactId>commons-jcs-core</artifactId> + <version>${project.version}</version> + </dependency> + + <dependency> + <groupId>org.apache.commons</groupId> <artifactId>commons-lang3</artifactId> <version>3.2.1</version> <optional>true</optional> Modified: commons/proper/jcs/trunk/commons-jcs-jcache/src/main/java/org/apache/commons/jcs/jcache/JCSCache.java URL: http://svn.apache.org/viewvc/commons/proper/jcs/trunk/commons-jcs-jcache/src/main/java/org/apache/commons/jcs/jcache/JCSCache.java?rev=1593843&r1=1593842&r2=1593843&view=diff ============================================================================== --- commons/proper/jcs/trunk/commons-jcs-jcache/src/main/java/org/apache/commons/jcs/jcache/JCSCache.java (original) +++ commons/proper/jcs/trunk/commons-jcs-jcache/src/main/java/org/apache/commons/jcs/jcache/JCSCache.java Sun May 11 19:43:30 2014 @@ -18,18 +18,18 @@ */ package org.apache.commons.jcs.jcache; +import org.apache.commons.jcs.access.CacheAccess; +import org.apache.commons.jcs.engine.control.CompositeCache; import org.apache.commons.jcs.jcache.jmx.JCSCacheMXBean; import org.apache.commons.jcs.jcache.jmx.JCSCacheStatisticsMXBean; import org.apache.commons.jcs.jcache.jmx.JMXs; import org.apache.commons.jcs.jcache.lang.Subsitutor; import org.apache.commons.jcs.jcache.proxy.ExceptionWrapperHandler; -import org.apache.commons.jcs.jcache.spi.CacheEvictor; import org.apache.commons.jcs.jcache.thread.DaemonThreadFactory; import javax.cache.Cache; import javax.cache.CacheManager; import javax.cache.configuration.CacheEntryListenerConfiguration; -import javax.cache.configuration.CompleteConfiguration; import javax.cache.configuration.Configuration; import javax.cache.configuration.Factory; import javax.cache.event.CacheEntryEvent; @@ -49,14 +49,12 @@ import javax.management.ObjectName; import java.io.Closeable; import java.io.Serializable; import java.util.Arrays; -import java.util.Comparator; import java.util.HashMap; import java.util.HashSet; import java.util.Iterator; import java.util.Map; import java.util.Properties; import java.util.Set; -import java.util.TreeSet; import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ConcurrentMap; import java.util.concurrent.ExecutorService; @@ -65,11 +63,12 @@ import java.util.concurrent.Executors; import static org.apache.commons.jcs.jcache.Asserts.assertNotNull; import static org.apache.commons.jcs.jcache.serialization.Serializations.copy; -public class JCSCache<K, V, C extends CompleteConfiguration<K, V>> implements Cache<K, V> +// TODO: configure serializer +public class JCSCache<K, V> implements Cache<K, V> { private static final Subsitutor SUBSTITUTOR = Subsitutor.Helper.INSTANCE; - private final ConcurrentMap<JCSKey<K>, JCSElement<V>> delegate; + private final CacheAccess<JCSKey<K>, JCSElement<V>> delegate; private final JCSCachingManager manager; private final JCSConfiguration<K, V> config; private final CacheLoader<K, V> loader; @@ -78,9 +77,6 @@ public class JCSCache<K, V, C extends Co private final ObjectName cacheConfigObjectName; private final ObjectName cacheStatsObjectName; private final String name; - private final long maxSize; - private final long maxDelete; - private final CacheEvictor<K, V> evictor; private volatile boolean closed = false; private final Map<CacheEntryListenerConfiguration<K, V>, JCSListener<K, V>> listeners = new ConcurrentHashMap<CacheEntryListenerConfiguration<K, V>, JCSListener<K, V>>(); private final Statistics statistics = new Statistics(); @@ -88,18 +84,14 @@ public class JCSCache<K, V, C extends Co public JCSCache(final ClassLoader classLoader, final JCSCachingManager mgr, - final String cacheName, - final JCSConfiguration<K, V> configuration, - final Properties properties) + final String cacheName, final JCSConfiguration<K, V> configuration, + final Properties properties, final CompositeCache<JCSKey<K>, JCSElement<V>> cache) { manager = mgr; name = cacheName; - final int capacity = Integer.parseInt(property(properties, cacheName, "capacity", "1000")); - final float loadFactor = Float.parseFloat(property(properties, cacheName, "loadFactor", "0.75")); - final int concurrencyLevel = Integer.parseInt(property(properties, cacheName, "concurrencyLevel", "16")); - delegate = new ConcurrentHashMap<JCSKey<K>, JCSElement<V>>(capacity, loadFactor, concurrencyLevel); + delegate = new CacheAccess<JCSKey<K>, JCSElement<V>>(cache); config = configuration; @@ -107,30 +99,6 @@ public class JCSCache<K, V, C extends Co final DaemonThreadFactory threadFactory = new DaemonThreadFactory("JCS-JCache-"); pool = poolSize > 0 ? Executors.newFixedThreadPool(poolSize, threadFactory) : Executors.newCachedThreadPool(threadFactory); - maxSize = Long.parseLong(property(properties, cacheName, "maxSize", "1000")); - maxDelete = Long.parseLong(property(properties, cacheName, "maxDeleteByEvictionRun", "100")); - final long evictionPause = Long.parseLong(properties.getProperty(cacheName + ".evictionPause", properties.getProperty("evictionPause", "30000"))); - final String evictorClass = property(properties, cacheName, "evictor", null); - if (evictorClass != null) - { - try - { - evictor = CacheEvictor.class.cast(classLoader.loadClass(evictorClass).newInstance()); - } - catch (final Exception e) - { - throw new IllegalStateException(e); - } - } - else - { - evictor = null; - } - if (evictionPause > 0) - { - pool.submit(new EvictionThread<K, V>(this, evictionPause)); - } - final Factory<CacheLoader<K, V>> cacheLoaderFactory = configuration.getCacheLoaderFactory(); if (cacheLoaderFactory == null) { @@ -240,7 +208,6 @@ public class JCSCache<K, V, C extends Co final JCSKey<K> jcsKey = new JCSKey<K>(key); jcsKey.access(Times.now(false)); delegate.put(jcsKey, new JCSElement<V>(v, duration)); - evictIfMaxSize(); } } return v; @@ -356,14 +323,13 @@ public class JCSCache<K, V, C extends Co statistics.increasePuts(1); statistics.addPutTime(System.currentTimeMillis() - start); } - - evictIfMaxSize(); } } private void expires(final JCSKey<K> cacheKey) { - final JCSElement<V> elt = delegate.remove(cacheKey); + final JCSElement<V> elt = delegate.get(cacheKey); + delegate.remove(cacheKey); for (final JCSListener<K, V> listener : listeners.values()) { listener.onExpired(Arrays.<CacheEntryEvent<? extends K, ? extends V>> asList(new JCSCacheEntryEvent<K, V>(this, @@ -375,6 +341,8 @@ public class JCSCache<K, V, C extends Co public V getAndPut(final K key, final V value) { assertNotClosed(); + assertNotNull(key, "key"); + assertNotNull(value, "value"); final V v = doGetControllingExpiry(new JCSKey<K>(key), false, false, true, false); put(key, value); return v; @@ -414,7 +382,10 @@ public class JCSCache<K, V, C extends Co writer.delete(key); final JCSKey<K> cacheKey = new JCSKey<K>(key); - final JCSElement<V> v = delegate.remove(cacheKey); + + final JCSElement<V> v = delegate.get(cacheKey); + delegate.remove(cacheKey); + final V value = v != null && v.getElement() != null ? v.getElement() : null; boolean remove = v != null; if (v != null && v.isExpired()) @@ -459,6 +430,7 @@ public class JCSCache<K, V, C extends Co public V getAndRemove(final K key) { assertNotClosed(); + assertNotNull(key, "key"); final V v = doGetControllingExpiry(new JCSKey<K>(key), false, false, true, false); remove(key); return v; @@ -623,7 +595,7 @@ public class JCSCache<K, V, C extends Co public void removeAll() { assertNotClosed(); - for (final JCSKey<K> k : delegate.keySet()) + for (final JCSKey<K> k : delegate.getCacheControl().getKeySet()) { remove(k.getKey()); } @@ -802,7 +774,7 @@ public class JCSCache<K, V, C extends Co public Iterator<Entry<K, V>> iterator() { assertNotClosed(); - final Iterator<JCSKey<K>> keys = new HashSet<JCSKey<K>>(delegate.keySet()).iterator(); + final Iterator<JCSKey<K>> keys = new HashSet<JCSKey<K>>(delegate.getCacheControl().getKeySet()).iterator(); return new Iterator<Entry<K, V>>() { private K lastKey = null; @@ -930,125 +902,4 @@ public class JCSCache<K, V, C extends Co statistics.setActive(false); JMXs.unregister(cacheStatsObjectName); } - - private static class EvictionThread<K, V> implements Runnable - { - private final long pause; - private final JCSCache<K, V, ?> cache; - - public EvictionThread(final JCSCache<K, V, ?> cache, final long evictionPause) - { - this.cache = cache; - this.pause = evictionPause; - } - - @Override - public void run() - { - while (!cache.isClosed()) - { - cache.evict(); - try - { - Thread.sleep(pause); - } - catch (final InterruptedException e) - { - Thread.interrupted(); - break; - } - } - } - } - - private void evictIfMaxSize() - { - if (delegate.size() > maxSize) - { - pool.submit(new Runnable() - { - @Override - public void run() - { - evict(); - } - }); - } - } - - private void evict() - { - if (isClosed()) - { - return; - } - - if (evictor != null) - { - evictor.evict(this); - } - else - { - defaultEviction(); - } - } - - private void defaultEviction() - { - final ConcurrentMap<JCSKey<K>, ? extends JCSElement<?>> map = delegate; - try - { - final TreeSet<JCSKey<K>> treeSet = new TreeSet<JCSKey<K>>(new Comparator<JCSKey<K>>() - { - @Override - public int compare(final JCSKey<K> o1, final JCSKey<K> o2) - { - final long l = o2.lastAccess() - o1.lastAccess(); // inverse - if (l == 0) - { - return o1.hashCode() - o2.hashCode(); - } - return (int) l; - } - }); - treeSet.addAll(map.keySet()); - - int delete = 0; - for (final JCSKey<K> key : treeSet) - { - if (delete >= maxDelete) { - break; - } - final JCSElement<?> elt = map.get(key); - if (elt != null) { - if (elt.isExpired()) - { - map.remove(key); - statistics.increaseEvictions(1); - delete++; - } - } - } - - if (delete >= maxDelete && maxSize > 0 && map.size() > maxSize) - { - for (final JCSKey<K> key : treeSet) - { - if (delete >= maxDelete) { - break; - } - final JCSElement<?> elt = map.get(key); - if (elt != null) { - map.remove(key); - statistics.increaseEvictions(1); - delete++; - } - } - } - } - catch (final Exception e) - { - // no-op - } - } } Modified: commons/proper/jcs/trunk/commons-jcs-jcache/src/main/java/org/apache/commons/jcs/jcache/JCSCachingManager.java URL: http://svn.apache.org/viewvc/commons/proper/jcs/trunk/commons-jcs-jcache/src/main/java/org/apache/commons/jcs/jcache/JCSCachingManager.java?rev=1593843&r1=1593842&r2=1593843&view=diff ============================================================================== --- commons/proper/jcs/trunk/commons-jcs-jcache/src/main/java/org/apache/commons/jcs/jcache/JCSCachingManager.java (original) +++ commons/proper/jcs/trunk/commons-jcs-jcache/src/main/java/org/apache/commons/jcs/jcache/JCSCachingManager.java Sun May 11 19:43:30 2014 @@ -18,6 +18,7 @@ */ package org.apache.commons.jcs.jcache; +import org.apache.commons.jcs.engine.control.CompositeCacheManager; import org.apache.commons.jcs.jcache.proxy.ClassLoaderAwareCache; import javax.cache.Cache; @@ -42,6 +43,7 @@ public class JCSCachingManager implement private final ConcurrentMap<String, Cache<?, ?>> caches = new ConcurrentHashMap<String, Cache<?, ?>>(); private final Properties configProperties; private volatile boolean closed = false; + private CompositeCacheManager delegate = CompositeCacheManager.getUnconfiguredInstance();; public JCSCachingManager(final CachingProvider provider, final URI uri, final ClassLoader loader, final Properties properties) { @@ -50,6 +52,8 @@ public class JCSCachingManager implement this.loader = loader; this.properties = readConfig(uri, loader, properties); this.configProperties = properties; + + delegate.configure(properties); } private Properties readConfig(final URI uri, final ClassLoader loader, final Properties properties) { @@ -112,7 +116,10 @@ public class JCSCachingManager implement final Class<?> valueType = configuration == null ? Object.class : configuration.getValueType(); if (!caches.containsKey(cacheName)) { - final Cache<K, V> cache = ClassLoaderAwareCache.wrap(loader, new JCSCache(loader, this, cacheName, new JCSConfiguration(configuration, keyType, valueType), properties)); + final Cache<K, V> cache = ClassLoaderAwareCache.wrap(loader, + new JCSCache(loader, this, cacheName, + new JCSConfiguration(configuration, keyType, valueType), properties, + delegate.getCache(cacheName))); caches.putIfAbsent(cacheName, cache); } else @@ -140,7 +147,7 @@ public class JCSCachingManager implement { assertNotClosed(); assertNotNull(cacheName, "cacheName"); - final JCSCache<?, ?, ?> cache = getJCSCache(cacheName); + final JCSCache<?, ?> cache = getJCSCache(cacheName); if (cache != null) { if (enabled) @@ -154,7 +161,7 @@ public class JCSCachingManager implement } } - private JCSCache<?, ?, ?> getJCSCache(final String cacheName) + private JCSCache<?, ?> getJCSCache(final String cacheName) { final Cache<?, ?> cache = caches.get(cacheName); return JCSCache.class.cast(ClassLoaderAwareCache.getDelegate(cache)); @@ -165,7 +172,7 @@ public class JCSCachingManager implement { assertNotClosed(); assertNotNull(cacheName, "cacheName"); - final JCSCache<?, ?, ?> cache = getJCSCache(cacheName); + final JCSCache<?, ?> cache = getJCSCache(cacheName); if (cache != null) { if (enabled) @@ -198,6 +205,7 @@ public class JCSCachingManager implement { JCSCachingProvider.class.cast(provider).remove(this); } + delegate.shutDown(); } @Override Modified: commons/proper/jcs/trunk/commons-jcs-jcache/src/main/java/org/apache/commons/jcs/jcache/TempStateCacheView.java URL: http://svn.apache.org/viewvc/commons/proper/jcs/trunk/commons-jcs-jcache/src/main/java/org/apache/commons/jcs/jcache/TempStateCacheView.java?rev=1593843&r1=1593842&r2=1593843&view=diff ============================================================================== --- commons/proper/jcs/trunk/commons-jcs-jcache/src/main/java/org/apache/commons/jcs/jcache/TempStateCacheView.java (original) +++ commons/proper/jcs/trunk/commons-jcs-jcache/src/main/java/org/apache/commons/jcs/jcache/TempStateCacheView.java Sun May 11 19:43:30 2014 @@ -40,13 +40,13 @@ import static org.apache.commons.jcs.jca // kind of transactional view for a Cache<K, V>, to use with EntryProcessor public class TempStateCacheView<K, V> implements Cache<K, V> { - private final JCSCache<K, V, ?> cache; + private final JCSCache<K, V> cache; private final Map<K, V> put = new HashMap<K, V>(); private final Collection<K> remove = new LinkedList<K>(); private boolean removeAll = false; private boolean clear = false; - public TempStateCacheView(final JCSCache<K, V, ?> entries) + public TempStateCacheView(final JCSCache<K, V> entries) { this.cache = entries; } Modified: commons/proper/jcs/trunk/commons-jcs-jcache/src/main/java/org/apache/commons/jcs/jcache/proxy/ClassLoaderAwareCache.java URL: http://svn.apache.org/viewvc/commons/proper/jcs/trunk/commons-jcs-jcache/src/main/java/org/apache/commons/jcs/jcache/proxy/ClassLoaderAwareCache.java?rev=1593843&r1=1593842&r2=1593843&view=diff ============================================================================== --- commons/proper/jcs/trunk/commons-jcs-jcache/src/main/java/org/apache/commons/jcs/jcache/proxy/ClassLoaderAwareCache.java (original) +++ commons/proper/jcs/trunk/commons-jcs-jcache/src/main/java/org/apache/commons/jcs/jcache/proxy/ClassLoaderAwareCache.java Sun May 11 19:43:30 2014 @@ -37,9 +37,9 @@ import java.util.Set; public class ClassLoaderAwareCache<K extends Serializable, V extends Serializable> implements Cache<K, V> { private final ClassLoader loader; - private final JCSCache<K, V, ?> delegate; + private final JCSCache<K, V> delegate; - public ClassLoaderAwareCache(final ClassLoader loader, final JCSCache<K, V, ?> delegate) + public ClassLoaderAwareCache(final ClassLoader loader, final JCSCache<K, V> delegate) { this.loader = loader; this.delegate = delegate; @@ -468,7 +468,7 @@ public class ClassLoaderAwareCache<K ext return delegate.hashCode(); } - public static <K extends Serializable, V extends Serializable> Cache<K, V> wrap(final ClassLoader loader, final JCSCache<K, V, ?> delegate) + public static <K extends Serializable, V extends Serializable> Cache<K, V> wrap(final ClassLoader loader, final JCSCache<K, V> delegate) { ClassLoader dontWrapLoader = ClassLoaderAwareCache.class.getClassLoader(); while (dontWrapLoader != null) @@ -478,15 +478,15 @@ public class ClassLoaderAwareCache<K ext return delegate; } dontWrapLoader = dontWrapLoader.getParent(); - }// TODO: maybe use normal wrapping since reflection takes too much time for a cache + } return new ClassLoaderAwareCache<K, V>(loader, delegate); } - public static <K extends Serializable, V extends Serializable> JCSCache<K, V, ?> getDelegate(final Cache<?, ?> cache) + public static <K extends Serializable, V extends Serializable> JCSCache<K, V> getDelegate(final Cache<?, ?> cache) { if (JCSCache.class.isInstance(cache)) { - return (JCSCache<K, V, ?>) cache; + return (JCSCache<K, V>) cache; } return ((ClassLoaderAwareCache<K, V>) cache).delegate; } Added: commons/proper/jcs/trunk/commons-jcs-jcache/src/test/java/org/apache/commons/jcs/jcache/NotSerializableTest.java URL: http://svn.apache.org/viewvc/commons/proper/jcs/trunk/commons-jcs-jcache/src/test/java/org/apache/commons/jcs/jcache/NotSerializableTest.java?rev=1593843&view=auto ============================================================================== --- commons/proper/jcs/trunk/commons-jcs-jcache/src/test/java/org/apache/commons/jcs/jcache/NotSerializableTest.java (added) +++ commons/proper/jcs/trunk/commons-jcs-jcache/src/test/java/org/apache/commons/jcs/jcache/NotSerializableTest.java Sun May 11 19:43:30 2014 @@ -0,0 +1,61 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.commons.jcs.jcache; + +import org.junit.Test; + +import javax.cache.Cache; +import javax.cache.CacheManager; +import javax.cache.Caching; +import javax.cache.configuration.MutableConfiguration; +import javax.cache.spi.CachingProvider; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; + +public class NotSerializableTest +{ + @Test + public void run() + { + final CachingProvider cachingProvider = Caching.getCachingProvider(); + final CacheManager cacheManager = cachingProvider.getCacheManager(); + cacheManager.createCache("default", new MutableConfiguration<String, NotSerializableAndImHappyWithIt>().setStoreByValue(false)); + final Cache<String, NotSerializableAndImHappyWithIt> cache = cacheManager.getCache("default"); + assertFalse(cache.containsKey("foo")); + cache.put("foo", new NotSerializableAndImHappyWithIt("bar")); + assertTrue(cache.containsKey("foo")); + assertEquals("bar", cache.get("foo").name); + cache.remove("foo"); + assertFalse(cache.containsKey("foo")); + cache.close(); + cacheManager.close(); + cachingProvider.close(); + } + + public static class NotSerializableAndImHappyWithIt { + private final String name; + + public NotSerializableAndImHappyWithIt(final String name) + { + this.name = name; + } + } +}
