commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From t.@apache.org
Subject svn commit: r1232163 [2/10] - in /commons/proper/jcs/branches/generics-interface/src: java/org/apache/jcs/ java/org/apache/jcs/access/ java/org/apache/jcs/access/behavior/ java/org/apache/jcs/admin/ java/org/apache/jcs/auxiliary/ java/org/apache/jcs/au...
Date Mon, 16 Jan 2012 21:05:50 GMT
Modified: commons/proper/jcs/branches/generics-interface/src/java/org/apache/jcs/auxiliary/disk/AbstractDiskCache.java
URL: http://svn.apache.org/viewvc/commons/proper/jcs/branches/generics-interface/src/java/org/apache/jcs/auxiliary/disk/AbstractDiskCache.java?rev=1232163&r1=1232162&r2=1232163&view=diff
==============================================================================
--- commons/proper/jcs/branches/generics-interface/src/java/org/apache/jcs/auxiliary/disk/AbstractDiskCache.java (original)
+++ commons/proper/jcs/branches/generics-interface/src/java/org/apache/jcs/auxiliary/disk/AbstractDiskCache.java Mon Jan 16 21:05:44 2012
@@ -58,9 +58,9 @@ import org.apache.jcs.engine.stats.behav
  * persistence mechanism, this class destroys the event queue. Should it also destroy purgatory?
  * Should it dispose itself?
  */
-public abstract class AbstractDiskCache
-    extends AbstractAuxiliaryCacheEventLogging
-    implements AuxiliaryCache, Serializable
+public abstract class AbstractDiskCache<K extends Serializable, V extends Serializable>
+    extends AbstractAuxiliaryCacheEventLogging<K, V>
+    implements AuxiliaryCache<K, V>, Serializable
 {
     /** Don't change. */
     private static final long serialVersionUID = 6541664080877628324L;
@@ -79,13 +79,13 @@ public abstract class AbstractDiskCache
      * If the elements are pulled into the memory cache while the are still in purgatory, writing to
      * disk can be canceled.
      */
-    protected Map<Serializable, PurgatoryElement> purgatory = new HashMap<Serializable, PurgatoryElement>();
+    protected Map<K, PurgatoryElement<K, V>> purgatory = new HashMap<K, PurgatoryElement<K, V>>();
 
     /**
      * The CacheEventQueue where changes will be queued for asynchronous updating of the persistent
      * storage.
      */
-    protected ICacheEventQueue cacheEventQueue;
+    protected ICacheEventQueue<K, V> cacheEventQueue;
 
     /**
      * Indicates whether the cache is 'alive': initialized, but not yet disposed. Child classes must
@@ -120,7 +120,7 @@ public abstract class AbstractDiskCache
         this.cacheName = attr.getCacheName();
 
         // create queue
-        CacheEventQueueFactory fact = new CacheEventQueueFactory();
+        CacheEventQueueFactory<K, V> fact = new CacheEventQueueFactory<K, V>();
         this.cacheEventQueue = fact.createCacheEventQueue( new MyCacheListener(), CacheInfo.listenerId, cacheName,
                                                            diskCacheAttributes.getEventQueuePoolName(),
                                                            diskCacheAttributes.getEventQueueType() );
@@ -151,11 +151,11 @@ public abstract class AbstractDiskCache
                 {
                     if ( diskCacheAttributes.getMaxPurgatorySize() >= 0 )
                     {
-                        purgatory = new LRUMapJCS<Serializable, PurgatoryElement>( diskCacheAttributes.getMaxPurgatorySize() );
+                        purgatory = new LRUMapJCS<K, PurgatoryElement<K, V>>( diskCacheAttributes.getMaxPurgatorySize() );
                     }
                     else
                     {
-                        purgatory = new HashMap<Serializable, PurgatoryElement>();
+                        purgatory = new HashMap<K, PurgatoryElement<K, V>>();
                     }
                 }
             }
@@ -163,11 +163,11 @@ public abstract class AbstractDiskCache
             {
                 if ( diskCacheAttributes.getMaxPurgatorySize() >= 0 )
                 {
-                    purgatory = new LRUMapJCS<Serializable, PurgatoryElement>( diskCacheAttributes.getMaxPurgatorySize() );
+                    purgatory = new LRUMapJCS<K, PurgatoryElement<K, V>>( diskCacheAttributes.getMaxPurgatorySize() );
                 }
                 else
                 {
-                    purgatory = new HashMap<Serializable, PurgatoryElement>();
+                    purgatory = new HashMap<K, PurgatoryElement<K, V>>();
                 }
             }
         }
@@ -191,7 +191,7 @@ public abstract class AbstractDiskCache
      * @see org.apache.jcs.engine.behavior.ICache#update
      */
     @Override
-    public final void update( ICacheElement cacheElement )
+    public final void update( ICacheElement<K, V> cacheElement )
         throws IOException
     {
         if ( log.isDebugEnabled() )
@@ -202,7 +202,7 @@ public abstract class AbstractDiskCache
         try
         {
             // Wrap the CacheElement in a PurgatoryElement
-            PurgatoryElement pe = new PurgatoryElement( cacheElement );
+            PurgatoryElement<K, V> pe = new PurgatoryElement<K, V>( cacheElement );
 
             // Indicates the the element is eligible to be spooled to disk,
             // this will remain true unless the item is pulled back into
@@ -231,11 +231,11 @@ public abstract class AbstractDiskCache
      * it on disk.
      * <p>
      * @param key
-     * @return ICacheElement or null
+     * @return ICacheElement<K, V> or null
      * @see AuxiliaryCache#get
      */
     @Override
-    public final ICacheElement get( Serializable key )
+    public final ICacheElement<K, V> get( K key )
     {
         // If not alive, always return null.
 
@@ -248,7 +248,7 @@ public abstract class AbstractDiskCache
             return null;
         }
 
-        PurgatoryElement pe = null;
+        PurgatoryElement<K, V> pe = null;
         synchronized ( purgatory )
         {
             pe = purgatory.get( key );
@@ -314,30 +314,30 @@ public abstract class AbstractDiskCache
      * cache will convert * to % and . to _
      * <p>
      * @param pattern
-     * @return a map of Serializable key to ICacheElement element, or an empty map if there is no
+     * @return a map of K key to ICacheElement<K, V> element, or an empty map if there is no
      *         data matching the pattern.
      * @throws IOException
      */
     @Override
-    public Map<Serializable, ICacheElement> getMatching( String pattern )
+    public Map<K, ICacheElement<K, V>> getMatching( String pattern )
         throws IOException
     {
         // Get the keys from purgatory
-        Object[] keyArray = null;
+        K[] keyArray = null;
 
         // this avoids locking purgatory, but it uses more memory
         synchronized ( purgatory )
         {
-            keyArray = purgatory.keySet().toArray();
+            keyArray = (K[]) purgatory.keySet().toArray();
         }
 
-        Set<Serializable> matchingKeys = getKeyMatcher().getMatchingKeysFromArray( pattern, keyArray );
+        Set<K> matchingKeys = getKeyMatcher().getMatchingKeysFromArray( pattern, keyArray );
 
         // call getMultiple with the set
-        Map<Serializable, ICacheElement> result = processGetMultiple( matchingKeys );
+        Map<K, ICacheElement<K, V>> result = processGetMultiple( matchingKeys );
 
         // Get the keys from disk
-        Map<Serializable, ICacheElement> diskMatches = doGetMatching( pattern );
+        Map<K, ICacheElement<K, V>> diskMatches = doGetMatching( pattern );
 
         result.putAll( diskMatches );
 
@@ -348,19 +348,19 @@ public abstract class AbstractDiskCache
      * Gets multiple items from the cache based on the given set of keys.
      * <p>
      * @param keys
-     * @return a map of Serializable key to ICacheElement element, or an empty map if there is no
+     * @return a map of K key to ICacheElement<K, V> element, or an empty map if there is no
      *         data in cache for any of these keys
      */
     @Override
-    public Map<Serializable, ICacheElement> processGetMultiple(Set<Serializable> keys)
+    public Map<K, ICacheElement<K, V>> processGetMultiple(Set<K> keys)
     {
-        Map<Serializable, ICacheElement> elements = new HashMap<Serializable, ICacheElement>();
+        Map<K, ICacheElement<K, V>> elements = new HashMap<K, ICacheElement<K, V>>();
 
         if ( keys != null && !keys.isEmpty() )
         {
-            for (Serializable key : keys)
+            for (K key : keys)
             {
-                ICacheElement element = get( key );
+                ICacheElement<K, V> element = get( key );
 
                 if ( element != null )
                 {
@@ -378,7 +378,7 @@ public abstract class AbstractDiskCache
      * (non-Javadoc)
      * @see org.apache.jcs.auxiliary.AuxiliaryCache#getGroupKeys(java.lang.String)
      */
-    public abstract Set<Serializable> getGroupKeys( String groupName );
+    public abstract Set<K> getGroupKeys( String groupName );
 
     /**
      * Removes are not queued. A call to remove is immediate.
@@ -389,10 +389,10 @@ public abstract class AbstractDiskCache
      * @see org.apache.jcs.engine.behavior.ICache#remove
      */
     @Override
-    public final boolean remove( Serializable key )
+    public final boolean remove( K key )
         throws IOException
     {
-        PurgatoryElement pe = null;
+        PurgatoryElement<K, V> pe = null;
 
         synchronized ( purgatory )
         {
@@ -605,7 +605,7 @@ public abstract class AbstractDiskCache
      * parent class.
      */
     protected class MyCacheListener
-        implements ICacheListener
+        implements ICacheListener<K, V>
     {
         /** Id of the listener */
         private long listenerId = 0;
@@ -640,16 +640,16 @@ public abstract class AbstractDiskCache
          *      added to the cache event queue, that may not be needed ( they are always
          *      PurgatoryElements ).
          */
-        public void handlePut( ICacheElement element )
+        public void handlePut( ICacheElement<K, V> element )
             throws IOException
         {
             if ( alive )
             {
-                // If the element is a PurgatoryElement we must check to see
+                // If the element is a PurgatoryElement<K, V> we must check to see
                 // if it is still spoolable, and remove it from purgatory.
                 if ( element instanceof PurgatoryElement )
                 {
-                    PurgatoryElement pe = (PurgatoryElement) element;
+                    PurgatoryElement<K, V> pe = (PurgatoryElement<K, V>) element;
 
                     synchronized ( pe.getCacheElement() )
                     {
@@ -722,7 +722,7 @@ public abstract class AbstractDiskCache
          * @throws IOException
          * @see ICacheListener#handleRemove
          */
-        public void handleRemove( String cacheName, Serializable key )
+        public void handleRemove( String cacheName, K key )
             throws IOException
         {
             if ( alive )
@@ -782,7 +782,7 @@ public abstract class AbstractDiskCache
      * @return An object matching key, or null.
      * @throws IOException
      */
-    protected final ICacheElement doGet( Serializable key )
+    protected final ICacheElement<K, V> doGet( K key )
         throws IOException
     {
         return super.getWithEventLogging( key );
@@ -799,7 +799,7 @@ public abstract class AbstractDiskCache
      * @return A map of matches..
      * @throws IOException
      */
-    protected final Map<Serializable, ICacheElement> doGetMatching( String pattern )
+    protected final Map<K, ICacheElement<K, V>> doGetMatching( String pattern )
         throws IOException
     {
         return super.getMatchingWithEventLogging( pattern );
@@ -815,7 +815,7 @@ public abstract class AbstractDiskCache
      * @param cacheElement
      * @throws IOException
      */
-    protected final void doUpdate( ICacheElement cacheElement )
+    protected final void doUpdate( ICacheElement<K, V> cacheElement )
         throws IOException
     {
         super.updateWithEventLogging( cacheElement );
@@ -832,7 +832,7 @@ public abstract class AbstractDiskCache
      * @return whether or no the item was present when removed
      * @throws IOException
      */
-    protected final boolean doRemove( Serializable key )
+    protected final boolean doRemove( K key )
         throws IOException
     {
         return super.removeWithEventLogging( key );

Modified: commons/proper/jcs/branches/generics-interface/src/java/org/apache/jcs/auxiliary/disk/PurgatoryElement.java
URL: http://svn.apache.org/viewvc/commons/proper/jcs/branches/generics-interface/src/java/org/apache/jcs/auxiliary/disk/PurgatoryElement.java?rev=1232163&r1=1232162&r2=1232163&view=diff
==============================================================================
--- commons/proper/jcs/branches/generics-interface/src/java/org/apache/jcs/auxiliary/disk/PurgatoryElement.java (original)
+++ commons/proper/jcs/branches/generics-interface/src/java/org/apache/jcs/auxiliary/disk/PurgatoryElement.java Mon Jan 16 21:05:44 2012
@@ -30,8 +30,8 @@ import org.apache.jcs.engine.behavior.IE
  * Elements are stored in purgatory when they are spooled to the auxilliary cache, but have not yet
  * been written to disk.
  */
-public class PurgatoryElement
-    implements ICacheElement, Serializable
+public class PurgatoryElement<K extends Serializable, V extends Serializable>
+    implements ICacheElement<K, V>, Serializable
 {
     /** Don't change */
     private static final long serialVersionUID = -8152034342684135628L;
@@ -40,14 +40,14 @@ public class PurgatoryElement
     protected boolean spoolable = false;
 
     /** Wrapped cache Element */
-    protected ICacheElement cacheElement;
+    protected ICacheElement<K, V> cacheElement;
 
     /**
-     * Constructor for the PurgatoryElement object
+     * Constructor for the PurgatoryElement<K, V> object
      * <p>
      * @param cacheElement CacheElement to wrap.
      */
-    public PurgatoryElement( ICacheElement cacheElement )
+    public PurgatoryElement( ICacheElement<K, V> cacheElement )
     {
         this.cacheElement = cacheElement;
     }
@@ -77,7 +77,7 @@ public class PurgatoryElement
      * <p>
      * @return ICacheElement
      */
-    public ICacheElement getCacheElement()
+    public ICacheElement<K, V> getCacheElement()
     {
         return cacheElement;
     }
@@ -97,7 +97,7 @@ public class PurgatoryElement
      * @return cacheElement.getKey();
      * @see ICacheElement#getKey
      */
-    public Serializable getKey()
+    public K getKey()
     {
         return cacheElement.getKey();
     }
@@ -106,7 +106,7 @@ public class PurgatoryElement
      * @return cacheElement.getVal();
      * @see ICacheElement#getVal
      */
-    public Serializable getVal()
+    public V getVal()
     {
         return cacheElement.getVal();
     }
@@ -128,7 +128,7 @@ public class PurgatoryElement
     {
         cacheElement.setElementAttributes( attr );
     }
-    
+
     /**
      * @return debug string
      */
@@ -144,5 +144,5 @@ public class PurgatoryElement
         buf.append( " ElementAttributes = " + getElementAttributes() );
         buf.append( "]" );
         return buf.toString();
-    }    
+    }
 }

Modified: commons/proper/jcs/branches/generics-interface/src/java/org/apache/jcs/auxiliary/disk/block/BlockDiskCache.java
URL: http://svn.apache.org/viewvc/commons/proper/jcs/branches/generics-interface/src/java/org/apache/jcs/auxiliary/disk/block/BlockDiskCache.java?rev=1232163&r1=1232162&r2=1232163&view=diff
==============================================================================
--- commons/proper/jcs/branches/generics-interface/src/java/org/apache/jcs/auxiliary/disk/block/BlockDiskCache.java (original)
+++ commons/proper/jcs/branches/generics-interface/src/java/org/apache/jcs/auxiliary/disk/block/BlockDiskCache.java Mon Jan 16 21:05:44 2012
@@ -51,8 +51,8 @@ import org.apache.jcs.engine.stats.behav
  * <p>
  * @author Aaron Smuts
  */
-public class BlockDiskCache
-    extends AbstractDiskCache
+public class BlockDiskCache<K extends Serializable, V extends Serializable>
+    extends AbstractDiskCache<K, V>
 {
     /** Don't change */
     private static final long serialVersionUID = 1L;
@@ -76,7 +76,7 @@ public class BlockDiskCache
     private final File rootDirectory;
 
     /** Store, loads, and persists the keys */
-    private BlockDiskKeyStore keyStore;
+    private BlockDiskKeyStore<K> keyStore;
 
     /**
      * Use this lock to synchronize reads and writes to the underlying storage mechanism. We don't
@@ -135,7 +135,7 @@ public class BlockDiskCache
                 this.dataFile = new BlockDisk( new File( rootDirectory, fileName + ".data" ), getElementSerializer() );
             }
 
-            keyStore = new BlockDiskKeyStore( this.blockDiskCacheAttributes, this );
+            keyStore = new BlockDiskKeyStore<K>( this.blockDiskCacheAttributes, this );
 
             boolean alright = verifyDisk();
 
@@ -176,11 +176,11 @@ public class BlockDiskCache
         {
             int maxToTest = 100;
             int count = 0;
-            Iterator<Map.Entry<Serializable, int[]>> it = this.keyStore.entrySet().iterator();
+            Iterator<Map.Entry<K, int[]>> it = this.keyStore.entrySet().iterator();
             while ( it.hasNext() && count < maxToTest )
             {
                 count++;
-                Map.Entry<Serializable, int[]> entry = it.next();
+                Map.Entry<K, int[]> entry = it.next();
                 Object data = this.dataFile.read( entry.getValue() );
                 if ( data == null )
                 {
@@ -209,16 +209,16 @@ public class BlockDiskCache
      * @see org.apache.jcs.auxiliary.disk.AbstractDiskCache#getGroupKeys(java.lang.String)
      */
     @Override
-    public Set<Serializable> getGroupKeys( String groupName )
+    public Set<K> getGroupKeys( String groupName )
     {
         GroupId groupId = new GroupId( cacheName, groupName );
-        HashSet<Serializable> keys = new HashSet<Serializable>();
+        HashSet<K> keys = new HashSet<K>();
 
         storageLock.readLock().lock();
 
         try
         {
-            for ( Serializable key : this.keyStore.keySet())
+            for ( K key : this.keyStore.keySet())
             {
                 if ( key instanceof GroupAttrName && ( (GroupAttrName) key ).groupId.equals( groupId ) )
                 {
@@ -238,30 +238,30 @@ public class BlockDiskCache
      * Gets matching items from the cache.
      * <p>
      * @param pattern
-     * @return a map of Serializable key to ICacheElement element, or an empty map if there is no
+     * @return a map of K key to ICacheElement<K, V> element, or an empty map if there is no
      *         data in cache matching keys
      */
     @Override
-    public Map<Serializable, ICacheElement> processGetMatching( String pattern )
+    public Map<K, ICacheElement<K, V>> processGetMatching( String pattern )
     {
-        Map<Serializable, ICacheElement> elements = new HashMap<Serializable, ICacheElement>();
+        Map<K, ICacheElement<K, V>> elements = new HashMap<K, ICacheElement<K, V>>();
 
-        Object[] keyArray = null;
+        K[] keyArray = null;
         storageLock.readLock().lock();
         try
         {
-            keyArray = this.keyStore.keySet().toArray();
+            keyArray = (K[]) this.keyStore.keySet().toArray();
         }
         finally
         {
             storageLock.readLock().unlock();
         }
 
-        Set<Serializable> matchingKeys = getKeyMatcher().getMatchingKeysFromArray( pattern, keyArray );
+        Set<K> matchingKeys = getKeyMatcher().getMatchingKeysFromArray( pattern, keyArray );
 
-        for (Serializable key : matchingKeys)
+        for (K key : matchingKeys)
         {
-            ICacheElement element = processGet( key );
+            ICacheElement<K, V> element = processGet( key );
             if ( element != null )
             {
                 elements.put( key, element );
@@ -284,7 +284,7 @@ public class BlockDiskCache
     }
 
     /**
-     * Gets the ICacheElement for the key if it is in the cache. The program flow is as follows:
+     * Gets the ICacheElement<K, V> for the key if it is in the cache. The program flow is as follows:
      * <ol>
      * <li>Make sure the disk cache is alive.</li> <li>Get a read lock.</li> <li>See if the key is
      * in the key store.</li> <li>If we found a key, ask the BlockDisk for the object at the
@@ -296,7 +296,7 @@ public class BlockDiskCache
      * @see org.apache.jcs.auxiliary.disk.AbstractDiskCache#doGet(java.io.Serializable)
      */
     @Override
-    protected ICacheElement processGet( Serializable key )
+    protected ICacheElement<K, V> processGet( K key )
     {
         if ( !alive )
         {
@@ -312,7 +312,7 @@ public class BlockDiskCache
             log.debug( logCacheName + "Trying to get from disk: " + key );
         }
 
-        ICacheElement object = null;
+        ICacheElement<K, V> object = null;
         storageLock.readLock().lock();
 
         try
@@ -320,7 +320,7 @@ public class BlockDiskCache
             int[] ded = this.keyStore.get( key );
             if ( ded != null )
             {
-                object = (ICacheElement) this.dataFile.read( ded );
+                object = (ICacheElement<K, V>) this.dataFile.read( ded );
             }
         }
         catch ( IOException ioe )
@@ -352,7 +352,7 @@ public class BlockDiskCache
      * @see org.apache.jcs.auxiliary.disk.AbstractDiskCache#doUpdate(org.apache.jcs.engine.behavior.ICacheElement)
      */
     @Override
-    protected void processUpdate( ICacheElement element )
+    protected void processUpdate( ICacheElement<K, V> element )
     {
         if ( !alive )
         {
@@ -411,7 +411,7 @@ public class BlockDiskCache
      * @see org.apache.jcs.auxiliary.disk.AbstractDiskCache#doRemove(java.io.Serializable)
      */
     @Override
-    protected boolean processRemove( Serializable key )
+    protected boolean processRemove( K key )
     {
         if ( !alive )
         {
@@ -432,12 +432,12 @@ public class BlockDiskCache
             if ( key instanceof String && key.toString().endsWith( CacheConstants.NAME_COMPONENT_DELIMITER ) )
             {
                 // remove all keys of the same name group.
-                Iterator<Map.Entry<Serializable, int[]>> iter = this.keyStore.entrySet().iterator();
+                Iterator<Map.Entry<K, int[]>> iter = this.keyStore.entrySet().iterator();
 
                 while ( iter.hasNext() )
                 {
-                    Map.Entry<Serializable, int[]> entry = iter.next();
-                    Object k = entry.getKey();
+                    Map.Entry<K, int[]> entry = iter.next();
+                    K k = entry.getKey();
 
                     if ( k instanceof String && k.toString().startsWith( key.toString() ) )
                     {
@@ -452,11 +452,11 @@ public class BlockDiskCache
             else if ( key instanceof GroupId )
             {
                 // remove all keys of the same name hierarchy.
-                Iterator<Map.Entry<Serializable, int[]>> iter = this.keyStore.entrySet().iterator();
+                Iterator<Map.Entry<K, int[]>> iter = this.keyStore.entrySet().iterator();
                 while ( iter.hasNext() )
                 {
-                    Map.Entry<Serializable, int[]> entry = iter.next();
-                    Object k = entry.getKey();
+                    Map.Entry<K, int[]> entry = iter.next();
+                    K k = entry.getKey();
 
                     if ( k instanceof GroupAttrName && ( (GroupAttrName) k ).groupId.equals( key ) )
                     {

Modified: commons/proper/jcs/branches/generics-interface/src/java/org/apache/jcs/auxiliary/disk/block/BlockDiskCacheFactory.java
URL: http://svn.apache.org/viewvc/commons/proper/jcs/branches/generics-interface/src/java/org/apache/jcs/auxiliary/disk/block/BlockDiskCacheFactory.java?rev=1232163&r1=1232162&r2=1232163&view=diff
==============================================================================
--- commons/proper/jcs/branches/generics-interface/src/java/org/apache/jcs/auxiliary/disk/block/BlockDiskCacheFactory.java (original)
+++ commons/proper/jcs/branches/generics-interface/src/java/org/apache/jcs/auxiliary/disk/block/BlockDiskCacheFactory.java Mon Jan 16 21:05:44 2012
@@ -19,6 +19,8 @@ package org.apache.jcs.auxiliary.disk.bl
  * under the License.
  */
 
+import java.io.Serializable;
+
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 import org.apache.jcs.auxiliary.AuxiliaryCache;
@@ -56,7 +58,7 @@ public class BlockDiskCacheFactory
      * @param elementSerializer
      * @return AuxiliaryCache
      */
-    public AuxiliaryCache createCache( AuxiliaryCacheAttributes iaca, ICompositeCacheManager cacheMgr,
+    public <K extends Serializable, V extends Serializable> AuxiliaryCache<K, V> createCache( AuxiliaryCacheAttributes iaca, ICompositeCacheManager cacheMgr,
                                        ICacheEventLogger cacheEventLogger, IElementSerializer elementSerializer )
     {
         BlockDiskCacheAttributes idca = (BlockDiskCacheAttributes) iaca;

Modified: commons/proper/jcs/branches/generics-interface/src/java/org/apache/jcs/auxiliary/disk/block/BlockDiskCacheManager.java
URL: http://svn.apache.org/viewvc/commons/proper/jcs/branches/generics-interface/src/java/org/apache/jcs/auxiliary/disk/block/BlockDiskCacheManager.java?rev=1232163&r1=1232162&r2=1232163&view=diff
==============================================================================
--- commons/proper/jcs/branches/generics-interface/src/java/org/apache/jcs/auxiliary/disk/block/BlockDiskCacheManager.java (original)
+++ commons/proper/jcs/branches/generics-interface/src/java/org/apache/jcs/auxiliary/disk/block/BlockDiskCacheManager.java Mon Jan 16 21:05:44 2012
@@ -19,6 +19,7 @@ package org.apache.jcs.auxiliary.disk.bl
  * under the License.
  */
 
+import java.io.Serializable;
 import java.util.Hashtable;
 
 import org.apache.commons.logging.Log;
@@ -44,7 +45,7 @@ public class BlockDiskCacheManager
     private static BlockDiskCacheManager instance;
 
     /** block disks for a region. */
-    private final Hashtable<String, AuxiliaryCache> caches = new Hashtable<String, AuxiliaryCache>();
+    private final Hashtable<String, AuxiliaryCache<?, ?>> caches = new Hashtable<String, AuxiliaryCache<?, ?>>();
 
     /** Attributes. */
     private final BlockDiskCacheAttributes defaultCacheAttributes;
@@ -93,7 +94,7 @@ public class BlockDiskCacheManager
      * @param cacheName Name that will be used when creating attributes.
      * @return A cache.
      */
-    public AuxiliaryCache getCache( String cacheName )
+    public <K extends Serializable, V extends Serializable> AuxiliaryCache<K, V> getCache( String cacheName )
     {
         BlockDiskCacheAttributes cacheAttributes = (BlockDiskCacheAttributes) defaultCacheAttributes.copy();
 
@@ -109,9 +110,9 @@ public class BlockDiskCacheManager
      * @param cacheAttributes Attributes the cache should have.
      * @return A cache, either from the existing set or newly created.
      */
-    public AuxiliaryCache getCache( BlockDiskCacheAttributes cacheAttributes )
+    public <K extends Serializable, V extends Serializable> AuxiliaryCache<K, V> getCache( BlockDiskCacheAttributes cacheAttributes )
     {
-        AuxiliaryCache cache = null;
+        AuxiliaryCache<K, V> cache = null;
 
         String cacheName = cacheAttributes.getCacheName();
 
@@ -122,14 +123,13 @@ public class BlockDiskCacheManager
             // Try to load the cache from the set that have already been
             // created. This only looks at the name attribute.
 
-            cache = caches.get( cacheName );
+            cache = (AuxiliaryCache<K, V>) caches.get( cacheName );
 
             // If it was not found, create a new one using the supplied
             // attributes
-
             if ( cache == null )
             {
-                cache = new BlockDiskCache( cacheAttributes );
+                cache = new BlockDiskCache<K, V>( cacheAttributes );
                 cache.setCacheEventLogger( getCacheEventLogger() );
                 cache.setElementSerializer( getElementSerializer() );
                 caches.put( cacheName, cache );

Modified: commons/proper/jcs/branches/generics-interface/src/java/org/apache/jcs/auxiliary/disk/block/BlockDiskElementDescriptor.java
URL: http://svn.apache.org/viewvc/commons/proper/jcs/branches/generics-interface/src/java/org/apache/jcs/auxiliary/disk/block/BlockDiskElementDescriptor.java?rev=1232163&r1=1232162&r2=1232163&view=diff
==============================================================================
--- commons/proper/jcs/branches/generics-interface/src/java/org/apache/jcs/auxiliary/disk/block/BlockDiskElementDescriptor.java (original)
+++ commons/proper/jcs/branches/generics-interface/src/java/org/apache/jcs/auxiliary/disk/block/BlockDiskElementDescriptor.java Mon Jan 16 21:05:44 2012
@@ -32,14 +32,14 @@ import java.io.Serializable;
  * <p>
  * @author Aaron Smuts
  */
-public class BlockDiskElementDescriptor
+public class BlockDiskElementDescriptor<K extends Serializable>
     implements Serializable, Externalizable
 {
     /** Don't change */
     private static final long serialVersionUID = -1400659301208101411L;
 
     /** The key */
-    private Serializable key;
+    private K key;
 
     /** The array of block numbers */
     private int[] blocks;
@@ -47,7 +47,7 @@ public class BlockDiskElementDescriptor
     /**
      * @param key The key to set.
      */
-    public void setKey( Serializable key )
+    public void setKey( K key )
     {
         this.key = key;
     }
@@ -55,7 +55,7 @@ public class BlockDiskElementDescriptor
     /**
      * @return Returns the key.
      */
-    public Serializable getKey()
+    public K getKey()
     {
         return key;
     }
@@ -109,7 +109,7 @@ public class BlockDiskElementDescriptor
     public void readExternal( ObjectInput input )
         throws IOException, ClassNotFoundException
     {
-        this.key = (Serializable) input.readObject();
+        this.key = (K) input.readObject();
         this.blocks = (int[]) input.readObject();
     }
 

Modified: commons/proper/jcs/branches/generics-interface/src/java/org/apache/jcs/auxiliary/disk/block/BlockDiskKeyStore.java
URL: http://svn.apache.org/viewvc/commons/proper/jcs/branches/generics-interface/src/java/org/apache/jcs/auxiliary/disk/block/BlockDiskKeyStore.java?rev=1232163&r1=1232162&r2=1232163&view=diff
==============================================================================
--- commons/proper/jcs/branches/generics-interface/src/java/org/apache/jcs/auxiliary/disk/block/BlockDiskKeyStore.java (original)
+++ commons/proper/jcs/branches/generics-interface/src/java/org/apache/jcs/auxiliary/disk/block/BlockDiskKeyStore.java Mon Jan 16 21:05:44 2012
@@ -47,7 +47,7 @@ import org.apache.jcs.utils.timing.Elaps
  * <p>
  * @author Aaron Smuts
  */
-public class BlockDiskKeyStore
+public class BlockDiskKeyStore<K extends Serializable>
 {
     /** The logger */
     protected static final Log log = LogFactory.getLog( BlockDiskKeyStore.class );
@@ -56,7 +56,7 @@ public class BlockDiskKeyStore
     private final BlockDiskCacheAttributes blockDiskCacheAttributes;
 
     /** The key to block map */
-    private Map<Serializable, int[]> keyHash;
+    private Map<K, int[]> keyHash;
 
     /** The file where we persist the keys */
     private final File keyFile;
@@ -71,7 +71,7 @@ public class BlockDiskKeyStore
     private final int maxKeySize;
 
     /** we need this so we can communicate free blocks to the data store when keys fall off the LRU */
-    protected final BlockDiskCache blockDiskCache;
+    protected final BlockDiskCache<K, ?> blockDiskCache;
 
     /**
      * The background key persister, one for all regions.
@@ -84,7 +84,7 @@ public class BlockDiskKeyStore
      * @param cacheAttributes
      * @param blockDiskCache used for freeing
      */
-    public BlockDiskKeyStore( BlockDiskCacheAttributes cacheAttributes, BlockDiskCache blockDiskCache )
+    public BlockDiskKeyStore( BlockDiskCacheAttributes cacheAttributes, BlockDiskCache<K, ?> blockDiskCache )
     {
         this.blockDiskCacheAttributes = cacheAttributes;
         this.logCacheName = "Region [" + this.blockDiskCacheAttributes.getCacheName() + "] ";
@@ -165,9 +165,9 @@ public class BlockDiskKeyStore
                 try
                 {
                     // don't need to synchronize, since the underlying collection makes a copy
-                    for (Map.Entry<Serializable, int[]> entry : keyHash.entrySet())
+                    for (Map.Entry<K, int[]> entry : keyHash.entrySet())
                     {
-                        BlockDiskElementDescriptor descriptor = new BlockDiskElementDescriptor();
+                        BlockDiskElementDescriptor<K> descriptor = new BlockDiskElementDescriptor<K>();
                         descriptor.setKey( entry.getKey() );
                         descriptor.setBlocks( entry.getValue() );
                         // stream these out in the loop.
@@ -231,7 +231,7 @@ public class BlockDiskKeyStore
         else
         {
             // If no max size, use a plain map for memory and processing efficiency.
-            keyHash = new HashMap<Serializable, int[]>();
+            keyHash = new HashMap<K, int[]>();
             // keyHash = Collections.synchronizedMap( new HashMap() );
             if ( log.isInfoEnabled() )
             {
@@ -256,7 +256,7 @@ public class BlockDiskKeyStore
             // create a key map to use.
             initKeyMap();
 
-            HashMap<Serializable, int[]> keys = new HashMap<Serializable, int[]>();
+            HashMap<K, int[]> keys = new HashMap<K, int[]>();
 
             synchronized (keyFile)
             {
@@ -267,7 +267,7 @@ public class BlockDiskKeyStore
                 {
                     while ( true )
                     {
-                        BlockDiskElementDescriptor descriptor = (BlockDiskElementDescriptor) ois.readObject();
+                        BlockDiskElementDescriptor<K> descriptor = (BlockDiskElementDescriptor<K>) ois.readObject();
                         if ( descriptor != null )
                         {
                             keys.put( descriptor.getKey(), descriptor.getBlocks() );
@@ -311,7 +311,7 @@ public class BlockDiskKeyStore
      * <p>
      * @return entry set.
      */
-    public Set<Map.Entry<Serializable, int[]>> entrySet()
+    public Set<Map.Entry<K, int[]>> entrySet()
     {
         return this.keyHash.entrySet();
     }
@@ -321,7 +321,7 @@ public class BlockDiskKeyStore
      * <p>
      * @return key set.
      */
-    public Set<Serializable> keySet()
+    public Set<K> keySet()
     {
         return this.keyHash.keySet();
     }
@@ -342,7 +342,7 @@ public class BlockDiskKeyStore
      * @param key
      * @return Object
      */
-    public int[] get( Object key )
+    public int[] get( K key )
     {
         return this.keyHash.get( key );
     }
@@ -353,7 +353,7 @@ public class BlockDiskKeyStore
      * @param key
      * @param value
      */
-    public void put( Serializable key, int[] value )
+    public void put( K key, int[] value )
     {
         this.keyHash.put( key, value );
     }
@@ -364,7 +364,7 @@ public class BlockDiskKeyStore
      * @param key
      * @return BlockDiskElementDescriptor if it was present, else null
      */
-    public int[] remove( Serializable key )
+    public int[] remove( K key )
     {
         return this.keyHash.remove( key );
     }
@@ -374,7 +374,7 @@ public class BlockDiskKeyStore
      * blocks as free.
      */
     public class LRUMap
-        extends LRUMapJCS<Serializable, int[]>
+        extends LRUMapJCS<K, int[]>
     {
         /** Don't change */
         private static final long serialVersionUID = 4955079991472142198L;
@@ -408,7 +408,7 @@ public class BlockDiskKeyStore
          * @param value
          */
         @Override
-        protected void processRemovedLRU( Serializable key, int[] value )
+        protected void processRemovedLRU( K key, int[] value )
         {
             blockDiskCache.freeBlocks( value );
             if ( log.isDebugEnabled() )

Modified: commons/proper/jcs/branches/generics-interface/src/java/org/apache/jcs/auxiliary/disk/file/FileDiskCache.java
URL: http://svn.apache.org/viewvc/commons/proper/jcs/branches/generics-interface/src/java/org/apache/jcs/auxiliary/disk/file/FileDiskCache.java?rev=1232163&r1=1232162&r2=1232163&view=diff
==============================================================================
--- commons/proper/jcs/branches/generics-interface/src/java/org/apache/jcs/auxiliary/disk/file/FileDiskCache.java (original)
+++ commons/proper/jcs/branches/generics-interface/src/java/org/apache/jcs/auxiliary/disk/file/FileDiskCache.java Mon Jan 16 21:05:44 2012
@@ -28,8 +28,8 @@ import org.apache.jcs.utils.timing.Sleep
  * This is a fairly simple implementation. All the disk writing is handled right here. It's not
  * clear that anything more complicated is needed.
  */
-public class FileDiskCache
-    extends AbstractDiskCache
+public class FileDiskCache<K extends Serializable, V extends Serializable>
+    extends AbstractDiskCache<K, V>
 {
     /** Don't change */
     private static final long serialVersionUID = 1L;
@@ -108,7 +108,7 @@ public class FileDiskCache
      * @param key
      * @return the file for the key
      */
-    protected File file( Serializable key )
+    protected <KK extends Serializable> File file( KK key )
     {
         StringBuffer fileNameBuffer = new StringBuffer();
 
@@ -139,7 +139,7 @@ public class FileDiskCache
      * @return Set
      */
     @Override
-    public Set<Serializable> getGroupKeys(String groupName)
+    public Set<K> getGroupKeys(String groupName)
     {
         throw new UnsupportedOperationException();
     }
@@ -183,7 +183,7 @@ public class FileDiskCache
     protected synchronized void processDispose()
         throws IOException
     {
-        ICacheEvent cacheEvent = createICacheEvent( cacheName, "none", ICacheEventLogger.DISPOSE_EVENT );
+        ICacheEvent<K> cacheEvent = createICacheEvent( cacheName, (K)"none", ICacheEventLogger.DISPOSE_EVENT );
         try
         {
             if ( !alive )
@@ -215,7 +215,7 @@ public class FileDiskCache
      * @throws IOException
      */
     @Override
-    protected ICacheElement processGet( Serializable key )
+    protected ICacheElement<K, V> processGet( K key )
         throws IOException
     {
         File file = file( key );
@@ -229,7 +229,7 @@ public class FileDiskCache
             return null;
         }
 
-        ICacheElement element = null;
+        ICacheElement<K, V> element = null;
 
         FileInputStream fis = null;
         try
@@ -253,7 +253,7 @@ public class FileDiskCache
                 throw new IOException( "Could not completely read file " + file.getName() );
             }
 
-            element = (ICacheElement) getElementSerializer().deSerialize( bytes );
+            element = getElementSerializer().deSerialize( bytes );
 
             // test that the retrieved object has equal key
             if ( element != null && !key.equals( element.getKey() ) )
@@ -293,7 +293,7 @@ public class FileDiskCache
      * @throws IOException
      */
     @Override
-    protected Map<Serializable, ICacheElement> processGetMatching( String pattern )
+    protected Map<K, ICacheElement<K, V>> processGetMatching( String pattern )
         throws IOException
     {
         // TODO get a list of file and return those with matching keys.
@@ -309,7 +309,20 @@ public class FileDiskCache
      * @throws IOException
      */
     @Override
-    protected boolean processRemove( Serializable key )
+    protected boolean processRemove( K key )
+        throws IOException
+    {
+        return _processRemove(key);
+    }
+
+    /**
+     * Removes the file.
+     * <p>
+     * @param key
+     * @return true if the item was removed
+     * @throws IOException
+     */
+    private <T extends Serializable> boolean _processRemove( T key )
         throws IOException
     {
         File file = file( key );
@@ -335,7 +348,7 @@ public class FileDiskCache
         String[] fileNames = getDirectory().list();
         for ( int i = 0; i < fileNames.length; i++ )
         {
-            processRemove( fileNames[i] );
+            _processRemove( fileNames[i] );
         }
     }
 
@@ -347,7 +360,7 @@ public class FileDiskCache
      * @throws IOException
      */
     @Override
-    protected void processUpdate( ICacheElement element )
+    protected void processUpdate( ICacheElement<K, V> element )
         throws IOException
     {
         removeIfLimitIsSetAndReached();

Modified: commons/proper/jcs/branches/generics-interface/src/java/org/apache/jcs/auxiliary/disk/file/FileDiskCacheFactory.java
URL: http://svn.apache.org/viewvc/commons/proper/jcs/branches/generics-interface/src/java/org/apache/jcs/auxiliary/disk/file/FileDiskCacheFactory.java?rev=1232163&r1=1232162&r2=1232163&view=diff
==============================================================================
--- commons/proper/jcs/branches/generics-interface/src/java/org/apache/jcs/auxiliary/disk/file/FileDiskCacheFactory.java (original)
+++ commons/proper/jcs/branches/generics-interface/src/java/org/apache/jcs/auxiliary/disk/file/FileDiskCacheFactory.java Mon Jan 16 21:05:44 2012
@@ -1,5 +1,7 @@
 package org.apache.jcs.auxiliary.disk.file;
 
+import java.io.Serializable;
+
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 import org.apache.jcs.auxiliary.AuxiliaryCache;
@@ -33,8 +35,9 @@ public class FileDiskCacheFactory
      * @param elementSerializer the serializer
      * @return AuxiliaryCache
      */
-    public AuxiliaryCache createCache( AuxiliaryCacheAttributes attr, ICompositeCacheManager cacheMgr,
-                                       ICacheEventLogger cacheEventLogger, IElementSerializer elementSerializer )
+    public <K extends Serializable, V extends Serializable> AuxiliaryCache<K, V> createCache(
+            AuxiliaryCacheAttributes attr, ICompositeCacheManager cacheMgr,
+           ICacheEventLogger cacheEventLogger, IElementSerializer elementSerializer )
     {
         FileDiskCacheAttributes idfca = (FileDiskCacheAttributes) attr;
         if ( log.isDebugEnabled() )

Modified: commons/proper/jcs/branches/generics-interface/src/java/org/apache/jcs/auxiliary/disk/file/FileDiskCacheManager.java
URL: http://svn.apache.org/viewvc/commons/proper/jcs/branches/generics-interface/src/java/org/apache/jcs/auxiliary/disk/file/FileDiskCacheManager.java?rev=1232163&r1=1232162&r2=1232163&view=diff
==============================================================================
--- commons/proper/jcs/branches/generics-interface/src/java/org/apache/jcs/auxiliary/disk/file/FileDiskCacheManager.java (original)
+++ commons/proper/jcs/branches/generics-interface/src/java/org/apache/jcs/auxiliary/disk/file/FileDiskCacheManager.java Mon Jan 16 21:05:44 2012
@@ -1,5 +1,6 @@
 package org.apache.jcs.auxiliary.disk.file;
 
+import java.io.Serializable;
 import java.util.Hashtable;
 
 import org.apache.commons.logging.Log;
@@ -22,7 +23,8 @@ public class FileDiskCacheManager
     private final static Log log = LogFactory.getLog( FileDiskCacheManager.class );
 
     /** Each region has an entry here. */
-    private final Hashtable<String, AuxiliaryCache> caches = new Hashtable<String, AuxiliaryCache>();
+    private final Hashtable<String, AuxiliaryCache<? extends Serializable, ? extends Serializable>> caches =
+        new Hashtable<String, AuxiliaryCache<? extends Serializable, ? extends Serializable>>();
 
     /** User configurable attributes */
     private final FileDiskCacheAttributes defaultCacheAttributes;
@@ -48,7 +50,7 @@ public class FileDiskCacheManager
      * @param cacheName Name that will be used when creating attributes.
      * @return A cache.
      */
-    public AuxiliaryCache getCache( String cacheName )
+    public <K extends Serializable, V extends Serializable> AuxiliaryCache<K, V> getCache( String cacheName )
     {
         FileDiskCacheAttributes cacheAttributes = (FileDiskCacheAttributes) defaultCacheAttributes.copy();
 
@@ -64,9 +66,9 @@ public class FileDiskCacheManager
      * @param cacheAttributes Attributes the cache should have.
      * @return A cache, either from the existing set or newly created.
      */
-    public AuxiliaryCache getCache( FileDiskCacheAttributes cacheAttributes )
+    public <K extends Serializable, V extends Serializable> AuxiliaryCache<K, V> getCache( FileDiskCacheAttributes cacheAttributes )
     {
-        AuxiliaryCache cache = null;
+        AuxiliaryCache<K, V> cache = null;
 
         String cacheName = cacheAttributes.getCacheName();
 
@@ -77,14 +79,14 @@ public class FileDiskCacheManager
             // Try to load the cache from the set that have already been
             // created. This only looks at the name attribute.
 
-            cache = caches.get( cacheName );
+            cache = (AuxiliaryCache<K, V>) caches.get( cacheName );
 
             // If it was not found, create a new one using the supplied
             // attributes
 
             if ( cache == null )
             {
-                cache = new FileDiskCache( cacheAttributes, getElementSerializer() );
+                cache = new FileDiskCache<K, V>( cacheAttributes, getElementSerializer() );
                 cache.setCacheEventLogger( getCacheEventLogger() );
                 caches.put( cacheName, cache );
             }

Modified: commons/proper/jcs/branches/generics-interface/src/java/org/apache/jcs/auxiliary/disk/indexed/IndexedDiskCache.java
URL: http://svn.apache.org/viewvc/commons/proper/jcs/branches/generics-interface/src/java/org/apache/jcs/auxiliary/disk/indexed/IndexedDiskCache.java?rev=1232163&r1=1232162&r2=1232163&view=diff
==============================================================================
--- commons/proper/jcs/branches/generics-interface/src/java/org/apache/jcs/auxiliary/disk/indexed/IndexedDiskCache.java (original)
+++ commons/proper/jcs/branches/generics-interface/src/java/org/apache/jcs/auxiliary/disk/indexed/IndexedDiskCache.java Mon Jan 16 21:05:44 2012
@@ -60,8 +60,8 @@ import org.apache.jcs.utils.timing.Elaps
  * stored in memory is configurable. The disk cache tries to recycle spots on disk to limit file
  * expansion.
  */
-public class IndexedDiskCache
-    extends AbstractDiskCache
+public class IndexedDiskCache<K extends Serializable, V extends Serializable>
+    extends AbstractDiskCache<K, V>
 {
     /** Don't change */
     private static final long serialVersionUID = -265035607729729629L;
@@ -82,7 +82,7 @@ public class IndexedDiskCache
     private IndexedDisk keyFile;
 
     /** Map containing the keys and disk offsets. */
-    private Map<Serializable, IndexedDiskElementDescriptor> keyHash;
+    private Map<K, IndexedDiskElementDescriptor> keyHash;
 
     /** The maximum number of keys that we will keep in memory. */
     private final int maxKeySize;
@@ -325,8 +325,8 @@ public class IndexedDiskCache
             // create a key map to use.
             initializeKeyMap();
 
-            HashMap<Serializable, IndexedDiskElementDescriptor> keys =
-                (HashMap<Serializable, IndexedDiskElementDescriptor>) keyFile.readObject( new IndexedDiskElementDescriptor( 0, (int) keyFile.length()
+            HashMap<K, IndexedDiskElementDescriptor> keys =
+                (HashMap<K, IndexedDiskElementDescriptor>) keyFile.readObject( new IndexedDiskElementDescriptor( 0, (int) keyFile.length()
                 - IndexedDisk.HEADER_SIZE_BYTES ) );
 
             if ( keys != null )
@@ -380,7 +380,7 @@ public class IndexedDiskCache
         {
             fileLength = dataFile.length();
 
-            for (Map.Entry<Serializable, IndexedDiskElementDescriptor> e : keyHash.entrySet())
+            for (Map.Entry<K, IndexedDiskElementDescriptor> e : keyHash.entrySet())
             {
                 IndexedDiskElementDescriptor ded = e.getValue();
 
@@ -464,8 +464,8 @@ public class IndexedDiskCache
 
             keyFile.reset();
 
-            HashMap<Serializable, IndexedDiskElementDescriptor> keys =
-                new HashMap<Serializable, IndexedDiskElementDescriptor>();
+            HashMap<K, IndexedDiskElementDescriptor> keys =
+                new HashMap<K, IndexedDiskElementDescriptor>();
             keys.putAll( keyHash );
 
             if ( keys.size() > 0 )
@@ -488,10 +488,10 @@ public class IndexedDiskCache
      * Update the disk cache. Called from the Queue. Makes sure the Item has not been retrieved from
      * purgatory while in queue for disk. Remove items from purgatory when they go to disk.
      * <p>
-     * @param ce The ICacheElement to put to disk.
+     * @param ce The ICacheElement<K, V> to put to disk.
      */
     @Override
-    protected void processUpdate( ICacheElement ce )
+    protected void processUpdate( ICacheElement<K, V> ce )
     {
         if ( !alive )
         {
@@ -603,11 +603,11 @@ public class IndexedDiskCache
      * Gets the key, then goes to disk to get the object.
      * <p>
      * @param key
-     * @return ICacheElement or null
+     * @return ICacheElement<K, V> or null
      * @see AbstractDiskCache#doGet
      */
     @Override
-    protected ICacheElement processGet( Serializable key )
+    protected ICacheElement<K, V> processGet( K key )
     {
         if ( !alive )
         {
@@ -620,7 +620,7 @@ public class IndexedDiskCache
             log.debug( logCacheName + "Trying to get from disk: " + key );
         }
 
-        ICacheElement object = null;
+        ICacheElement<K, V> object = null;
         try
         {
             storageLock.readLock().lock();
@@ -654,31 +654,31 @@ public class IndexedDiskCache
      * Gets matching items from the cache.
      * <p>
      * @param pattern
-     * @return a map of Serializable key to ICacheElement element, or an empty map if there is no
+     * @return a map of K key to ICacheElement<K, V> element, or an empty map if there is no
      *         data in cache matching keys
      */
     @Override
-    public Map<Serializable, ICacheElement>  processGetMatching( String pattern )
+    public Map<K, ICacheElement<K, V>> processGetMatching( String pattern )
     {
-        Map<Serializable, ICacheElement> elements = new HashMap<Serializable, ICacheElement>();
+        Map<K, ICacheElement<K, V>> elements = new HashMap<K, ICacheElement<K, V>>();
         try
         {
-            Object[] keyArray = null;
+            K[] keyArray = null;
             storageLock.readLock().lock();
             try
             {
-                keyArray = keyHash.keySet().toArray();
+                keyArray = (K[]) keyHash.keySet().toArray();
             }
             finally
             {
                 storageLock.readLock().unlock();
             }
 
-            Set<Serializable> matchingKeys = getKeyMatcher().getMatchingKeysFromArray( pattern, keyArray );
+            Set<K> matchingKeys = getKeyMatcher().getMatchingKeysFromArray( pattern, keyArray );
 
-            for (Serializable key : matchingKeys)
+            for (K key : matchingKeys)
             {
-                ICacheElement element = processGet( key );
+                ICacheElement<K, V> element = processGet( key );
                 if ( element != null )
                 {
                     elements.put( key, element );
@@ -699,10 +699,10 @@ public class IndexedDiskCache
      * @return ICacheElement
      * @throws IOException
      */
-    private ICacheElement readElement( Serializable key )
+    private ICacheElement<K, V> readElement( K key )
         throws IOException
     {
-        ICacheElement object = null;
+        ICacheElement<K, V> object = null;
 
         IndexedDiskElementDescriptor ded = keyHash.get( key );
 
@@ -714,7 +714,7 @@ public class IndexedDiskCache
             }
             try
             {
-                object = (ICacheElement) dataFile.readObject( ded );
+                object = (ICacheElement<K, V>) dataFile.readObject( ded );
                 // TODO consider checking key equality and throwing if there is a failure
             }
             catch ( IOException e )
@@ -738,10 +738,10 @@ public class IndexedDiskCache
      * @see org.apache.jcs.auxiliary.AuxiliaryCache#getGroupKeys(java.lang.String)
      */
     @Override
-    public Set<Serializable> getGroupKeys( String groupName )
+    public Set<K> getGroupKeys( String groupName )
     {
         GroupId groupId = new GroupId( cacheName, groupName );
-        HashSet<Serializable> keys = new HashSet<Serializable>();
+        HashSet<K> keys = new HashSet<K>();
         try
         {
             storageLock.readLock().lock();
@@ -774,7 +774,7 @@ public class IndexedDiskCache
      * @param key
      */
     @Override
-    protected boolean processRemove( Serializable key )
+    protected boolean processRemove( K key )
     {
         if ( !alive )
         {
@@ -845,9 +845,9 @@ public class IndexedDiskCache
         boolean removed = false;
 
         // remove all keys of the same name hierarchy.
-        List<Serializable> itemsToRemove = new LinkedList<Serializable>();
+        List<K> itemsToRemove = new LinkedList<K>();
 
-        for (Serializable k : keyHash.keySet())
+        for (K k : keyHash.keySet())
         {
             if ( k instanceof String && k.toString().startsWith( key.toString() ) )
             {
@@ -856,7 +856,7 @@ public class IndexedDiskCache
         }
 
         // remove matches.
-        for (Serializable fullKey : itemsToRemove)
+        for (K fullKey : itemsToRemove)
         {
             // Don't add to recycle bin here
             // https://issues.apache.org/jira/browse/JCS-67
@@ -882,10 +882,10 @@ public class IndexedDiskCache
         boolean removed = false;
 
         // remove all keys of the same name group.
-        List<Serializable> itemsToRemove = new LinkedList<Serializable>();
+        List<K> itemsToRemove = new LinkedList<K>();
 
         // remove all keys of the same name hierarchy.
-        for (Serializable k : keyHash.keySet())
+        for (K k : keyHash.keySet())
         {
             if ( k instanceof GroupAttrName && ( (GroupAttrName) k ).groupId.equals( key ) )
             {
@@ -894,7 +894,7 @@ public class IndexedDiskCache
         }
 
         // remove matches.
-        for (Serializable fullKey : itemsToRemove)
+        for (K fullKey : itemsToRemove)
         {
             // Don't add to recycle bin here
             // https://issues.apache.org/jira/browse/JCS-67
@@ -914,7 +914,7 @@ public class IndexedDiskCache
      * @param key
      * @return true if an item was removed.
      */
-    private boolean performSingleKeyRemoval( Serializable key )
+    private boolean performSingleKeyRemoval( K key )
     {
         boolean removed;
         // remove single item.
@@ -935,7 +935,7 @@ public class IndexedDiskCache
     @Override
     public void processRemoveAll()
     {
-        ICacheEvent cacheEvent = createICacheEvent( cacheName, "all", ICacheEventLogger.REMOVEALL_EVENT );
+        ICacheEvent<String> cacheEvent = createICacheEvent( cacheName, "all", ICacheEventLogger.REMOVEALL_EVENT );
         try
         {
             reset();
@@ -1030,7 +1030,7 @@ public class IndexedDiskCache
         else
         {
             // If no max size, use a plain map for memory and processing efficiency.
-            keyHash = new HashMap<Serializable, IndexedDiskElementDescriptor>();
+            keyHash = new HashMap<K, IndexedDiskElementDescriptor>();
             // keyHash = Collections.synchronizedMap( new HashMap() );
             if ( log.isInfoEnabled() )
             {
@@ -1048,7 +1048,7 @@ public class IndexedDiskCache
     @Override
     public void processDispose()
     {
-        ICacheEvent cacheEvent = createICacheEvent( cacheName, "none", ICacheEventLogger.DISPOSE_EVENT );
+        ICacheEvent<String> cacheEvent = createICacheEvent( cacheName, "none", ICacheEventLogger.DISPOSE_EVENT );
         try
         {
             Runnable disR = new Runnable()
@@ -1376,10 +1376,10 @@ public class IndexedDiskCache
     private IndexedDiskElementDescriptor[] createPositionSortedDescriptorList()
     {
         IndexedDiskElementDescriptor[] defragList = new IndexedDiskElementDescriptor[keyHash.size()];
-        Iterator<Map.Entry<Serializable, IndexedDiskElementDescriptor>> iterator = keyHash.entrySet().iterator();
+        Iterator<Map.Entry<K, IndexedDiskElementDescriptor>> iterator = keyHash.entrySet().iterator();
         for ( int i = 0; iterator.hasNext(); i++ )
         {
-            Map.Entry<Serializable, IndexedDiskElementDescriptor> next = iterator.next();
+            Map.Entry<K, IndexedDiskElementDescriptor> next = iterator.next();
             defragList[i] = next.getValue();
         }
 
@@ -1482,7 +1482,7 @@ public class IndexedDiskCache
     }
 
     /**
-     * For debugging. This dumps the values by defualt.
+     * For debugging. This dumps the values by default.
      */
     public void dump()
     {
@@ -1500,9 +1500,9 @@ public class IndexedDiskCache
         {
             log.debug( logCacheName + "[dump] Number of keys: " + keyHash.size() );
 
-            for (Map.Entry<Serializable, IndexedDiskElementDescriptor> e : keyHash.entrySet())
+            for (Map.Entry<K, IndexedDiskElementDescriptor> e : keyHash.entrySet())
             {
-                Serializable key = e.getKey();
+                K key = e.getKey();
                 IndexedDiskElementDescriptor ded = e.getValue();
 
                 log.debug( logCacheName + "[dump] Disk element, key: " + key + ", pos: " + ded.pos + ", ded.len"
@@ -1700,7 +1700,7 @@ public class IndexedDiskCache
      * to the recycle bin.
      */
     public class LRUMap
-        extends LRUMapJCS<Serializable, IndexedDiskElementDescriptor>
+        extends LRUMapJCS<K, IndexedDiskElementDescriptor>
         // implements Serializable
     {
         /** Don't change */
@@ -1735,7 +1735,7 @@ public class IndexedDiskCache
          * @param value
          */
         @Override
-        protected void processRemovedLRU(Serializable key, IndexedDiskElementDescriptor value )
+        protected void processRemovedLRU(K key, IndexedDiskElementDescriptor value )
         {
             addToRecycleBin( value );
             if ( log.isDebugEnabled() )

Modified: commons/proper/jcs/branches/generics-interface/src/java/org/apache/jcs/auxiliary/disk/indexed/IndexedDiskCacheFactory.java
URL: http://svn.apache.org/viewvc/commons/proper/jcs/branches/generics-interface/src/java/org/apache/jcs/auxiliary/disk/indexed/IndexedDiskCacheFactory.java?rev=1232163&r1=1232162&r2=1232163&view=diff
==============================================================================
--- commons/proper/jcs/branches/generics-interface/src/java/org/apache/jcs/auxiliary/disk/indexed/IndexedDiskCacheFactory.java (original)
+++ commons/proper/jcs/branches/generics-interface/src/java/org/apache/jcs/auxiliary/disk/indexed/IndexedDiskCacheFactory.java Mon Jan 16 21:05:44 2012
@@ -19,6 +19,8 @@ package org.apache.jcs.auxiliary.disk.in
  * under the License.
  */
 
+import java.io.Serializable;
+
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 import org.apache.jcs.auxiliary.AuxiliaryCache;
@@ -52,11 +54,11 @@ public class IndexedDiskCacheFactory
      * @param cacheMgr This allows auxiliaries to reference the manager without assuming that it is
      *            a singleton. This will allow JCS to be a non-singleton. Also, it makes it easier to
      *            test.
-     * @param cacheEventLogger 
-     * @param elementSerializer 
+     * @param cacheEventLogger
+     * @param elementSerializer
      * @return AuxiliaryCache
      */
-    public AuxiliaryCache createCache( AuxiliaryCacheAttributes iaca, ICompositeCacheManager cacheMgr,
+    public <K extends Serializable, V extends Serializable> AuxiliaryCache<K, V> createCache( AuxiliaryCacheAttributes iaca, ICompositeCacheManager cacheMgr,
                                        ICacheEventLogger cacheEventLogger, IElementSerializer elementSerializer )
     {
         IndexedDiskCacheAttributes idca = (IndexedDiskCacheAttributes) iaca;

Modified: commons/proper/jcs/branches/generics-interface/src/java/org/apache/jcs/auxiliary/disk/indexed/IndexedDiskCacheManager.java
URL: http://svn.apache.org/viewvc/commons/proper/jcs/branches/generics-interface/src/java/org/apache/jcs/auxiliary/disk/indexed/IndexedDiskCacheManager.java?rev=1232163&r1=1232162&r2=1232163&view=diff
==============================================================================
--- commons/proper/jcs/branches/generics-interface/src/java/org/apache/jcs/auxiliary/disk/indexed/IndexedDiskCacheManager.java (original)
+++ commons/proper/jcs/branches/generics-interface/src/java/org/apache/jcs/auxiliary/disk/indexed/IndexedDiskCacheManager.java Mon Jan 16 21:05:44 2012
@@ -19,6 +19,7 @@ package org.apache.jcs.auxiliary.disk.in
  * under the License.
  */
 
+import java.io.Serializable;
 import java.util.Hashtable;
 
 import org.apache.commons.logging.Log;
@@ -44,7 +45,8 @@ public class IndexedDiskCacheManager
     private static IndexedDiskCacheManager instance;
 
     /** Each region has an entry here. */
-    private final Hashtable<String, AuxiliaryCache> caches = new Hashtable<String, AuxiliaryCache>();
+    private final Hashtable<String, AuxiliaryCache<? extends Serializable, ? extends Serializable>> caches =
+        new Hashtable<String, AuxiliaryCache<? extends Serializable, ? extends Serializable>>();
 
     /** User configurable attributes */
     private final IndexedDiskCacheAttributes defaultCacheAttributes;
@@ -57,7 +59,7 @@ public class IndexedDiskCacheManager
      * @param elementSerializer
      */
     private IndexedDiskCacheManager( IndexedDiskCacheAttributes defaultCacheAttributes,
-                                     ICacheEventLogger cacheEventLogger, IElementSerializer elementSerializer )
+         ICacheEventLogger cacheEventLogger, IElementSerializer elementSerializer )
     {
         this.defaultCacheAttributes = defaultCacheAttributes;
         setElementSerializer( elementSerializer );
@@ -93,7 +95,7 @@ public class IndexedDiskCacheManager
      * @param cacheName Name that will be used when creating attributes.
      * @return A cache.
      */
-    public AuxiliaryCache getCache( String cacheName )
+    public <K extends Serializable, V extends Serializable> AuxiliaryCache<K, V> getCache( String cacheName )
     {
         IndexedDiskCacheAttributes cacheAttributes = (IndexedDiskCacheAttributes) defaultCacheAttributes.copy();
 
@@ -109,9 +111,9 @@ public class IndexedDiskCacheManager
      * @param cacheAttributes Attributes the cache should have.
      * @return A cache, either from the existing set or newly created.
      */
-    public AuxiliaryCache getCache( IndexedDiskCacheAttributes cacheAttributes )
+    public <K extends Serializable, V extends Serializable> AuxiliaryCache<K, V> getCache( IndexedDiskCacheAttributes cacheAttributes )
     {
-        AuxiliaryCache cache = null;
+        AuxiliaryCache<K, V> cache = null;
 
         String cacheName = cacheAttributes.getCacheName();
 
@@ -122,14 +124,14 @@ public class IndexedDiskCacheManager
             // Try to load the cache from the set that have already been
             // created. This only looks at the name attribute.
 
-            cache = caches.get( cacheName );
+            cache = (AuxiliaryCache<K, V>) caches.get( cacheName );
 
             // If it was not found, create a new one using the supplied
             // attributes
 
             if ( cache == null )
             {
-                cache = new IndexedDiskCache( cacheAttributes, getElementSerializer() );
+                cache = new IndexedDiskCache<K, V>( cacheAttributes, getElementSerializer() );
                 cache.setCacheEventLogger( getCacheEventLogger() );
                 caches.put( cacheName, cache );
             }

Modified: commons/proper/jcs/branches/generics-interface/src/java/org/apache/jcs/auxiliary/disk/indexed/IndexedDiskDumper.java
URL: http://svn.apache.org/viewvc/commons/proper/jcs/branches/generics-interface/src/java/org/apache/jcs/auxiliary/disk/indexed/IndexedDiskDumper.java?rev=1232163&r1=1232162&r2=1232163&view=diff
==============================================================================
--- commons/proper/jcs/branches/generics-interface/src/java/org/apache/jcs/auxiliary/disk/indexed/IndexedDiskDumper.java (original)
+++ commons/proper/jcs/branches/generics-interface/src/java/org/apache/jcs/auxiliary/disk/indexed/IndexedDiskDumper.java Mon Jan 16 21:05:44 2012
@@ -1,5 +1,7 @@
 package org.apache.jcs.auxiliary.disk.indexed;
 
+import java.io.Serializable;
+
 /*
  * Licensed to the Apache Software Foundation (ASF) under one
  * or more contributor license agreements.  See the NOTICE file
@@ -47,7 +49,7 @@ public class IndexedDiskDumper
         attr.setCacheName( args[0] );
         attr.setDiskPath( args[0] );
 
-        final IndexedDiskCache dc = new IndexedDiskCache( attr );
+        IndexedDiskCache<Serializable, Serializable> dc = new IndexedDiskCache<Serializable, Serializable>( attr );
         dc.dump( true );
         System.exit( 0 );
     }

Modified: commons/proper/jcs/branches/generics-interface/src/java/org/apache/jcs/auxiliary/disk/jdbc/JDBCDiskCache.java
URL: http://svn.apache.org/viewvc/commons/proper/jcs/branches/generics-interface/src/java/org/apache/jcs/auxiliary/disk/jdbc/JDBCDiskCache.java?rev=1232163&r1=1232162&r2=1232163&view=diff
==============================================================================
--- commons/proper/jcs/branches/generics-interface/src/java/org/apache/jcs/auxiliary/disk/jdbc/JDBCDiskCache.java (original)
+++ commons/proper/jcs/branches/generics-interface/src/java/org/apache/jcs/auxiliary/disk/jdbc/JDBCDiskCache.java Mon Jan 16 21:05:44 2012
@@ -22,11 +22,11 @@ package org.apache.jcs.auxiliary.disk.jd
 import java.io.IOException;
 import java.io.Serializable;
 import java.sql.Connection;
-import java.sql.Timestamp;
 import java.sql.PreparedStatement;
 import java.sql.ResultSet;
 import java.sql.SQLException;
 import java.sql.Statement;
+import java.sql.Timestamp;
 import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.HashMap;
@@ -79,8 +79,8 @@ import org.apache.jcs.utils.serializatio
  * <p>
  * @author Aaron Smuts
  */
-public class JDBCDiskCache
-    extends AbstractDiskCache
+public class JDBCDiskCache<K extends Serializable, V extends Serializable>
+    extends AbstractDiskCache<K, V>
 {
     /** The local logger. */
     private final static Log log = LogFactory.getLog( JDBCDiskCache.class );
@@ -182,7 +182,7 @@ public class JDBCDiskCache
      * @param ce
      */
     @Override
-    protected void processUpdate( ICacheElement ce )
+    protected void processUpdate( ICacheElement<K, V> ce )
     {
         incrementUpdateCount();
 
@@ -290,7 +290,7 @@ public class JDBCDiskCache
      * @param con
      * @param element
      */
-    private void insertOrUpdate( ICacheElement ce, Connection con, byte[] element )
+    private void insertOrUpdate( ICacheElement<K, V> ce, Connection con, byte[] element )
     {
         boolean exists = false;
 
@@ -321,7 +321,7 @@ public class JDBCDiskCache
      * @param element
      * @return true if the insertion fails because the record exists.
      */
-    private boolean insertRow( ICacheElement ce, Connection con, byte[] element )
+    private boolean insertRow( ICacheElement<K, V> ce, Connection con, byte[] element )
     {
         boolean exists = false;
         try
@@ -386,7 +386,7 @@ public class JDBCDiskCache
      * @param con
      * @param element
      */
-    private void updateRow( ICacheElement ce, Connection con, byte[] element )
+    private void updateRow( ICacheElement<K, V> ce, Connection con, byte[] element )
     {
         String sqlU = null;
         try
@@ -428,7 +428,7 @@ public class JDBCDiskCache
      * @param ce
      * @return boolean
      */
-    protected boolean doesElementExist( ICacheElement ce )
+    protected boolean doesElementExist( ICacheElement<K, V> ce )
     {
         boolean exists = false;
 
@@ -507,7 +507,7 @@ public class JDBCDiskCache
      * @see org.apache.jcs.auxiliary.disk.AbstractDiskCache#doGet(java.io.Serializable)
      */
     @Override
-    protected ICacheElement processGet( Serializable key )
+    protected ICacheElement<K, V> processGet( K key )
     {
         incrementGetCount();
 
@@ -521,7 +521,7 @@ public class JDBCDiskCache
             return null;
         }
 
-        ICacheElement obj = null;
+        ICacheElement<K, V> obj = null;
 
         byte[] data = null;
         try
@@ -552,7 +552,7 @@ public class JDBCDiskCache
                             try
                             {
                                 // USE THE SERIALIZER
-                                obj = (ICacheElement) getElementSerializer().deSerialize( data );
+                                obj = getElementSerializer().deSerialize( data );
                             }
                             catch ( IOException ioe )
                             {
@@ -612,7 +612,7 @@ public class JDBCDiskCache
      * @return key,value map
      */
     @Override
-    protected Map<Serializable, ICacheElement> processGetMatching( String pattern )
+    protected Map<K, ICacheElement<K, V>> processGetMatching( String pattern )
     {
         incrementGetMatchingCount();
 
@@ -626,7 +626,7 @@ public class JDBCDiskCache
             return null;
         }
 
-        Map<Serializable, ICacheElement> results = new HashMap<Serializable, ICacheElement>();
+        Map<K, ICacheElement<K, V>> results = new HashMap<K, ICacheElement<K, V>>();
 
         try
         {
@@ -656,8 +656,8 @@ public class JDBCDiskCache
                                 try
                                 {
                                     // USE THE SERIALIZER
-                                    ICacheElement value = (ICacheElement) getElementSerializer().deSerialize( data );
-                                    results.put( key, value );
+                                    ICacheElement<K, V> value = getElementSerializer().deSerialize( data );
+                                    results.put( (K) key, value );
                                 }
                                 catch ( IOException ioe )
                                 {
@@ -735,7 +735,7 @@ public class JDBCDiskCache
      * @return boolean
      */
     @Override
-    protected boolean processRemove( Serializable key )
+    protected boolean processRemove( K key )
     {
         // remove single item.
         String sql = "delete from " + getJdbcDiskCacheAttributes().getTableName()
@@ -944,7 +944,7 @@ public class JDBCDiskCache
     @Override
     public void processDispose()
     {
-        ICacheEvent cacheEvent = createICacheEvent( cacheName, "none", ICacheEventLogger.DISPOSE_EVENT );
+        ICacheEvent<K> cacheEvent = createICacheEvent( cacheName, (K)"none", ICacheEventLogger.DISPOSE_EVENT );
         try
         {
             try
@@ -1044,7 +1044,7 @@ public class JDBCDiskCache
      * @return byte[]
      * @throws IOException
      */
-    protected byte[] serialize( Serializable obj )
+    protected byte[] serialize( ICacheElement<K, V> obj )
         throws IOException
     {
         return getElementSerializer().serialize( obj );
@@ -1055,7 +1055,7 @@ public class JDBCDiskCache
      * @return Set
      */
     @Override
-    public Set<Serializable> getGroupKeys( String groupName )
+    public Set<K> getGroupKeys( String groupName )
     {
         throw new UnsupportedOperationException( "Groups not implemented." );
         // return null;

Modified: commons/proper/jcs/branches/generics-interface/src/java/org/apache/jcs/auxiliary/disk/jdbc/JDBCDiskCacheFactory.java
URL: http://svn.apache.org/viewvc/commons/proper/jcs/branches/generics-interface/src/java/org/apache/jcs/auxiliary/disk/jdbc/JDBCDiskCacheFactory.java?rev=1232163&r1=1232162&r2=1232163&view=diff
==============================================================================
--- commons/proper/jcs/branches/generics-interface/src/java/org/apache/jcs/auxiliary/disk/jdbc/JDBCDiskCacheFactory.java (original)
+++ commons/proper/jcs/branches/generics-interface/src/java/org/apache/jcs/auxiliary/disk/jdbc/JDBCDiskCacheFactory.java Mon Jan 16 21:05:44 2012
@@ -19,6 +19,8 @@ package org.apache.jcs.auxiliary.disk.jd
  * under the License.
  */
 
+import java.io.Serializable;
+
 import org.apache.jcs.auxiliary.AuxiliaryCache;
 import org.apache.jcs.auxiliary.AuxiliaryCacheAttributes;
 import org.apache.jcs.auxiliary.AuxiliaryCacheFactory;
@@ -46,7 +48,7 @@ public class JDBCDiskCacheFactory
      * @param elementSerializer
      * @return AuxiliaryCache
      */
-    public AuxiliaryCache createCache( AuxiliaryCacheAttributes rawAttr, ICompositeCacheManager compositeCacheManager,
+    public <K extends Serializable, V extends Serializable> AuxiliaryCache<K, V> createCache( AuxiliaryCacheAttributes rawAttr, ICompositeCacheManager compositeCacheManager,
                                        ICacheEventLogger cacheEventLogger, IElementSerializer elementSerializer )
     {
         JDBCDiskCacheManager diskCacheManager = JDBCDiskCacheManager.getInstance( (JDBCDiskCacheAttributes) rawAttr,

Modified: commons/proper/jcs/branches/generics-interface/src/java/org/apache/jcs/auxiliary/disk/jdbc/JDBCDiskCacheManager.java
URL: http://svn.apache.org/viewvc/commons/proper/jcs/branches/generics-interface/src/java/org/apache/jcs/auxiliary/disk/jdbc/JDBCDiskCacheManager.java?rev=1232163&r1=1232162&r2=1232163&view=diff
==============================================================================
--- commons/proper/jcs/branches/generics-interface/src/java/org/apache/jcs/auxiliary/disk/jdbc/JDBCDiskCacheManager.java (original)
+++ commons/proper/jcs/branches/generics-interface/src/java/org/apache/jcs/auxiliary/disk/jdbc/JDBCDiskCacheManager.java Mon Jan 16 21:05:44 2012
@@ -19,6 +19,8 @@ package org.apache.jcs.auxiliary.disk.jd
  * under the License.
  */
 
+import java.io.Serializable;
+
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 import org.apache.jcs.auxiliary.AuxiliaryCache;
@@ -43,8 +45,8 @@ public class JDBCDiskCacheManager
     private static JDBCDiskCacheManager instance;
 
     /** User configurable settings. */
-    private JDBCDiskCacheAttributes defaultJDBCDiskCacheAttributes;
-    
+    private final JDBCDiskCacheAttributes defaultJDBCDiskCacheAttributes;
+
     /** The cache manager instance */
     private ICompositeCacheManager compositeCacheManager;
 
@@ -52,12 +54,12 @@ public class JDBCDiskCacheManager
      * Constructor for the HSQLCacheManager object
      * <p>
      * @param cattr
-     * @param compositeCacheManager 
+     * @param compositeCacheManager
      * @param cacheEventLogger
      * @param elementSerializer
      */
     private JDBCDiskCacheManager( JDBCDiskCacheAttributes cattr, ICompositeCacheManager compositeCacheManager, ICacheEventLogger cacheEventLogger,
-                                  IElementSerializer elementSerializer )
+          IElementSerializer elementSerializer )
     {
         if ( log.isInfoEnabled() )
         {
@@ -83,13 +85,13 @@ public class JDBCDiskCacheManager
      * Gets the instance attribute of the HSQLCacheManager class
      * <p>
      * @param cattr
-     * @param compositeCacheManager 
+     * @param compositeCacheManager
      * @param cacheEventLogger
      * @param elementSerializer
      * @return The instance value
      */
     public static JDBCDiskCacheManager getInstance( JDBCDiskCacheAttributes cattr, ICompositeCacheManager compositeCacheManager, ICacheEventLogger cacheEventLogger,
-                                                    IElementSerializer elementSerializer )
+        IElementSerializer elementSerializer )
     {
         synchronized ( JDBCDiskCacheManager.class )
         {
@@ -108,7 +110,7 @@ public class JDBCDiskCacheManager
      * @param cacheName
      * @return The cache value
      */
-    public AuxiliaryCache getCache( String cacheName )
+    public <K extends Serializable, V extends Serializable> AuxiliaryCache<K, V> getCache( String cacheName )
     {
         JDBCDiskCacheAttributes cattr = (JDBCDiskCacheAttributes) defaultJDBCDiskCacheAttributes.copy();
         cattr.setCacheName( cacheName );
@@ -122,10 +124,10 @@ public class JDBCDiskCacheManager
      * @param tableState
      * @return AuxiliaryCache
      */
-    protected AuxiliaryCache createJDBCDiskCache( JDBCDiskCacheAttributes cattr, TableState tableState )
+    protected <K extends Serializable, V extends Serializable> AuxiliaryCache<K, V> createJDBCDiskCache( JDBCDiskCacheAttributes cattr, TableState tableState )
     {
-        AuxiliaryCache raf;
-        raf = new JDBCDiskCache( cattr, tableState, getCompositeCacheManager() );
+        AuxiliaryCache<K, V> raf;
+        raf = new JDBCDiskCache<K, V>( cattr, tableState, getCompositeCacheManager() );
         return raf;
     }
 

Modified: commons/proper/jcs/branches/generics-interface/src/java/org/apache/jcs/auxiliary/disk/jdbc/JDBCDiskCacheManagerAbstractTemplate.java
URL: http://svn.apache.org/viewvc/commons/proper/jcs/branches/generics-interface/src/java/org/apache/jcs/auxiliary/disk/jdbc/JDBCDiskCacheManagerAbstractTemplate.java?rev=1232163&r1=1232162&r2=1232163&view=diff
==============================================================================
--- commons/proper/jcs/branches/generics-interface/src/java/org/apache/jcs/auxiliary/disk/jdbc/JDBCDiskCacheManagerAbstractTemplate.java (original)
+++ commons/proper/jcs/branches/generics-interface/src/java/org/apache/jcs/auxiliary/disk/jdbc/JDBCDiskCacheManagerAbstractTemplate.java Mon Jan 16 21:05:44 2012
@@ -20,6 +20,7 @@ package org.apache.jcs.auxiliary.disk.jd
  */
 
 import java.io.IOException;
+import java.io.Serializable;
 import java.util.Enumeration;
 import java.util.Hashtable;
 import java.util.Map;
@@ -52,7 +53,8 @@ public abstract class JDBCDiskCacheManag
     protected static int clients;
 
     /** A map of JDBCDiskCache objects to region names. */
-    protected static Hashtable<String, AuxiliaryCache> caches = new Hashtable<String, AuxiliaryCache>();
+    protected static Hashtable<String, AuxiliaryCache<? extends Serializable, ? extends Serializable>> caches =
+        new Hashtable<String, AuxiliaryCache<? extends Serializable, ? extends Serializable>>();
 
     /**
      * A map of TableState objects to table names. Each cache has a table state object, which is
@@ -76,7 +78,7 @@ public abstract class JDBCDiskCacheManag
      * @param tableState An object used by multiple processes to indicate state.
      * @return AuxiliaryCache -- a JDBCDiskCache
      */
-    protected abstract AuxiliaryCache createJDBCDiskCache( JDBCDiskCacheAttributes cattr, TableState tableState );
+    protected abstract <K extends Serializable, V extends Serializable> AuxiliaryCache<K, V> createJDBCDiskCache( JDBCDiskCacheAttributes cattr, TableState tableState );
 
     /**
      * Creates a JDBCDiskCache for the region if one doesn't exist, else it returns the pre-created
@@ -85,15 +87,15 @@ public abstract class JDBCDiskCacheManag
      * @param cattr
      * @return The cache value
      */
-    public AuxiliaryCache getCache( JDBCDiskCacheAttributes cattr )
+    public <K extends Serializable, V extends Serializable> AuxiliaryCache<K, V> getCache( JDBCDiskCacheAttributes cattr )
     {
-        AuxiliaryCache diskCache = null;
+        AuxiliaryCache<K, V> diskCache = null;
 
         log.debug( "cacheName = " + cattr.getCacheName() );
 
         synchronized ( caches )
         {
-            diskCache = caches.get( cattr.getCacheName() );
+            diskCache = (AuxiliaryCache<K, V>) caches.get( cattr.getCacheName() );
 
             if ( diskCache == null )
             {
@@ -128,7 +130,7 @@ public abstract class JDBCDiskCacheManag
      * @param cattr
      * @param raf
      */
-    protected void createShrinkerWhenNeeded( JDBCDiskCacheAttributes cattr, AuxiliaryCache raf )
+    protected void createShrinkerWhenNeeded( JDBCDiskCacheAttributes cattr, AuxiliaryCache<?, ?> raf )
     {
         // add cache to shrinker.
         if ( cattr.isUseDiskShrinker() )
@@ -152,7 +154,7 @@ public abstract class JDBCDiskCacheManag
                 }
                 shrinkerDaemon.scheduleAtFixedRate(shrinkerThread, 0, intervalMillis, TimeUnit.MILLISECONDS);
             }
-            shrinkerThread.addDiskCacheToShrinkList( (JDBCDiskCache) raf );
+            shrinkerThread.addDiskCacheToShrinkList( (JDBCDiskCache<?, ?>) raf );
         }
     }
 
@@ -161,7 +163,7 @@ public abstract class JDBCDiskCacheManag
      */
     public void freeCache( String name )
     {
-        JDBCDiskCache raf = (JDBCDiskCache) caches.get( name );
+        JDBCDiskCache<?, ?> raf = (JDBCDiskCache<?, ?>) caches.get( name );
         if ( raf != null )
         {
             try
@@ -195,11 +197,11 @@ public abstract class JDBCDiskCacheManag
         }
         synchronized ( caches )
         {
-            Enumeration<AuxiliaryCache> allCaches = caches.elements();
+            Enumeration<AuxiliaryCache<?, ?>> allCaches = caches.elements();
 
             while ( allCaches.hasMoreElements() )
             {
-                JDBCDiskCache raf = (JDBCDiskCache) allCaches.nextElement();
+                JDBCDiskCache<?, ?> raf = (JDBCDiskCache<?, ?>) allCaches.nextElement();
                 if ( raf != null )
                 {
                     try

Modified: commons/proper/jcs/branches/generics-interface/src/java/org/apache/jcs/auxiliary/disk/jdbc/ShrinkerThread.java
URL: http://svn.apache.org/viewvc/commons/proper/jcs/branches/generics-interface/src/java/org/apache/jcs/auxiliary/disk/jdbc/ShrinkerThread.java?rev=1232163&r1=1232162&r2=1232163&view=diff
==============================================================================
--- commons/proper/jcs/branches/generics-interface/src/java/org/apache/jcs/auxiliary/disk/jdbc/ShrinkerThread.java (original)
+++ commons/proper/jcs/branches/generics-interface/src/java/org/apache/jcs/auxiliary/disk/jdbc/ShrinkerThread.java Mon Jan 16 21:05:44 2012
@@ -19,6 +19,7 @@ package org.apache.jcs.auxiliary.disk.jd
  * under the License.
  */
 
+import java.io.Serializable;
 import java.util.Collections;
 import java.util.HashSet;
 import java.util.Set;
@@ -39,7 +40,8 @@ public class ShrinkerThread
     private final static Log log = LogFactory.getLog( ShrinkerThread.class );
 
     /** A set of JDBCDiskCache objects to call deleteExpired on. */
-    private final Set<JDBCDiskCache> shrinkSet = Collections.synchronizedSet( new HashSet<JDBCDiskCache>() );
+    private final Set<JDBCDiskCache<? extends Serializable, ? extends Serializable>> shrinkSet =
+        Collections.synchronizedSet( new HashSet<JDBCDiskCache<? extends Serializable, ? extends Serializable>>() );
 
     /** Default time period to use. */
     private static final long DEFAULT_PAUSE_BETWEEN_REGION_CALLS_MILLIS = 5000;
@@ -64,7 +66,7 @@ public class ShrinkerThread
      * <p>
      * @param diskCache
      */
-    public void addDiskCacheToShrinkList( JDBCDiskCache diskCache )
+    public void addDiskCacheToShrinkList( JDBCDiskCache<? extends Serializable, ? extends Serializable> diskCache )
     {
         // the set will prevent dupes.
         // we could also just add these to a hashmap by region name
@@ -109,7 +111,7 @@ public class ShrinkerThread
         {
             for ( int i = 0; i < caches.length; i++ )
             {
-                JDBCDiskCache cache = (JDBCDiskCache) caches[i];
+                JDBCDiskCache<?, ?> cache = (JDBCDiskCache<?, ?>) caches[i];
 
                 long start = System.currentTimeMillis();
                 int deleted = cache.deleteExpired();

Modified: commons/proper/jcs/branches/generics-interface/src/java/org/apache/jcs/auxiliary/disk/jdbc/hsql/HSQLDiskCacheFactory.java
URL: http://svn.apache.org/viewvc/commons/proper/jcs/branches/generics-interface/src/java/org/apache/jcs/auxiliary/disk/jdbc/hsql/HSQLDiskCacheFactory.java?rev=1232163&r1=1232162&r2=1232163&view=diff
==============================================================================
--- commons/proper/jcs/branches/generics-interface/src/java/org/apache/jcs/auxiliary/disk/jdbc/hsql/HSQLDiskCacheFactory.java (original)
+++ commons/proper/jcs/branches/generics-interface/src/java/org/apache/jcs/auxiliary/disk/jdbc/hsql/HSQLDiskCacheFactory.java Mon Jan 16 21:05:44 2012
@@ -19,6 +19,7 @@ package org.apache.jcs.auxiliary.disk.jd
  * under the License.
  */
 
+import java.io.Serializable;
 import java.sql.Connection;
 import java.sql.DriverManager;
 import java.sql.SQLException;
@@ -65,7 +66,7 @@ public class HSQLDiskCacheFactory
      * @param elementSerializer
      * @return AuxiliaryCache
      */
-    public AuxiliaryCache createCache( AuxiliaryCacheAttributes rawAttr, ICompositeCacheManager arg1,
+    public <K extends Serializable, V extends Serializable> AuxiliaryCache<K, V> createCache( AuxiliaryCacheAttributes rawAttr, ICompositeCacheManager arg1,
                                        ICacheEventLogger cacheEventLogger, IElementSerializer elementSerializer )
     {
         JDBCDiskCacheManager mgr = JDBCDiskCacheManager.getInstance( (JDBCDiskCacheAttributes) rawAttr,

Modified: commons/proper/jcs/branches/generics-interface/src/java/org/apache/jcs/auxiliary/disk/jdbc/mysql/MySQLDiskCache.java
URL: http://svn.apache.org/viewvc/commons/proper/jcs/branches/generics-interface/src/java/org/apache/jcs/auxiliary/disk/jdbc/mysql/MySQLDiskCache.java?rev=1232163&r1=1232162&r2=1232163&view=diff
==============================================================================
--- commons/proper/jcs/branches/generics-interface/src/java/org/apache/jcs/auxiliary/disk/jdbc/mysql/MySQLDiskCache.java (original)
+++ commons/proper/jcs/branches/generics-interface/src/java/org/apache/jcs/auxiliary/disk/jdbc/mysql/MySQLDiskCache.java Mon Jan 16 21:05:44 2012
@@ -37,8 +37,8 @@ import org.apache.jcs.engine.behavior.IC
  * <p>
  * @author Aaron Smuts
  */
-public class MySQLDiskCache
-    extends JDBCDiskCache
+public class MySQLDiskCache<K extends Serializable, V extends Serializable>
+    extends JDBCDiskCache<K, V>
 {
     /** don't change */
     private static final long serialVersionUID = -7169488308515823491L;
@@ -77,7 +77,7 @@ public class MySQLDiskCache
      * @return An object matching key, or null.
      */
     @Override
-    protected ICacheElement processGet( Serializable key )
+    protected ICacheElement<K, V> processGet( K key )
     {
         if ( this.getTableState().getState() == TableState.OPTIMIZATION_RUNNING )
         {
@@ -97,7 +97,7 @@ public class MySQLDiskCache
      * @return An object matching key, or null.
      */
     @Override
-    protected Map<Serializable, ICacheElement> processGetMatching( String pattern )
+    protected Map<K, ICacheElement<K, V>> processGetMatching( String pattern )
     {
         if ( this.getTableState().getState() == TableState.OPTIMIZATION_RUNNING )
         {
@@ -134,7 +134,7 @@ public class MySQLDiskCache
      * @param element
      */
     @Override
-    protected void processUpdate( ICacheElement element )
+    protected void processUpdate( ICacheElement<K, V> element )
     {
         if ( this.getTableState().getState() == TableState.OPTIMIZATION_RUNNING )
         {



Mime
View raw message