commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From t.@apache.org
Subject svn commit: r1232163 [7/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/engine/memory/AbstractDoulbeLinkedListMemoryCache.java
URL: http://svn.apache.org/viewvc/commons/proper/jcs/branches/generics-interface/src/java/org/apache/jcs/engine/memory/AbstractDoulbeLinkedListMemoryCache.java?rev=1232163&r1=1232162&r2=1232163&view=diff
==============================================================================
--- commons/proper/jcs/branches/generics-interface/src/java/org/apache/jcs/engine/memory/AbstractDoulbeLinkedListMemoryCache.java (original)
+++ commons/proper/jcs/branches/generics-interface/src/java/org/apache/jcs/engine/memory/AbstractDoulbeLinkedListMemoryCache.java Mon Jan 16 21:05:44 2012
@@ -30,8 +30,8 @@ import org.apache.jcs.utils.struct.Doubl
  * 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 AbstractDoulbeLinkedListMemoryCache
-    extends AbstractMemoryCache
+public abstract class AbstractDoulbeLinkedListMemoryCache<K extends Serializable, V extends Serializable>
+    extends AbstractMemoryCache<K, V>
 {
     /** Don't change. */
     private static final long serialVersionUID = 1422569420563967389L;
@@ -40,7 +40,7 @@ public abstract class AbstractDoulbeLink
     private final static Log log = LogFactory.getLog( AbstractDoulbeLinkedListMemoryCache.class );
 
     /** thread-safe double linked list for lru */
-    protected DoubleLinkedList<MemoryElementDescriptor> list;
+    protected DoubleLinkedList<MemoryElementDescriptor<K, V>> list;
 
     /** number of hits */
     protected int hitCnt = 0;
@@ -57,10 +57,10 @@ public abstract class AbstractDoulbeLink
      * @param hub
      */
     @Override
-    public synchronized void initialize( CompositeCache hub )
+    public synchronized void initialize( CompositeCache<K, V> hub )
     {
         super.initialize( hub );
-        list = new DoubleLinkedList<MemoryElementDescriptor>();
+        list = new DoubleLinkedList<MemoryElementDescriptor<K, V>>();
         log.info( "initialized MemoryCache for " + cacheName );
     }
 
@@ -70,9 +70,9 @@ public abstract class AbstractDoulbeLink
      * @return new Hashtable()
      */
     @Override
-    public Map<Serializable, MemoryElementDescriptor> createMap()
+    public Map<K, MemoryElementDescriptor<K, V>> createMap()
     {
-        return new Hashtable<Serializable, MemoryElementDescriptor>();
+        return new Hashtable<K, MemoryElementDescriptor<K, V>>();
     }
 
     /**
@@ -84,7 +84,7 @@ public abstract class AbstractDoulbeLink
      * @exception IOException
      */
     @Override
-    public final void update( ICacheElement ce )
+    public final void update( ICacheElement<K, V> ce )
         throws IOException
     {
         putCnt++;
@@ -93,10 +93,10 @@ public abstract class AbstractDoulbeLink
         synchronized ( this )
         {
             // ABSTRACT
-            MemoryElementDescriptor newNode = adjustListForUpdate( ce );
+            MemoryElementDescriptor<K, V> newNode = adjustListForUpdate( ce );
 
             // this must be synchronized
-            MemoryElementDescriptor oldNode = map.put( newNode.ce.getKey(), newNode );
+            MemoryElementDescriptor<K, V> oldNode = map.put( newNode.ce.getKey(), newNode );
 
             // If the node was the same as an existing node, remove it.
             if ( oldNode != null && ( newNode.ce.getKey().equals( oldNode.ce.getKey() ) ) )
@@ -116,7 +116,7 @@ public abstract class AbstractDoulbeLink
      * @return MemoryElementDescriptor the new node
      * @throws IOException
      */
-    protected abstract MemoryElementDescriptor adjustListForUpdate( ICacheElement ce )
+    protected abstract MemoryElementDescriptor<K, V> adjustListForUpdate( ICacheElement<K, V> ce )
         throws IOException;
 
     /**
@@ -167,21 +167,21 @@ public abstract class AbstractDoulbeLink
      * Get an item from the cache If the item is found, it is removed from the list and added first.
      * <p>
      * @param key Identifies item to find
-     * @return ICacheElement if found, else null
+     * @return ICacheElement<K, V> if found, else null
      * @exception IOException
      */
     @Override
-    public final synchronized ICacheElement get( Serializable key )
+    public final synchronized ICacheElement<K, V> get( K key )
         throws IOException
     {
-        ICacheElement ce = null;
+        ICacheElement<K, V> ce = null;
 
         if ( log.isDebugEnabled() )
         {
             log.debug( "getting item from cache " + cacheName + " for key " + key );
         }
 
-        MemoryElementDescriptor me = map.get( key );
+        MemoryElementDescriptor<K, V> me = map.get( key );
 
         if ( me != null )
         {
@@ -214,7 +214,7 @@ public abstract class AbstractDoulbeLink
      * <p>
      * @param me
      */
-    protected abstract void adjustListForGet( MemoryElementDescriptor me );
+    protected abstract void adjustListForGet( MemoryElementDescriptor<K, V> me );
 
     /**
      * This instructs the memory cache to remove the <i>numberToFree</i> according to its eviction
@@ -232,7 +232,7 @@ public abstract class AbstractDoulbeLink
         int freed = 0;
         for ( ; freed < numberToFree; freed++ )
         {
-            ICacheElement element = spoolLastElement();
+            ICacheElement<K, V> element = spoolLastElement();
             if ( element == null )
             {
                 break;
@@ -244,13 +244,13 @@ public abstract class AbstractDoulbeLink
     /**
      * This spools the last element in the LRU, if one exists.
      * <p>
-     * @return ICacheElement if there was a last element, else null.
+     * @return ICacheElement<K, V> if there was a last element, else null.
      * @throws Error
      */
-    protected ICacheElement spoolLastElement()
+    protected ICacheElement<K, V> spoolLastElement()
         throws Error
     {
-        ICacheElement toSpool = null;
+        ICacheElement<K, V> toSpool = null;
         synchronized ( this )
         {
             if ( list.getLast() != null )
@@ -305,7 +305,7 @@ public abstract class AbstractDoulbeLink
      * @exception IOException
      */
     @Override
-    public synchronized boolean remove( Serializable key )
+    public synchronized boolean remove( K key )
         throws IOException
     {
         if ( log.isDebugEnabled() )
@@ -321,10 +321,10 @@ public abstract class AbstractDoulbeLink
             // remove all keys of the same name hierarchy.
             synchronized ( map )
             {
-                for (Iterator<Map.Entry<Serializable, MemoryElementDescriptor>> itr = map.entrySet().iterator(); itr.hasNext(); )
+                for (Iterator<Map.Entry<K, MemoryElementDescriptor<K, V>>> itr = map.entrySet().iterator(); itr.hasNext(); )
                 {
-                    Map.Entry<Serializable, MemoryElementDescriptor> entry = itr.next();
-                    Object k = entry.getKey();
+                    Map.Entry<K, MemoryElementDescriptor<K, V>> entry = itr.next();
+                    K k = entry.getKey();
 
                     if ( k instanceof String && ( (String) k ).startsWith( key.toString() ) )
                     {
@@ -340,10 +340,10 @@ public abstract class AbstractDoulbeLink
             // remove all keys of the same name hierarchy.
             synchronized ( map )
             {
-                for (Iterator<Map.Entry<Serializable, MemoryElementDescriptor>> itr = map.entrySet().iterator(); itr.hasNext(); )
+                for (Iterator<Map.Entry<K, MemoryElementDescriptor<K, V>>> itr = map.entrySet().iterator(); itr.hasNext(); )
                 {
-                    Map.Entry<Serializable, MemoryElementDescriptor> entry = itr.next();
-                    Object k = entry.getKey();
+                    Map.Entry<K, MemoryElementDescriptor<K, V>> entry = itr.next();
+                    K k = entry.getKey();
 
                     if ( k instanceof GroupAttrName && ( (GroupAttrName) k ).groupId.equals( key ) )
                     {
@@ -357,7 +357,7 @@ public abstract class AbstractDoulbeLink
         else
         {
             // remove single item.
-            MemoryElementDescriptor me = map.remove( key );
+            MemoryElementDescriptor<K, V> me = map.remove( key );
 
             if ( me != null )
             {
@@ -390,9 +390,9 @@ public abstract class AbstractDoulbeLink
      * @param ce The feature to be added to the First
      * @return MemoryElementDescriptor
      */
-    protected synchronized MemoryElementDescriptor addFirst( ICacheElement ce )
+    protected synchronized MemoryElementDescriptor<K, V> addFirst( ICacheElement<K, V> ce )
     {
-        MemoryElementDescriptor me = new MemoryElementDescriptor( ce );
+        MemoryElementDescriptor<K, V> me = new MemoryElementDescriptor<K, V>( ce );
         list.addFirst( me );
         verifyCache( ce.getKey() );
         return me;
@@ -404,9 +404,9 @@ public abstract class AbstractDoulbeLink
      * @param ce The feature to be added to the First
      * @return MemoryElementDescriptor
      */
-    protected synchronized MemoryElementDescriptor addLast( ICacheElement ce )
+    protected synchronized MemoryElementDescriptor<K, V> addLast( ICacheElement<K, V> ce )
     {
-        MemoryElementDescriptor me = new MemoryElementDescriptor( ce );
+        MemoryElementDescriptor<K, V> me = new MemoryElementDescriptor<K, V>( ce );
         list.addLast( me );
         verifyCache( ce.getKey() );
         return me;
@@ -420,7 +420,7 @@ public abstract class AbstractDoulbeLink
     public void dumpCacheEntries()
     {
         log.debug( "dumpingCacheEntries" );
-        for ( MemoryElementDescriptor me = list.getFirst(); me != null; me = (MemoryElementDescriptor) me.next )
+        for ( MemoryElementDescriptor<K, V> me = list.getFirst(); me != null; me = (MemoryElementDescriptor<K, V>) me.next )
         {
             log.debug( "dumpCacheEntries> key=" + me.ce.getKey() + ", val=" + me.ce.getVal() );
         }
@@ -451,7 +451,7 @@ public abstract class AbstractDoulbeLink
         log.debug( "verifycache[" + cacheName + "]: mapContains " + map.size() + " elements, linked list contains "
             + dumpCacheSize() + " elements" );
         log.debug( "verifycache: checking linked list by key " );
-        for ( MemoryElementDescriptor li = list.getFirst(); li != null; li = (MemoryElementDescriptor) li.next )
+        for ( MemoryElementDescriptor<K, V> li = list.getFirst(); li != null; li = (MemoryElementDescriptor<K, V>) li.next )
         {
             Object key = li.ce.getKey();
             if ( !map.containsKey( key ) )
@@ -479,7 +479,7 @@ public abstract class AbstractDoulbeLink
         }
 
         log.debug( "verifycache: checking linked list by value " );
-        for ( MemoryElementDescriptor li3 = list.getFirst(); li3 != null; li3 = (MemoryElementDescriptor) li3.next )
+        for ( MemoryElementDescriptor<K, V> li3 = list.getFirst(); li3 != null; li3 = (MemoryElementDescriptor<K, V>) li3.next )
         {
             if ( map.containsValue( li3 ) == false )
             {
@@ -493,7 +493,7 @@ public abstract class AbstractDoulbeLink
         {
             found = false;
 
-            for ( MemoryElementDescriptor li2 = list.getFirst(); li2 != null; li2 = (MemoryElementDescriptor) li2.next )
+            for ( MemoryElementDescriptor<K, V> li2 = list.getFirst(); li2 != null; li2 = (MemoryElementDescriptor<K, V>) li2.next )
             {
                 if ( val.equals( li2.ce.getKey() ) )
                 {
@@ -522,7 +522,7 @@ public abstract class AbstractDoulbeLink
      * <p>
      * @param key
      */
-    private void verifyCache( Serializable key )
+    private void verifyCache( K key )
     {
         if ( !log.isDebugEnabled() )
         {
@@ -532,7 +532,7 @@ public abstract class AbstractDoulbeLink
         boolean found = false;
 
         // go through the linked list looking for the key
-        for ( MemoryElementDescriptor li = list.getFirst(); li != null; li = (MemoryElementDescriptor) li.next )
+        for ( MemoryElementDescriptor<K, V> li = list.getFirst(); li != null; li = (MemoryElementDescriptor<K, V>) li.next )
         {
             if ( li.ce.getKey() == key )
             {
@@ -551,17 +551,17 @@ public abstract class AbstractDoulbeLink
     /**
      * iteration aid
      */
-    public static class IteratorWrapper
-        implements Iterator<Entry<Serializable, MemoryElementDescriptor>>
+    public static class IteratorWrapper<K extends Serializable, V extends Serializable>
+        implements Iterator<Entry<K, MemoryElementDescriptor<K, V>>>
     {
         /** The internal iterator */
-        private final Iterator<Entry<Serializable, MemoryElementDescriptor>> i;
+        private final Iterator<Entry<K, MemoryElementDescriptor<K, V>>> i;
 
         /**
          * Wrapped to remove our wrapper object
          * @param m
          */
-        protected IteratorWrapper(Map<Serializable, MemoryElementDescriptor> m)
+        protected IteratorWrapper(Map<K, MemoryElementDescriptor<K, V>> m)
         {
             i = m.entrySet().iterator();
         }
@@ -573,7 +573,7 @@ public abstract class AbstractDoulbeLink
         }
 
         /** @return new MapEntryWrapper( (Map.Entry) i.next() ) */
-        public Entry<Serializable, MemoryElementDescriptor> next()
+        public Entry<K, MemoryElementDescriptor<K, V>> next()
         {
             // return new MapEntryWrapper<Serializable>( i.next() );
             return i.next();
@@ -606,16 +606,16 @@ public abstract class AbstractDoulbeLink
     /**
      * @author Aaron Smuts
      */
-    public static class MapEntryWrapper<K>
-        implements Map.Entry<K, ICacheElement>
+    public static class MapEntryWrapper<K extends Serializable, V extends Serializable>
+        implements Map.Entry<K, ICacheElement<K, V>>
     {
         /** The internal entry */
-        private final Map.Entry<K, MemoryElementDescriptor> e;
+        private final Map.Entry<K, MemoryElementDescriptor<K, V>> e;
 
         /**
          * @param e
          */
-        private MapEntryWrapper( Map.Entry<K, MemoryElementDescriptor> e )
+        private MapEntryWrapper( Map.Entry<K, MemoryElementDescriptor<K, V>> e )
         {
             this.e = e;
         }
@@ -637,7 +637,7 @@ public abstract class AbstractDoulbeLink
         }
 
         /** @return ( (MemoryElementDescriptor) e.getValue() ).ce */
-        public ICacheElement getValue()
+        public ICacheElement<K, V> getValue()
         {
             return e.getValue().ce;
         }
@@ -654,7 +654,7 @@ public abstract class AbstractDoulbeLink
          * @param value
          * @return always throws
          */
-        public ICacheElement setValue(ICacheElement value)
+        public ICacheElement<K, V> setValue(ICacheElement<K, V> value)
         {
             throw new UnsupportedOperationException( "Use normal cache methods"
                 + " to alter the contents of the cache." );
@@ -667,9 +667,9 @@ public abstract class AbstractDoulbeLink
      * @return The iterator value
      */
     @Override
-    public Iterator<Entry<Serializable, MemoryElementDescriptor>> getIterator()
+    public Iterator<Entry<K, MemoryElementDescriptor<K, V>>> getIterator()
     {
-        return new IteratorWrapper( map );
+        return new IteratorWrapper<K, V>( map );
     }
 
     /**
@@ -677,13 +677,13 @@ public abstract class AbstractDoulbeLink
      * @return An Object[]
      */
     @Override
-    public Object[] getKeyArray()
+    public K[] getKeyArray()
     {
         // need a better locking strategy here.
         synchronized ( this )
         {
             // may need to lock to map here?
-            return map.keySet().toArray();
+            return (K[]) map.keySet().toArray();
         }
     }
 

Modified: commons/proper/jcs/branches/generics-interface/src/java/org/apache/jcs/engine/memory/AbstractMemoryCache.java
URL: http://svn.apache.org/viewvc/commons/proper/jcs/branches/generics-interface/src/java/org/apache/jcs/engine/memory/AbstractMemoryCache.java?rev=1232163&r1=1232162&r2=1232163&view=diff
==============================================================================
--- commons/proper/jcs/branches/generics-interface/src/java/org/apache/jcs/engine/memory/AbstractMemoryCache.java (original)
+++ commons/proper/jcs/branches/generics-interface/src/java/org/apache/jcs/engine/memory/AbstractMemoryCache.java Mon Jan 16 21:05:44 2012
@@ -51,8 +51,8 @@ import org.apache.jcs.engine.stats.behav
  * 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
-    implements MemoryCache, Serializable
+public abstract class AbstractMemoryCache<K extends Serializable, V extends Serializable>
+    implements MemoryCache<K, V>, Serializable
 {
     /** Don't change. */
     private static final long serialVersionUID = -4494626991630099575L;
@@ -64,7 +64,7 @@ public abstract class AbstractMemoryCach
     protected String cacheName;
 
     /** Map where items are stored by key.  This is created by the concrete child class. */
-    protected Map<Serializable, MemoryElementDescriptor> map;
+    protected Map<K, MemoryElementDescriptor<K, V>> map;
 
     /** Region Elemental Attributes, used as a default and copied for each item. */
     public IElementAttributes elementAttributes;
@@ -73,7 +73,7 @@ public abstract class AbstractMemoryCach
     public ICompositeCacheAttributes cacheAttributes;
 
     /** The cache region this store is associated with */
-    protected CompositeCache cache;
+    protected CompositeCache<K, V> cache;
 
     /** status */
     protected int status;
@@ -90,7 +90,7 @@ public abstract class AbstractMemoryCach
      * <p>
      * @param hub
      */
-    public synchronized void initialize( CompositeCache hub )
+    public synchronized void initialize( CompositeCache<K, V> hub )
     {
         this.cacheName = hub.getCacheName();
         this.cacheAttributes = hub.getCacheAttributes();
@@ -107,7 +107,7 @@ public abstract class AbstractMemoryCach
                 shrinkerDaemon = Executors.newScheduledThreadPool(1, new MyThreadFactory());
             }
 
-            shrinkerDaemon.scheduleAtFixedRate(new ShrinkerThread(this), 0, cacheAttributes.getShrinkerIntervalSeconds(), TimeUnit.SECONDS);
+            shrinkerDaemon.scheduleAtFixedRate(new ShrinkerThread<K, V>(this), 0, cacheAttributes.getShrinkerIntervalSeconds(), TimeUnit.SECONDS);
         }
     }
 
@@ -117,7 +117,7 @@ public abstract class AbstractMemoryCach
      * <p>
      * @return a threadsafe Map
      */
-    public abstract Map<Serializable, MemoryElementDescriptor> createMap();
+    public abstract Map<K, MemoryElementDescriptor<K, V>> createMap();
 
     /**
      * Removes an item from the cache
@@ -126,7 +126,7 @@ public abstract class AbstractMemoryCach
      * @return Description of the Return Value
      * @exception IOException Description of the Exception
      */
-    public abstract boolean remove( Serializable key )
+    public abstract boolean remove( K key )
         throws IOException;
 
     /**
@@ -136,27 +136,27 @@ public abstract class AbstractMemoryCach
      * @return Description of the Return Value
      * @exception IOException Description of the Exception
      */
-    public abstract ICacheElement get( Serializable key )
+    public abstract ICacheElement<K, V> get( K key )
         throws IOException;
 
     /**
      * 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
      * @throws IOException
      */
-    public Map<Serializable, ICacheElement> getMultiple( Set<Serializable> keys )
+    public Map<K, ICacheElement<K, V>> getMultiple( Set<K> keys )
         throws IOException
     {
-        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 )
                 {
@@ -176,12 +176,12 @@ public abstract class AbstractMemoryCach
      * @return Element matching key if found, or null
      * @exception IOException
      */
-    public ICacheElement getQuiet( Serializable key )
+    public ICacheElement<K, V> getQuiet( K key )
         throws IOException
     {
-        ICacheElement ce = null;
+        ICacheElement<K, V> ce = null;
 
-        MemoryElementDescriptor me = map.get( key );
+        MemoryElementDescriptor<K, V> me = map.get( key );
         if ( me != null )
         {
             if ( log.isDebugEnabled() )
@@ -205,7 +205,7 @@ public abstract class AbstractMemoryCach
      * @param ce Description of the Parameter
      * @exception IOException Description of the Exception
      */
-    public abstract void update( ICacheElement ce )
+    public abstract void update( ICacheElement<K, V> ce )
         throws IOException;
 
     /**
@@ -213,7 +213,7 @@ public abstract class AbstractMemoryCach
      * <p>
      * @return An Object[]
      */
-    public abstract Object[] getKeyArray();
+    public abstract K[] getKeyArray();
 
     /**
      * Removes all cached items from the cache.
@@ -287,7 +287,7 @@ public abstract class AbstractMemoryCach
      * @param ce
      * @exception IOException
      */
-    public void waterfal( ICacheElement ce )
+    public void waterfal( ICacheElement<K, V> ce )
         throws IOException
     {
         this.cache.spoolToDisk( ce );
@@ -298,7 +298,7 @@ public abstract class AbstractMemoryCach
      * <p>
      * @return The iterator value
      */
-    public Iterator<Map.Entry<Serializable, MemoryElementDescriptor>> getIterator()
+    public Iterator<Map.Entry<K, MemoryElementDescriptor<K, V>>> getIterator()
     {
         return map.entrySet().iterator();
     }
@@ -310,9 +310,9 @@ public abstract class AbstractMemoryCach
     public void dumpMap()
     {
         log.debug( "dumpingMap" );
-        for (Map.Entry<Serializable, MemoryElementDescriptor> e : map.entrySet())
+        for (Map.Entry<K, MemoryElementDescriptor<K, V>> e : map.entrySet())
         {
-            MemoryElementDescriptor me = e.getValue();
+            MemoryElementDescriptor<K, V> me = e.getValue();
             log.debug( "dumpMap> key=" + e.getKey() + ", val=" + me.ce.getVal() );
         }
     }
@@ -342,7 +342,7 @@ public abstract class AbstractMemoryCach
      * <p>
      * @return The cache value
      */
-    public CompositeCache getCompositeCache()
+    public CompositeCache<K, V> getCompositeCache()
     {
         return this.cache;
     }
@@ -351,19 +351,19 @@ public abstract class AbstractMemoryCach
      * @param groupName
      * @return group keys
      */
-    public Set<Serializable> getGroupKeys( String groupName )
+    public Set<K> getGroupKeys( String groupName )
     {
         GroupId groupId = new GroupId( getCacheName(), groupName );
-        HashSet<Serializable> keys = new HashSet<Serializable>();
+        HashSet<K> keys = new HashSet<K>();
         synchronized ( map )
         {
-            for (Map.Entry<Serializable, MemoryElementDescriptor> entry : map.entrySet())
+            for (Map.Entry<K, MemoryElementDescriptor<K, V>> entry : map.entrySet())
             {
-                Object k = entry.getKey();
+                K k = entry.getKey();
 
                 if ( k instanceof GroupAttrName && ( (GroupAttrName) k ).groupId.equals( groupId ) )
                 {
-                    keys.add((Serializable) ( (GroupAttrName) k ).attrName );
+                    keys.add(( (GroupAttrName) k ).attrName );
                 }
             }
         }

Modified: commons/proper/jcs/branches/generics-interface/src/java/org/apache/jcs/engine/memory/MemoryCache.java
URL: http://svn.apache.org/viewvc/commons/proper/jcs/branches/generics-interface/src/java/org/apache/jcs/engine/memory/MemoryCache.java?rev=1232163&r1=1232162&r2=1232163&view=diff
==============================================================================
--- commons/proper/jcs/branches/generics-interface/src/java/org/apache/jcs/engine/memory/MemoryCache.java (original)
+++ commons/proper/jcs/branches/generics-interface/src/java/org/apache/jcs/engine/memory/MemoryCache.java Mon Jan 16 21:05:44 2012
@@ -19,6 +19,8 @@ package org.apache.jcs.engine.memory;
  * under the License.
  */
 
+import java.io.Serializable;
+
 import org.apache.jcs.engine.memory.behavior.IMemoryCache;
 
 /**
@@ -30,8 +32,8 @@ import org.apache.jcs.engine.memory.beha
  * of.
  * <p>
  */
-public interface MemoryCache
-    extends IMemoryCache
+public interface MemoryCache<K extends Serializable, V extends Serializable>
+    extends IMemoryCache<K, V>
 {
     // temporary, for backward compatibility.
 }

Modified: commons/proper/jcs/branches/generics-interface/src/java/org/apache/jcs/engine/memory/behavior/IMemoryCache.java
URL: http://svn.apache.org/viewvc/commons/proper/jcs/branches/generics-interface/src/java/org/apache/jcs/engine/memory/behavior/IMemoryCache.java?rev=1232163&r1=1232162&r2=1232163&view=diff
==============================================================================
--- commons/proper/jcs/branches/generics-interface/src/java/org/apache/jcs/engine/memory/behavior/IMemoryCache.java (original)
+++ commons/proper/jcs/branches/generics-interface/src/java/org/apache/jcs/engine/memory/behavior/IMemoryCache.java Mon Jan 16 21:05:44 2012
@@ -32,14 +32,14 @@ import org.apache.jcs.engine.memory.util
 import org.apache.jcs.engine.stats.behavior.IStats;
 
 /** For the framework. Insures methods a MemoryCache needs to access. */
-public interface IMemoryCache
+public interface IMemoryCache<K extends Serializable, V extends Serializable>
 {
     /**
      * Initialize the memory cache
      * <p>
      * @param cache The cache (region) this memory store is attached to.
      */
-    void initialize( CompositeCache cache );
+    void initialize( CompositeCache<K, V> cache );
 
     /**
      * Destroy the memory cache
@@ -70,7 +70,7 @@ public interface IMemoryCache
      * <p>
      * @return An iterator
      */
-    Iterator<Map.Entry<Serializable, MemoryElementDescriptor>> getIterator();
+    Iterator<Map.Entry<K, MemoryElementDescriptor<K, V>>> getIterator();
 
     /**
      * Get an Array of the keys for all elements in the memory cache.
@@ -80,7 +80,7 @@ public interface IMemoryCache
      *       will be a problem if someone puts a 1,000,000 or so items in a
      *       region.
      */
-    Object[] getKeyArray();
+    K[] getKeyArray();
 
     /**
      * Removes an item from the cache
@@ -91,7 +91,7 @@ public interface IMemoryCache
      * @exception IOException
      *                Description of the Exception
      */
-    boolean remove( Serializable key )
+    boolean remove( K key )
         throws IOException;
 
     /**
@@ -126,18 +126,18 @@ public interface IMemoryCache
      * @exception IOException
      *                Description of the Exception
      */
-    ICacheElement get( Serializable key )
+    ICacheElement<K, V> get( K key )
         throws IOException;
 
     /**
      * 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
+     * @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
      * @throws IOException
      */
-    Map<Serializable, ICacheElement> getMultiple( Set<Serializable> keys )
+    Map<K, ICacheElement<K, V>> getMultiple( Set<K> keys )
         throws IOException;
 
     /**
@@ -150,7 +150,7 @@ public interface IMemoryCache
      * @exception IOException
      *                Description of the Exception
      */
-    ICacheElement getQuiet( Serializable key )
+    ICacheElement<K, V> getQuiet( K key )
         throws IOException;
 
     /**
@@ -161,7 +161,7 @@ public interface IMemoryCache
      * @exception IOException
      *                Description of the Exception
      */
-    void waterfal( ICacheElement ce )
+    void waterfal( ICacheElement<K, V> ce )
         throws IOException;
 
     /**
@@ -172,7 +172,7 @@ public interface IMemoryCache
      * @exception IOException
      *                Description of the Exception
      */
-    void update( ICacheElement ce )
+    void update( ICacheElement<K, V> ce )
         throws IOException;
 
     /**
@@ -195,7 +195,7 @@ public interface IMemoryCache
      * <p>
      * @return The cache value
      */
-    CompositeCache getCompositeCache();
+    CompositeCache<K, V> getCompositeCache();
 
     /**
      * Gets the set of keys of objects currently in the group.
@@ -203,5 +203,5 @@ public interface IMemoryCache
      * @param group
      * @return a Set of group keys.
      */
-    Set<Serializable> getGroupKeys( String group );
+    Set<K> getGroupKeys( String group );
 }

Modified: commons/proper/jcs/branches/generics-interface/src/java/org/apache/jcs/engine/memory/fifo/FIFOMemoryCache.java
URL: http://svn.apache.org/viewvc/commons/proper/jcs/branches/generics-interface/src/java/org/apache/jcs/engine/memory/fifo/FIFOMemoryCache.java?rev=1232163&r1=1232162&r2=1232163&view=diff
==============================================================================
--- commons/proper/jcs/branches/generics-interface/src/java/org/apache/jcs/engine/memory/fifo/FIFOMemoryCache.java (original)
+++ commons/proper/jcs/branches/generics-interface/src/java/org/apache/jcs/engine/memory/fifo/FIFOMemoryCache.java Mon Jan 16 21:05:44 2012
@@ -20,6 +20,7 @@ package org.apache.jcs.engine.memory.fif
  */
 
 import java.io.IOException;
+import java.io.Serializable;
 
 import org.apache.jcs.engine.behavior.ICacheElement;
 import org.apache.jcs.engine.memory.AbstractDoulbeLinkedListMemoryCache;
@@ -28,8 +29,8 @@ import org.apache.jcs.engine.memory.util
 /**
  * The items are spooled in the order they are added. No adjustments to the list are made on get.
  */
-public class FIFOMemoryCache
-    extends AbstractDoulbeLinkedListMemoryCache
+public class FIFOMemoryCache<K extends Serializable, V extends Serializable>
+    extends AbstractDoulbeLinkedListMemoryCache<K, V>
 {
     /** Don't change */
     private static final long serialVersionUID = 6403738094136424201L;
@@ -42,7 +43,7 @@ public class FIFOMemoryCache
      * @return MemoryElementDescriptor the new node
      * @exception IOException
      */
-    protected MemoryElementDescriptor adjustListForUpdate( ICacheElement ce )
+    protected MemoryElementDescriptor<K, V> adjustListForUpdate( ICacheElement<K, V> ce )
         throws IOException
     {
         return addFirst( ce );
@@ -53,7 +54,7 @@ public class FIFOMemoryCache
      * <p>
      * @param me
      */
-    protected void adjustListForGet( MemoryElementDescriptor me )
+    protected void adjustListForGet( MemoryElementDescriptor<K, V> me )
     {
         // DO NOTHING
     }

Modified: commons/proper/jcs/branches/generics-interface/src/java/org/apache/jcs/engine/memory/lru/LHMLRUMemoryCache.java
URL: http://svn.apache.org/viewvc/commons/proper/jcs/branches/generics-interface/src/java/org/apache/jcs/engine/memory/lru/LHMLRUMemoryCache.java?rev=1232163&r1=1232162&r2=1232163&view=diff
==============================================================================
--- commons/proper/jcs/branches/generics-interface/src/java/org/apache/jcs/engine/memory/lru/LHMLRUMemoryCache.java (original)
+++ commons/proper/jcs/branches/generics-interface/src/java/org/apache/jcs/engine/memory/lru/LHMLRUMemoryCache.java Mon Jan 16 21:05:44 2012
@@ -43,8 +43,8 @@ import org.apache.jcs.engine.stats.behav
 /**
  * This is a test memory manager using the jdk1.4 LinkedHashMap.
  */
-public class LHMLRUMemoryCache
-    extends AbstractMemoryCache
+public class LHMLRUMemoryCache<K extends Serializable, V extends Serializable>
+    extends AbstractMemoryCache<K, V>
 {
     /** Don't change */
     private static final long serialVersionUID = 6403738094136424101L;
@@ -67,7 +67,7 @@ public class LHMLRUMemoryCache
      * @param hub
      */
     @Override
-    public synchronized void initialize( CompositeCache hub )
+    public synchronized void initialize( CompositeCache<K, V> hub )
     {
         super.initialize( hub );
         log.info( "initialized LHMLRUMemoryCache for " + cacheName );
@@ -79,7 +79,7 @@ public class LHMLRUMemoryCache
      * @return Collections.synchronizedMap( new LHMSpooler() )
      */
     @Override
-    public Map<Serializable, MemoryElementDescriptor> createMap()
+    public Map<K, MemoryElementDescriptor<K, V>> createMap()
     {
         return Collections.synchronizedMap( new LHMSpooler() );
     }
@@ -91,12 +91,12 @@ public class LHMLRUMemoryCache
      * @exception IOException
      */
     @Override
-    public void update( ICacheElement ce )
+    public void update( ICacheElement<K, V> ce )
         throws IOException
     {
         putCnt++;
         ce.getElementAttributes().setLastAccessTimeNow();
-        map.put( ce.getKey(), new MemoryElementDescriptor(ce) );
+        map.put( ce.getKey(), new MemoryElementDescriptor<K, V>(ce) );
     }
 
     /**
@@ -108,7 +108,7 @@ public class LHMLRUMemoryCache
      * @exception IOException
      */
     @Override
-    public ICacheElement getQuiet( Serializable key )
+    public ICacheElement<K, V> getQuiet( K key )
         throws IOException
     {
         return map.get( key ).ce;
@@ -118,14 +118,14 @@ public class LHMLRUMemoryCache
      * Get an item from the cache
      * <p>
      * @param key Identifies item to find
-     * @return ICacheElement if found, else null
+     * @return ICacheElement<K, V> if found, else null
      * @exception IOException
      */
     @Override
-    public synchronized ICacheElement get( Serializable key )
+    public synchronized ICacheElement<K, V> get( K key )
         throws IOException
     {
-        MemoryElementDescriptor me = null;
+        MemoryElementDescriptor<K, V> me = null;
 
         if ( log.isDebugEnabled() )
         {
@@ -163,7 +163,7 @@ public class LHMLRUMemoryCache
      * @exception IOException
      */
     @Override
-    public synchronized boolean remove( Serializable key )
+    public synchronized boolean remove( K key )
         throws IOException
     {
         if ( log.isDebugEnabled() )
@@ -179,10 +179,10 @@ public class LHMLRUMemoryCache
             // remove all keys of the same name hierarchy.
             synchronized ( map )
             {
-                for (Iterator<Map.Entry<Serializable, MemoryElementDescriptor>> itr = map.entrySet().iterator(); itr.hasNext(); )
+                for (Iterator<Map.Entry<K, MemoryElementDescriptor<K, V>>> itr = map.entrySet().iterator(); itr.hasNext(); )
                 {
-                    Map.Entry<Serializable, MemoryElementDescriptor> entry = itr.next();
-                    Object k = entry.getKey();
+                    Map.Entry<K, MemoryElementDescriptor<K, V>> entry = itr.next();
+                    K k = entry.getKey();
 
                     if ( k instanceof String && ( (String) k ).startsWith( key.toString() ) )
                     {
@@ -197,10 +197,10 @@ public class LHMLRUMemoryCache
             // remove all keys of the same name hierarchy.
             synchronized ( map )
             {
-                for (Iterator<Map.Entry<Serializable, MemoryElementDescriptor>> itr = map.entrySet().iterator(); itr.hasNext(); )
+                for (Iterator<Map.Entry<K, MemoryElementDescriptor<K, V>>> itr = map.entrySet().iterator(); itr.hasNext(); )
                 {
-                    Map.Entry<Serializable, MemoryElementDescriptor> entry = itr.next();
-                    Object k = entry.getKey();
+                    Map.Entry<K, MemoryElementDescriptor<K, V>> entry = itr.next();
+                    K k = entry.getKey();
 
                     if ( k instanceof GroupAttrName && ( (GroupAttrName) k ).groupId.equals( key ) )
                     {
@@ -213,7 +213,7 @@ public class LHMLRUMemoryCache
         else
         {
             // remove single item.
-            MemoryElementDescriptor me = map.remove( key );
+            MemoryElementDescriptor<K, V> me = map.remove( key );
             if ( me != null )
             {
                 removed = true;
@@ -229,13 +229,13 @@ public class LHMLRUMemoryCache
      * @return An Object[]
      */
     @Override
-    public Object[] getKeyArray()
+    public K[] getKeyArray()
     {
         // need a better locking strategy here.
         synchronized ( this )
         {
             // may need to lock to map here?
-            return map.keySet().toArray();
+            return (K[])map.keySet().toArray();
         }
     }
 
@@ -315,7 +315,7 @@ public class LHMLRUMemoryCache
      * Implementation of removeEldestEntry in LinkedHashMap
      */
     public class LHMSpooler
-        extends java.util.LinkedHashMap<Serializable, MemoryElementDescriptor>
+        extends java.util.LinkedHashMap<K, MemoryElementDescriptor<K, V>>
     {
         /** Don't change. */
         private static final long serialVersionUID = -1255907868906762484L;
@@ -336,9 +336,9 @@ public class LHMLRUMemoryCache
          * @return true if removed
          */
         @Override
-        protected boolean removeEldestEntry( Map.Entry<Serializable, MemoryElementDescriptor> eldest )
+        protected boolean removeEldestEntry( Map.Entry<K, MemoryElementDescriptor<K, V>> eldest )
         {
-            ICacheElement element = eldest.getValue().ce;
+            ICacheElement<K, V> element = eldest.getValue().ce;
 
             if ( size() <= cache.getCacheAttributes().getMaxObjects() )
             {
@@ -367,13 +367,13 @@ public class LHMLRUMemoryCache
          * <p>
          * @param element The CacheElement
          */
-        private void spoolToDisk( ICacheElement element )
+        private void spoolToDisk( ICacheElement<K, V> element )
         {
             cache.spoolToDisk( element );
 
             if ( log.isDebugEnabled() )
             {
-                log.debug( cache.getCacheName() + "Spoolled element to disk: " + element.getKey() );
+                log.debug( cache.getCacheName() + "Spooled element to disk: " + element.getKey() );
             }
         }
     }

Modified: commons/proper/jcs/branches/generics-interface/src/java/org/apache/jcs/engine/memory/lru/LRUMemoryCache.java
URL: http://svn.apache.org/viewvc/commons/proper/jcs/branches/generics-interface/src/java/org/apache/jcs/engine/memory/lru/LRUMemoryCache.java?rev=1232163&r1=1232162&r2=1232163&view=diff
==============================================================================
--- commons/proper/jcs/branches/generics-interface/src/java/org/apache/jcs/engine/memory/lru/LRUMemoryCache.java (original)
+++ commons/proper/jcs/branches/generics-interface/src/java/org/apache/jcs/engine/memory/lru/LRUMemoryCache.java Mon Jan 16 21:05:44 2012
@@ -20,6 +20,7 @@ package org.apache.jcs.engine.memory.lru
  */
 
 import java.io.IOException;
+import java.io.Serializable;
 
 import org.apache.jcs.engine.behavior.ICacheElement;
 import org.apache.jcs.engine.memory.AbstractDoulbeLinkedListMemoryCache;
@@ -36,8 +37,8 @@ import org.apache.jcs.engine.memory.util
  * 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
-    extends AbstractDoulbeLinkedListMemoryCache
+public class LRUMemoryCache<K extends Serializable, V extends Serializable>
+    extends AbstractDoulbeLinkedListMemoryCache<K, V>
 {
     /** Don't change */
     private static final long serialVersionUID = 6403738094136424201L;
@@ -50,7 +51,7 @@ public class LRUMemoryCache
      * @return MemoryElementDescriptor the new node
      * @exception IOException
      */
-    protected MemoryElementDescriptor adjustListForUpdate( ICacheElement ce )
+    protected MemoryElementDescriptor<K, V> adjustListForUpdate( ICacheElement<K, V> ce )
         throws IOException
     {
         return addFirst( ce );
@@ -61,7 +62,7 @@ public class LRUMemoryCache
      * <p>
      * @param me
      */
-    protected void adjustListForGet( MemoryElementDescriptor me )
+    protected void adjustListForGet( MemoryElementDescriptor<K, V> me )
     {
         list.makeFirst( me );
     }

Modified: commons/proper/jcs/branches/generics-interface/src/java/org/apache/jcs/engine/memory/mru/MRUMemoryCache.java
URL: http://svn.apache.org/viewvc/commons/proper/jcs/branches/generics-interface/src/java/org/apache/jcs/engine/memory/mru/MRUMemoryCache.java?rev=1232163&r1=1232162&r2=1232163&view=diff
==============================================================================
--- commons/proper/jcs/branches/generics-interface/src/java/org/apache/jcs/engine/memory/mru/MRUMemoryCache.java (original)
+++ commons/proper/jcs/branches/generics-interface/src/java/org/apache/jcs/engine/memory/mru/MRUMemoryCache.java Mon Jan 16 21:05:44 2012
@@ -20,6 +20,7 @@ package org.apache.jcs.engine.memory.mru
  */
 
 import java.io.IOException;
+import java.io.Serializable;
 
 import org.apache.jcs.engine.behavior.ICacheElement;
 import org.apache.jcs.engine.memory.AbstractDoulbeLinkedListMemoryCache;
@@ -29,8 +30,8 @@ import org.apache.jcs.engine.memory.util
  * The most recently used items move to the front of the list and get spooled to disk if the cache
  * hub is configured to use a disk cache.
  */
-public class MRUMemoryCache
-    extends AbstractDoulbeLinkedListMemoryCache
+public class MRUMemoryCache<K extends Serializable, V extends Serializable>
+    extends AbstractDoulbeLinkedListMemoryCache<K, V>
 {
     /** Don't change */
     private static final long serialVersionUID = 5013101678192336129L;
@@ -45,7 +46,7 @@ public class MRUMemoryCache
      * @return MemoryElementDescriptor the new node
      * @exception IOException
      */
-    protected MemoryElementDescriptor adjustListForUpdate( ICacheElement ce )
+    protected MemoryElementDescriptor<K, V> adjustListForUpdate( ICacheElement<K, V> ce )
         throws IOException
     {
         return addFirst( ce );
@@ -56,7 +57,7 @@ public class MRUMemoryCache
      * <p>
      * @param me
      */
-    protected void adjustListForGet( MemoryElementDescriptor me )
+    protected void adjustListForGet( MemoryElementDescriptor<K, V> me )
     {
         list.makeLast( me );
     }

Modified: commons/proper/jcs/branches/generics-interface/src/java/org/apache/jcs/engine/memory/shrinking/ShrinkerThread.java
URL: http://svn.apache.org/viewvc/commons/proper/jcs/branches/generics-interface/src/java/org/apache/jcs/engine/memory/shrinking/ShrinkerThread.java?rev=1232163&r1=1232162&r2=1232163&view=diff
==============================================================================
--- commons/proper/jcs/branches/generics-interface/src/java/org/apache/jcs/engine/memory/shrinking/ShrinkerThread.java (original)
+++ commons/proper/jcs/branches/generics-interface/src/java/org/apache/jcs/engine/memory/shrinking/ShrinkerThread.java Mon Jan 16 21:05:44 2012
@@ -38,14 +38,14 @@ import org.apache.jcs.engine.memory.Memo
  * acting directly on an iterator of the underlying memory cache should have been solved.
  * @version $Id$
  */
-public class ShrinkerThread
+public class ShrinkerThread<K extends Serializable, V extends Serializable>
     implements Runnable
 {
     /** The logger */
     private final static Log log = LogFactory.getLog( ShrinkerThread.class );
 
     /** The MemoryCache instance which this shrinker is watching */
-    private final MemoryCache cache;
+    private final MemoryCache<K, V> cache;
 
     /** Maximum memory idle time for the whole cache */
     private final long maxMemoryIdleTime;
@@ -61,7 +61,7 @@ public class ShrinkerThread
      * <p>
      * @param cache The MemoryCache which the new shrinker should watch.
      */
-    public ShrinkerThread( MemoryCache cache )
+    public ShrinkerThread( MemoryCache<K, V> cache )
     {
         super();
 
@@ -95,7 +95,7 @@ public class ShrinkerThread
     }
 
     /**
-     * This method is called when the thread wakes up. Frist the method obtains an array of keys for
+     * This method is called when the thread wakes up. First the method obtains an array of keys for
      * the cache region. It iterates through the keys and tries to get the item from the cache
      * without affecting the last access or position of the item. The item is checked for
      * expiration, the expiration check has 3 parts:
@@ -103,7 +103,7 @@ public class ShrinkerThread
      * <li>Has the cacheattributes.MaxMemoryIdleTimeSeconds defined for the region been exceeded? If
      * so, the item should be move to disk.</li> <li>Has the item exceeded MaxLifeSeconds defined in
      * the element attributes? If so, remove it.</li> <li>Has the item exceeded IdleTime defined in
-     * the element atributes? If so, remove it. If there are event listeners registered for the
+     * the element attributes? If so, remove it. If there are event listeners registered for the
      * cache element, they will be called.</li>
      * </ol>
      * @todo Change element event handling to use the queue, then move the queue to the region and
@@ -121,22 +121,22 @@ public class ShrinkerThread
 
         try
         {
-            Object[] keys = cache.getKeyArray();
+            K[] keys = cache.getKeyArray();
             int size = keys.length;
             if ( log.isDebugEnabled() )
             {
                 log.debug( "Keys size: " + size );
             }
 
-            Serializable key;
-            ICacheElement cacheElement;
+            K key;
+            ICacheElement<K, V> cacheElement;
             IElementAttributes attributes;
 
             int spoolCount = 0;
 
             for ( int i = 0; i < size; i++ )
             {
-                key = (Serializable) keys[i];
+                key = keys[i];
                 cacheElement = cache.getQuiet( key );
 
                 if ( cacheElement == null )
@@ -233,7 +233,7 @@ public class ShrinkerThread
      * @return true if the element should be removed, or false.
      * @throws IOException
      */
-    protected boolean checkForRemoval( ICacheElement cacheElement, long now )
+    protected boolean checkForRemoval( ICacheElement<?, ?> cacheElement, long now )
         throws IOException
     {
         IElementAttributes attributes = cacheElement.getElementAttributes();
@@ -280,7 +280,7 @@ public class ShrinkerThread
      * @param eventType Type of event to handle
      * @throws IOException If an error occurs
      */
-    private void handleElementEvents( ICacheElement cacheElement, int eventType )
+    private void handleElementEvents( ICacheElement<?, ?> cacheElement, int eventType )
         throws IOException
     {
         IElementAttributes attributes = cacheElement.getElementAttributes();

Modified: commons/proper/jcs/branches/generics-interface/src/java/org/apache/jcs/engine/memory/util/MemoryElementDescriptor.java
URL: http://svn.apache.org/viewvc/commons/proper/jcs/branches/generics-interface/src/java/org/apache/jcs/engine/memory/util/MemoryElementDescriptor.java?rev=1232163&r1=1232162&r2=1232163&view=diff
==============================================================================
--- commons/proper/jcs/branches/generics-interface/src/java/org/apache/jcs/engine/memory/util/MemoryElementDescriptor.java (original)
+++ commons/proper/jcs/branches/generics-interface/src/java/org/apache/jcs/engine/memory/util/MemoryElementDescriptor.java Mon Jan 16 21:05:44 2012
@@ -19,27 +19,29 @@ package org.apache.jcs.engine.memory.uti
  * under the License.
  */
 
+import java.io.Serializable;
+
 import org.apache.jcs.engine.behavior.ICacheElement;
 import org.apache.jcs.utils.struct.DoubleLinkedListNode;
 
 /**
  * This wrapper is needed for double linked lists.
  */
-public class MemoryElementDescriptor
-    extends DoubleLinkedListNode<ICacheElement>
+public class MemoryElementDescriptor<K extends Serializable, V extends Serializable>
+    extends DoubleLinkedListNode<ICacheElement<K, V>>
 {
     /** Don't change */
     private static final long serialVersionUID = -1905161209035522460L;
 
     /** The CacheElement wrapped by this descriptor */
-    public ICacheElement ce;
+    public ICacheElement<K, V> ce;
 
     /**
      * Constructs a usable MemoryElementDescriptor.
      * <p>
      * @param ce
      */
-    public MemoryElementDescriptor( ICacheElement ce )
+    public MemoryElementDescriptor( ICacheElement<K, V> ce )
     {
         super( ce );
         this.ce = ce;

Modified: commons/proper/jcs/branches/generics-interface/src/java/org/apache/jcs/utils/access/JCSWorker.java
URL: http://svn.apache.org/viewvc/commons/proper/jcs/branches/generics-interface/src/java/org/apache/jcs/utils/access/JCSWorker.java?rev=1232163&r1=1232162&r2=1232163&view=diff
==============================================================================
--- commons/proper/jcs/branches/generics-interface/src/java/org/apache/jcs/utils/access/JCSWorker.java (original)
+++ commons/proper/jcs/branches/generics-interface/src/java/org/apache/jcs/utils/access/JCSWorker.java Mon Jan 16 21:05:44 2012
@@ -35,9 +35,9 @@ import org.apache.jcs.access.exception.C
  * org.apache.jcs.utils.access.AbstractJCSWorkerHelper and implement Object
  * doWork() and do the work in there, returning the object to be cached. Then
  * call .getResult() with the key and the AbstractJCSWorkerHelper to get the
- * result of the work. If the object isn't allready in the Cache,
+ * result of the work. If the object isn't already in the Cache,
  * AbstractJCSWorkerHelper.doWork() will get called, and the result will be put
- * into the cache. If the object is allready in cache, the cached result will be
+ * into the cache. If the object is already in cache, the cached result will be
  * returned instead.
  * <p>
  * As an added bonus, multiple JCSWorkers with the same region, and key won't do
@@ -90,13 +90,13 @@ import org.apache.jcs.access.exception.C
  * <p>
  * @author Travis Savo
  */
-public class JCSWorker
+public class JCSWorker<K extends Serializable, V extends Serializable>
 {
     /** The logger */
     private static final Log logger = LogFactory.getLog( JCSWorker.class );
 
     /** The cache we are working with */
-    private JCS cache;
+    private JCS<K, V> cache;
 
     /**
      * Map to hold who's doing work presently.
@@ -139,7 +139,7 @@ public class JCSWorker
      * Gets the cached result for this region/key OR does the work and caches
      * the result, returning the result. If the result has not been cached yet,
      * this calls doWork() on the JCSWorkerHelper to do the work and cache the
-     * result. This is also an opertunity to do any post processing of the
+     * result. This is also an opportunity to do any post processing of the
      * result in your CachedWorker implementation.
      * @param aKey
      *            The key to get/put with on the Cache.
@@ -152,7 +152,7 @@ public class JCSWorker
      *             Throws an exception if anything goes wrong while doing the
      *             work.
      */
-    public Object getResult( Serializable aKey, JCSWorkerHelper aWorker )
+    public V getResult( K aKey, JCSWorkerHelper aWorker )
         throws Exception
     {
         return run( aKey, null, aWorker );
@@ -177,7 +177,7 @@ public class JCSWorker
      *             Throws an exception if anything goes wrong while doing the
      *             work.
      */
-    public Object getResult( Serializable aKey, String aGroup, JCSWorkerHelper aWorker )
+    public V getResult( K aKey, String aGroup, JCSWorkerHelper aWorker )
         throws Exception
     {
         return run( aKey, aGroup, aWorker );
@@ -197,17 +197,17 @@ public class JCSWorker
      *             If something goes wrong while doing the work, throw an
      *             exception.
      */
-    private Object run( Serializable aKey, String aGroup, JCSWorkerHelper aHelper )
+    private V run( K aKey, String aGroup, JCSWorkerHelper aHelper )
         throws Exception
     {
-        Serializable result = null;
+        V result = null;
         // long start = 0;
         // long dbTime = 0;
         JCSWorkerHelper helper = null;
 
         synchronized ( map )
         {
-            // Check to see if we allready have a thread doing this work.
+            // Check to see if we already have a thread doing this work.
             helper = map.get( getRegion() + aKey );
             if ( helper == null )
             {
@@ -255,7 +255,7 @@ public class JCSWorker
             // If the cache dosn't have it, do the work.
             if ( result == null )
             {
-                result = (Serializable)aHelper.doWork();
+                result = (V)aHelper.doWork();
                 if ( logger.isDebugEnabled() )
                 {
                     logger.debug( "Work Done, caching: key:" + aKey + ", group:" + aGroup + ", result:" + result + "." );

Modified: commons/proper/jcs/branches/generics-interface/src/java/org/apache/jcs/utils/serialization/CompressingSerializer.java
URL: http://svn.apache.org/viewvc/commons/proper/jcs/branches/generics-interface/src/java/org/apache/jcs/utils/serialization/CompressingSerializer.java?rev=1232163&r1=1232162&r2=1232163&view=diff
==============================================================================
--- commons/proper/jcs/branches/generics-interface/src/java/org/apache/jcs/utils/serialization/CompressingSerializer.java (original)
+++ commons/proper/jcs/branches/generics-interface/src/java/org/apache/jcs/utils/serialization/CompressingSerializer.java Mon Jan 16 21:05:44 2012
@@ -37,13 +37,13 @@ public class CompressingSerializer
     implements IElementSerializer
 {
     /**
-     * Serializes an object using default serilaization. Compresses the byte array.
+     * Serializes an object using default serialization. Compresses the byte array.
      * <p>
      * @param obj object
      * @return byte[]
      * @throws IOException on i/o problem
      */
-    public byte[] serialize( Serializable obj )
+    public <T extends Serializable> byte[] serialize( T obj )
         throws IOException
     {
         byte[] uncompressed = serializeObject( obj );
@@ -58,7 +58,7 @@ public class CompressingSerializer
      * @return byte[]
      * @throws IOException on i/o problem
      */
-    protected byte[] serializeObject( Serializable obj )
+    protected <T extends Serializable> byte[] serializeObject( T obj )
         throws IOException
     {
         ByteArrayOutputStream baos = new ByteArrayOutputStream();
@@ -84,7 +84,7 @@ public class CompressingSerializer
      * @throws IOException on i/o problem
      * @throws ClassNotFoundException if class is not found during deserialization
      */
-    public Object deSerialize( byte[] data )
+    public <T extends Serializable> T deSerialize( byte[] data )
         throws IOException, ClassNotFoundException
     {
         if ( data == null )
@@ -103,7 +103,7 @@ public class CompressingSerializer
      * @throws IOException on i/o error
      * @throws ClassNotFoundException if class is not found during deserialization
      */
-    protected Object deserializeObject( byte[] decompressedByteArray )
+    protected <T extends Serializable> T deserializeObject( byte[] decompressedByteArray )
         throws IOException, ClassNotFoundException
     {
         ByteArrayInputStream bais = new ByteArrayInputStream( decompressedByteArray );
@@ -114,7 +114,7 @@ public class CompressingSerializer
         {
             try
             {
-                return ois.readObject();
+                return (T) ois.readObject();
             }
             catch ( IOException e )
             {

Modified: commons/proper/jcs/branches/generics-interface/src/java/org/apache/jcs/utils/serialization/SerializationConversionUtil.java
URL: http://svn.apache.org/viewvc/commons/proper/jcs/branches/generics-interface/src/java/org/apache/jcs/utils/serialization/SerializationConversionUtil.java?rev=1232163&r1=1232162&r2=1232163&view=diff
==============================================================================
--- commons/proper/jcs/branches/generics-interface/src/java/org/apache/jcs/utils/serialization/SerializationConversionUtil.java (original)
+++ commons/proper/jcs/branches/generics-interface/src/java/org/apache/jcs/utils/serialization/SerializationConversionUtil.java Mon Jan 16 21:05:44 2012
@@ -20,6 +20,7 @@ package org.apache.jcs.utils.serializati
  */
 
 import java.io.IOException;
+import java.io.Serializable;
 
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
@@ -49,7 +50,7 @@ public class SerializationConversionUtil
      * @return null for null;
      * @throws IOException
      */
-    public static ICacheElementSerialized getSerializedCacheElement( ICacheElement element,
+    public static <K extends Serializable, V extends Serializable> ICacheElementSerialized<K, V> getSerializedCacheElement( ICacheElement<K, V> element,
                                                                     IElementSerializer elementSerializer )
         throws IOException
     {
@@ -58,12 +59,12 @@ public class SerializationConversionUtil
             return null;
         }
 
-        byte[] serialzedValue = null;
+        byte[] serializedValue = null;
 
         // if it has already been serialized, don't do it again.
         if ( element instanceof ICacheElementSerialized )
         {
-            serialzedValue = ( (ICacheElementSerialized) element ).getSerializedValue();
+            serializedValue = ( (ICacheElementSerialized<K, V>) element ).getSerializedValue();
         }
         else
         {
@@ -71,7 +72,7 @@ public class SerializationConversionUtil
             {
                 try
                 {
-                    serialzedValue = elementSerializer.serialize( element.getVal() );
+                    serializedValue = elementSerializer.serialize( element.getVal() );
                 }
                 catch ( IOException e )
                 {
@@ -86,8 +87,8 @@ public class SerializationConversionUtil
                 throw new IOException( "Could not serialize object.  The ElementSerializer is null." );
             }
         }
-        ICacheElementSerialized serialized = new CacheElementSerialized( element.getCacheName(), element.getKey(),
-                                                                         serialzedValue, element.getElementAttributes() );
+        ICacheElementSerialized<K, V> serialized = new CacheElementSerialized<K, V>(
+                element.getCacheName(), element.getKey(), serializedValue, element.getElementAttributes() );
 
         return serialized;
     }
@@ -103,7 +104,7 @@ public class SerializationConversionUtil
      * @throws IOException
      * @throws ClassNotFoundException
      */
-    public static ICacheElement getDeSerializedCacheElement( ICacheElementSerialized serialized,
+    public static <K extends Serializable, V extends Serializable> ICacheElement<K, V> getDeSerializedCacheElement( ICacheElementSerialized<K, V> serialized,
                                                             IElementSerializer elementSerializer )
         throws IOException, ClassNotFoundException
     {
@@ -112,7 +113,7 @@ public class SerializationConversionUtil
             return null;
         }
 
-        Object deSerialzedValue = null;
+        V deSerializedValue = null;
 
         if ( elementSerializer != null )
         {
@@ -120,7 +121,7 @@ public class SerializationConversionUtil
             {
                 try
                 {
-                    deSerialzedValue = elementSerializer.deSerialize( serialized.getSerializedValue() );
+                    deSerializedValue = elementSerializer.deSerialize( serialized.getSerializedValue() );
                 }
                 catch ( ClassNotFoundException e )
                 {
@@ -139,7 +140,7 @@ public class SerializationConversionUtil
             // we could just use the default.
             log.warn( "ElementSerializer is null.  Could not serialize object." );
         }
-        ICacheElement deSerialized = new CacheElement( serialized.getCacheName(), serialized.getKey(), deSerialzedValue );
+        ICacheElement<K, V> deSerialized = new CacheElement<K, V>( serialized.getCacheName(), serialized.getKey(), deSerializedValue );
         deSerialized.setElementAttributes( serialized.getElementAttributes() );
 
         return deSerialized;

Modified: commons/proper/jcs/branches/generics-interface/src/java/org/apache/jcs/utils/serialization/StandardSerializer.java
URL: http://svn.apache.org/viewvc/commons/proper/jcs/branches/generics-interface/src/java/org/apache/jcs/utils/serialization/StandardSerializer.java?rev=1232163&r1=1232162&r2=1232163&view=diff
==============================================================================
--- commons/proper/jcs/branches/generics-interface/src/java/org/apache/jcs/utils/serialization/StandardSerializer.java (original)
+++ commons/proper/jcs/branches/generics-interface/src/java/org/apache/jcs/utils/serialization/StandardSerializer.java Mon Jan 16 21:05:44 2012
@@ -40,14 +40,14 @@ public class StandardSerializer
     /**
      * Serializes an object using default serialization.
      * <p>
-     * @param obj 
+     * @param obj
      * @return byte[]
-     * @throws IOException 
+     * @throws IOException
      */
-    public byte[] serialize( Serializable obj )
+    public <T extends Serializable> byte[] serialize( T obj )
         throws IOException
     {
-        ByteArrayOutputStream baos = new ByteArrayOutputStream();        
+        ByteArrayOutputStream baos = new ByteArrayOutputStream();
         ObjectOutputStream oos = new ObjectOutputStream( baos );
         try
         {
@@ -69,7 +69,7 @@ public class StandardSerializer
      * @throws IOException
      * @throws ClassNotFoundException
      */
-    public Object deSerialize( byte[] data )
+    public <T extends Serializable> T deSerialize( byte[] data )
         throws IOException, ClassNotFoundException
     {
         ByteArrayInputStream bais = new ByteArrayInputStream( data );
@@ -79,7 +79,7 @@ public class StandardSerializer
         {
             try
             {
-                return ois.readObject();
+                return (T) ois.readObject();
             }
             catch ( IOException e )
             {

Modified: commons/proper/jcs/branches/generics-interface/src/test/org/apache/jcs/JCSCacheElementRetrievalUnitTest.java
URL: http://svn.apache.org/viewvc/commons/proper/jcs/branches/generics-interface/src/test/org/apache/jcs/JCSCacheElementRetrievalUnitTest.java?rev=1232163&r1=1232162&r2=1232163&view=diff
==============================================================================
--- commons/proper/jcs/branches/generics-interface/src/test/org/apache/jcs/JCSCacheElementRetrievalUnitTest.java (original)
+++ commons/proper/jcs/branches/generics-interface/src/test/org/apache/jcs/JCSCacheElementRetrievalUnitTest.java Mon Jan 16 21:05:44 2012
@@ -43,7 +43,7 @@ public class JCSCacheElementRetrievalUni
         jcs.put( "test_key", "test_data" );
 
         long now = System.currentTimeMillis();
-        ICacheElement elem = jcs.getCacheElement( "test_key" );
+        ICacheElement<String, String> elem = jcs.getCacheElement( "test_key" );
         assertEquals( "Name wasn't right", "testCache1", elem.getCacheName() );
 
         long diff = now - elem.getElementAttributes().getCreateTime();

Modified: commons/proper/jcs/branches/generics-interface/src/test/org/apache/jcs/access/CacheAccessUnitTest.java
URL: http://svn.apache.org/viewvc/commons/proper/jcs/branches/generics-interface/src/test/org/apache/jcs/access/CacheAccessUnitTest.java?rev=1232163&r1=1232162&r2=1232163&view=diff
==============================================================================
--- commons/proper/jcs/branches/generics-interface/src/test/org/apache/jcs/access/CacheAccessUnitTest.java (original)
+++ commons/proper/jcs/branches/generics-interface/src/test/org/apache/jcs/access/CacheAccessUnitTest.java Mon Jan 16 21:05:44 2012
@@ -147,7 +147,7 @@ public class CacheAccessUnitTest
 
         access.put( key, value );
 
-        ICacheElement element = access.getCacheElement( key );
+        ICacheElement<String, String> element = access.getCacheElement( key );
 
         assertEquals( "Wrong max life.  Should have the new value.", maxLife, element.getElementAttributes()
             .getMaxLifeSeconds() );
@@ -184,10 +184,10 @@ public class CacheAccessUnitTest
 
         //VERIFY
         assertEquals( "map size", 2, result.size() );
-        ICacheElement elementOne = (ICacheElement) result.get( keyOne );
+        ICacheElement<String, String> elementOne = (ICacheElement) result.get( keyOne );
         assertEquals( "value one", keyOne, elementOne.getKey() );
         assertEquals( "value one", valueOne, elementOne.getVal() );
-        ICacheElement elementTwo = (ICacheElement) result.get( keyTwo );
+        ICacheElement<String, String> elementTwo = (ICacheElement) result.get( keyTwo );
         assertEquals( "value two", keyTwo, elementTwo.getKey() );
         assertEquals( "value two", valueTwo, elementTwo.getVal() );
     }
@@ -291,7 +291,7 @@ public class CacheAccessUnitTest
         assertEquals( "Wrong number returned 1:", numToInsertPrefix1, result1.size() );
         assertEquals( "Wrong number returned 2:", numToInsertPrefix2, result2.size() );
         //System.out.println( result1 );
-        
+
         // verify that the elements are unwrapped
         Set keySet1 = result1.keySet();
         Iterator it1 = keySet1.iterator();
@@ -302,7 +302,7 @@ public class CacheAccessUnitTest
             assertFalse( "Should not be a cache element.", value instanceof ICacheElement );
         }
     }
-    
+
     /**
      * Verify we can get some matching elements..
      * <p>
@@ -348,7 +348,7 @@ public class CacheAccessUnitTest
         assertEquals( "Wrong number returned 1:", numToInsertPrefix1, result1.size() );
         assertEquals( "Wrong number returned 2:", numToInsertPrefix2, result2.size() );
         //System.out.println( result1 );
-        
+
         // verify that the elements are wrapped
         Set keySet1 = result1.keySet();
         Iterator it1 = keySet1.iterator();
@@ -357,6 +357,6 @@ public class CacheAccessUnitTest
             Object key = it1.next();
             Object value = result1.get( key );
             assertTrue( "Should be a cache element.", value instanceof ICacheElement );
-        }        
+        }
     }
 }

Modified: commons/proper/jcs/branches/generics-interface/src/test/org/apache/jcs/auxiliary/MockAuxiliaryCache.java
URL: http://svn.apache.org/viewvc/commons/proper/jcs/branches/generics-interface/src/test/org/apache/jcs/auxiliary/MockAuxiliaryCache.java?rev=1232163&r1=1232162&r2=1232163&view=diff
==============================================================================
--- commons/proper/jcs/branches/generics-interface/src/test/org/apache/jcs/auxiliary/MockAuxiliaryCache.java (original)
+++ commons/proper/jcs/branches/generics-interface/src/test/org/apache/jcs/auxiliary/MockAuxiliaryCache.java Mon Jan 16 21:05:44 2012
@@ -35,8 +35,8 @@ import org.apache.jcs.engine.stats.behav
  * <p>
  * @author Aaron Smuts
  */
-public class MockAuxiliaryCache
-    extends AbstractAuxiliaryCache
+public class MockAuxiliaryCache<K extends Serializable, V extends Serializable>
+    extends AbstractAuxiliaryCache<K, V>
 {
     /** Don't change */
     private static final long serialVersionUID = 1L;
@@ -54,7 +54,7 @@ public class MockAuxiliaryCache
      * @param ce
      * @throws IOException
      */
-    public void update( ICacheElement ce )
+    public void update( ICacheElement<K, V> ce )
         throws IOException
     {
         // TODO Auto-generated method stub
@@ -66,7 +66,7 @@ public class MockAuxiliaryCache
      * @return ICacheElement
      * @throws IOException
      */
-    public ICacheElement get( Serializable key )
+    public ICacheElement<K, V> get( K key )
         throws IOException
     {
         // TODO Auto-generated method stub
@@ -78,23 +78,23 @@ public class MockAuxiliaryCache
      * @return Map
      * @throws IOException
      */
-    public Map<Serializable, ICacheElement> getMatching(String pattern)
+    public Map<K, ICacheElement<K, V>> getMatching(String pattern)
         throws IOException
     {
         getMatchingCallCount++;
-        return new HashMap<Serializable, ICacheElement>();
+        return new HashMap<K, ICacheElement<K, V>>();
     }
 
     /**
      * 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<String, String> element, or an empty map if there is no
      *         data in cache for any of these keys
      */
-    public Map<Serializable, ICacheElement> getMultiple(Set<Serializable> keys)
+    public Map<K, ICacheElement<K, V>> getMultiple(Set<K> keys)
     {
-        return new HashMap<Serializable, ICacheElement>();
+        return new HashMap<K, ICacheElement<K, V>>();
     }
 
     /**
@@ -102,7 +102,7 @@ public class MockAuxiliaryCache
      * @return boolean
      * @throws IOException
      */
-    public boolean remove( Serializable key )
+    public boolean remove( K key )
         throws IOException
     {
         // TODO Auto-generated method stub
@@ -159,7 +159,7 @@ public class MockAuxiliaryCache
      * @return null
      * @throws IOException
      */
-    public Set<Serializable> getGroupKeys( String group )
+    public Set<K> getGroupKeys( String group )
         throws IOException
     {
         return null;

Modified: commons/proper/jcs/branches/generics-interface/src/test/org/apache/jcs/auxiliary/MockCacheEventLogger.java
URL: http://svn.apache.org/viewvc/commons/proper/jcs/branches/generics-interface/src/test/org/apache/jcs/auxiliary/MockCacheEventLogger.java?rev=1232163&r1=1232162&r2=1232163&view=diff
==============================================================================
--- commons/proper/jcs/branches/generics-interface/src/test/org/apache/jcs/auxiliary/MockCacheEventLogger.java (original)
+++ commons/proper/jcs/branches/generics-interface/src/test/org/apache/jcs/auxiliary/MockCacheEventLogger.java Mon Jan 16 21:05:44 2012
@@ -4,7 +4,6 @@ import java.io.Serializable;
 import java.util.ArrayList;
 import java.util.List;
 
-import org.apache.jcs.engine.behavior.ICacheElement;
 import org.apache.jcs.engine.logging.CacheEvent;
 import org.apache.jcs.engine.logging.behavior.ICacheEvent;
 import org.apache.jcs.engine.logging.behavior.ICacheEventLogger;
@@ -44,7 +43,7 @@ public class MockCacheEventLogger
     /**
      * @param cacheEvent
      */
-    public void logICacheEvent( ICacheEvent cacheEvent )
+    public <T extends Serializable> void logICacheEvent( ICacheEvent<T> event )
     {
         endICacheEventCalls++;
     }
@@ -68,25 +67,10 @@ public class MockCacheEventLogger
      * @param key
      * @return ICacheEvent
      */
-    public ICacheEvent createICacheEvent( String source, String region, String eventName, String optionalDetails,
-                                          Serializable key )
+    public <T extends Serializable> ICacheEvent<T> createICacheEvent( String source, String region,
+            String eventName, String optionalDetails, T key )
     {
         startICacheEventCalls++;
-        return new CacheEvent();
-    }
-
-    /**
-     * @param source
-     * @param region
-     * @param eventName
-     * @param optionalDetails
-     * @param item
-     * @return ICacheEvent
-     */
-    public ICacheEvent createICacheEvent( String source, String region, String eventName, String optionalDetails,
-                                          ICacheElement item )
-    {
-        startICacheEventCalls++;
-        return new CacheEvent();
+        return new CacheEvent<T>();
     }
 }

Modified: commons/proper/jcs/branches/generics-interface/src/test/org/apache/jcs/auxiliary/disk/AbstractDiskCacheUnitTest.java
URL: http://svn.apache.org/viewvc/commons/proper/jcs/branches/generics-interface/src/test/org/apache/jcs/auxiliary/disk/AbstractDiskCacheUnitTest.java?rev=1232163&r1=1232162&r2=1232163&view=diff
==============================================================================
--- commons/proper/jcs/branches/generics-interface/src/test/org/apache/jcs/auxiliary/disk/AbstractDiskCacheUnitTest.java (original)
+++ commons/proper/jcs/branches/generics-interface/src/test/org/apache/jcs/auxiliary/disk/AbstractDiskCacheUnitTest.java Mon Jan 16 21:05:44 2012
@@ -37,17 +37,17 @@ public class AbstractDiskCacheUnitTest
         IDiskCacheAttributes diskCacheAttributes = new IndexedDiskCacheAttributes();
         diskCacheAttributes.setCacheName( cacheName );
 
-        AbstractDiskCacheTestInstance diskCache = new AbstractDiskCacheTestInstance( diskCacheAttributes );
+        AbstractDiskCacheTestInstance<String, String> diskCache = new AbstractDiskCacheTestInstance<String, String>( diskCacheAttributes );
 
         String key = "myKey";
         String value = "myValue";
         IElementAttributes elementAttributes = new ElementAttributes();
-        ICacheElement cacheElement = new CacheElement( cacheName, key, value, elementAttributes );
+        ICacheElement<String, String> cacheElement = new CacheElement<String, String>( cacheName, key, value, elementAttributes );
 
         diskCache.update( cacheElement );
 
         // DO WORK
-        ICacheElement result = diskCache.get( key );
+        ICacheElement<String, String> result = diskCache.get( key );
 
         // VERIFY
         //System.out.println( diskCache.getStats() );
@@ -67,12 +67,12 @@ public class AbstractDiskCacheUnitTest
         IDiskCacheAttributes diskCacheAttributes = new IndexedDiskCacheAttributes();
         diskCacheAttributes.setCacheName( cacheName );
 
-        AbstractDiskCacheTestInstance diskCache = new AbstractDiskCacheTestInstance( diskCacheAttributes );
+        AbstractDiskCacheTestInstance<String, String> diskCache = new AbstractDiskCacheTestInstance<String, String>( diskCacheAttributes );
 
         String key = "myKey";
         String value = "myValue";
         IElementAttributes elementAttributes = new ElementAttributes();
-        ICacheElement cacheElement = new CacheElement( cacheName, key, value, elementAttributes );
+        ICacheElement<String, String> cacheElement = new CacheElement<String, String>( cacheName, key, value, elementAttributes );
 
         diskCache.update( cacheElement );
 
@@ -99,13 +99,13 @@ public class AbstractDiskCacheUnitTest
         IDiskCacheAttributes diskCacheAttributes = new IndexedDiskCacheAttributes();
         diskCacheAttributes.setAllowRemoveAll( false );
 
-        AbstractDiskCacheTestInstance diskCache = new AbstractDiskCacheTestInstance( diskCacheAttributes );
+        AbstractDiskCacheTestInstance<String, String> diskCache = new AbstractDiskCacheTestInstance<String, String>( diskCacheAttributes );
 
         String cacheName = "testRemoveAll_notAllowed";
         String key = "myKey";
         String value = "myValue";
         IElementAttributes elementAttributes = new ElementAttributes();
-        ICacheElement cacheElement = new CacheElement( cacheName, key, value, elementAttributes );
+        ICacheElement<String, String> cacheElement = new CacheElement<String, String>( cacheName, key, value, elementAttributes );
 
         diskCache.update( cacheElement );
 
@@ -130,13 +130,13 @@ public class AbstractDiskCacheUnitTest
         IDiskCacheAttributes diskCacheAttributes = new IndexedDiskCacheAttributes();
         diskCacheAttributes.setAllowRemoveAll( true );
 
-        AbstractDiskCacheTestInstance diskCache = new AbstractDiskCacheTestInstance( diskCacheAttributes );
+        AbstractDiskCacheTestInstance<String, String> diskCache = new AbstractDiskCacheTestInstance<String, String>( diskCacheAttributes );
 
         String cacheName = "testRemoveAll_allowed";
         String key = "myKey";
         String value = "myValue";
         IElementAttributes elementAttributes = new ElementAttributes();
-        ICacheElement cacheElement = new CacheElement( cacheName, key, value, elementAttributes );
+        ICacheElement<String, String> cacheElement = new CacheElement<String, String>( cacheName, key, value, elementAttributes );
 
         diskCache.update( cacheElement );
 
@@ -148,11 +148,11 @@ public class AbstractDiskCacheUnitTest
     }
 
     /** Concrete, testable instance. */
-    protected static class AbstractDiskCacheTestInstance
-        extends AbstractDiskCache
+    protected static class AbstractDiskCacheTestInstance<K extends Serializable, V extends Serializable>
+        extends AbstractDiskCache<K, V>
     {
         /** Internal map */
-        protected Map<Serializable, ICacheElement> map = new HashMap<Serializable, ICacheElement>();
+        protected Map<K, ICacheElement<K, V>> map = new HashMap<K, ICacheElement<K, V>>();
 
         /** used by the abstract aux class */
         protected IDiskCacheAttributes diskCacheAttributes;
@@ -188,7 +188,7 @@ public class AbstractDiskCacheUnitTest
          * @return Collections.EMPTY_SET
          */
         @Override
-        public Set<Serializable> getGroupKeys(String groupName)
+        public Set<K> getGroupKeys(String groupName)
         {
             return Collections.emptySet();
         }
@@ -218,7 +218,7 @@ public class AbstractDiskCacheUnitTest
          * @throws IOException
          */
         @Override
-        protected ICacheElement processGet( Serializable key )
+        protected ICacheElement<K, V> processGet( K key )
             throws IOException
         {
             //System.out.println( "processGet: " + key );
@@ -231,7 +231,7 @@ public class AbstractDiskCacheUnitTest
          * @throws IOException
          */
         @Override
-        protected Map<Serializable, ICacheElement> processGetMatching( String pattern )
+        protected Map<K, ICacheElement<K, V>> processGetMatching( String pattern )
             throws IOException
         {
             return Collections.emptyMap();
@@ -243,7 +243,7 @@ public class AbstractDiskCacheUnitTest
          * @throws IOException
          */
         @Override
-        protected boolean processRemove( Serializable key )
+        protected boolean processRemove( K key )
             throws IOException
         {
             return map.remove( key ) != null;
@@ -265,7 +265,7 @@ public class AbstractDiskCacheUnitTest
          * @throws IOException
          */
         @Override
-        protected void processUpdate( ICacheElement cacheElement )
+        protected void processUpdate( ICacheElement<K, V> cacheElement )
             throws IOException
         {
             //System.out.println( "processUpdate: " + cacheElement );

Modified: commons/proper/jcs/branches/generics-interface/src/test/org/apache/jcs/auxiliary/disk/PurgatoryElementUnitTest.java
URL: http://svn.apache.org/viewvc/commons/proper/jcs/branches/generics-interface/src/test/org/apache/jcs/auxiliary/disk/PurgatoryElementUnitTest.java?rev=1232163&r1=1232162&r2=1232163&view=diff
==============================================================================
--- commons/proper/jcs/branches/generics-interface/src/test/org/apache/jcs/auxiliary/disk/PurgatoryElementUnitTest.java (original)
+++ commons/proper/jcs/branches/generics-interface/src/test/org/apache/jcs/auxiliary/disk/PurgatoryElementUnitTest.java Mon Jan 16 21:05:44 2012
@@ -19,8 +19,8 @@ public class PurgatoryElementUnitTest
         String key = "myKey";
         String value = "myValue";
         IElementAttributes elementAttributes = new ElementAttributes();
-        ICacheElement cacheElement = new CacheElement( cacheName, key, value, elementAttributes );
-        PurgatoryElement purgatoryElement = new PurgatoryElement( cacheElement );
+        ICacheElement<String, String> cacheElement = new CacheElement<String, String>( cacheName, key, value, elementAttributes );
+        PurgatoryElement<String, String> purgatoryElement = new PurgatoryElement<String, String>( cacheElement );
         purgatoryElement.setSpoolable( false );
 
         // DO WORK
@@ -39,8 +39,8 @@ public class PurgatoryElementUnitTest
         String value = "myValue";
         IElementAttributes elementAttributes = new ElementAttributes();
 
-        ICacheElement cacheElement = new CacheElement( cacheName, key, value );
-        PurgatoryElement purgatoryElement = new PurgatoryElement( cacheElement );
+        ICacheElement<String, String> cacheElement = new CacheElement<String, String>( cacheName, key, value );
+        PurgatoryElement<String, String> purgatoryElement = new PurgatoryElement<String, String>( cacheElement );
         purgatoryElement.setElementAttributes( elementAttributes );
 
         // DO WORK
@@ -58,8 +58,8 @@ public class PurgatoryElementUnitTest
         String key = "myKey";
         String value = "myValue";
         IElementAttributes elementAttributes = new ElementAttributes();
-        ICacheElement cacheElement = new CacheElement( cacheName, key, value, elementAttributes );
-        PurgatoryElement purgatoryElement = new PurgatoryElement( cacheElement );
+        ICacheElement<String, String> cacheElement = new CacheElement<String, String>( cacheName, key, value, elementAttributes );
+        PurgatoryElement<String, String> purgatoryElement = new PurgatoryElement<String, String>( cacheElement );
 
         // DO WORK
         String result = purgatoryElement.toString();

Modified: commons/proper/jcs/branches/generics-interface/src/test/org/apache/jcs/auxiliary/disk/block/BlockDiskCacheConcurrentUnitTest.java
URL: http://svn.apache.org/viewvc/commons/proper/jcs/branches/generics-interface/src/test/org/apache/jcs/auxiliary/disk/block/BlockDiskCacheConcurrentUnitTest.java?rev=1232163&r1=1232162&r2=1232163&view=diff
==============================================================================
--- commons/proper/jcs/branches/generics-interface/src/test/org/apache/jcs/auxiliary/disk/block/BlockDiskCacheConcurrentUnitTest.java (original)
+++ commons/proper/jcs/branches/generics-interface/src/test/org/apache/jcs/auxiliary/disk/block/BlockDiskCacheConcurrentUnitTest.java Mon Jan 16 21:05:44 2012
@@ -142,7 +142,7 @@ public class BlockDiskCacheConcurrentUni
     public void runTestForRegion( String region )
         throws Exception
     {
-        JCS jcs = JCS.getInstance( region );
+        JCS<String, String> jcs = JCS.getInstance( region );
 
         // Add items to cache
         for ( int i = 0; i <= items; i++ )
@@ -153,22 +153,22 @@ public class BlockDiskCacheConcurrentUni
         // Test that all items are in cache
         for ( int i = 0; i <= items; i++ )
         {
-            String value = (String) jcs.get( i + ":key" );
+            String value = jcs.get( i + ":key" );
 
             assertEquals( region + " data " + i, value );
         }
 
         // Test that getElements returns all the expected values
-        Set keys = new HashSet();
+        Set<String> keys = new HashSet<String>();
         for ( int i = 0; i <= items; i++ )
         {
             keys.add( i + ":key" );
         }
 
-        Map elements = jcs.getCacheElements( keys );
+        Map<String, ICacheElement<String, String>> elements = jcs.getCacheElements( keys );
         for ( int i = 0; i <= items; i++ )
         {
-            ICacheElement element = (ICacheElement) elements.get( i + ":key" );
+            ICacheElement<String, String> element = elements.get( i + ":key" );
             assertNotNull( "element " + i + ":key is missing", element );
             assertEquals( "value " + i + ":key", region + " data " + i, element.getVal() );
         }
@@ -203,7 +203,7 @@ public class BlockDiskCacheConcurrentUni
     public void runTestForRegionInRange( String region, int start, int end )
         throws Exception
     {
-        JCS jcs = JCS.getInstance( region );
+        JCS<String, String> jcs = JCS.getInstance( region );
 
         // Add items to cache
         for ( int i = start; i <= end; i++ )
@@ -214,22 +214,22 @@ public class BlockDiskCacheConcurrentUni
         // Test that all items are in cache
         for ( int i = start; i <= end; i++ )
         {
-            String value = (String) jcs.get( i + ":key" );
+            String value = jcs.get( i + ":key" );
 
             assertEquals( region + " data " + i, value );
         }
 
         // Test that getElements returns all the expected values
-        Set keys = new HashSet();
+        Set<String> keys = new HashSet<String>();
         for ( int i = start; i <= end; i++ )
         {
             keys.add( i + ":key" );
         }
 
-        Map elements = jcs.getCacheElements( keys );
+        Map<String, ICacheElement<String, String>> elements = jcs.getCacheElements( keys );
         for ( int i = start; i <= end; i++ )
         {
-            ICacheElement element = (ICacheElement) elements.get( i + ":key" );
+            ICacheElement<String, String> element = elements.get( i + ":key" );
             assertNotNull( "element " + i + ":key is missing", element );
             assertEquals( "value " + i + ":key", region + " data " + i, element.getVal() );
         }

Modified: commons/proper/jcs/branches/generics-interface/src/test/org/apache/jcs/auxiliary/disk/block/BlockDiskCacheSameRegionConcurrentUnitTest.java
URL: http://svn.apache.org/viewvc/commons/proper/jcs/branches/generics-interface/src/test/org/apache/jcs/auxiliary/disk/block/BlockDiskCacheSameRegionConcurrentUnitTest.java?rev=1232163&r1=1232162&r2=1232163&view=diff
==============================================================================
--- commons/proper/jcs/branches/generics-interface/src/test/org/apache/jcs/auxiliary/disk/block/BlockDiskCacheSameRegionConcurrentUnitTest.java (original)
+++ commons/proper/jcs/branches/generics-interface/src/test/org/apache/jcs/auxiliary/disk/block/BlockDiskCacheSameRegionConcurrentUnitTest.java Mon Jan 16 21:05:44 2012
@@ -135,7 +135,7 @@ public class BlockDiskCacheSameRegionCon
     public void runTestForRegion( String region, int start, int end )
         throws Exception
     {
-        JCS jcs = JCS.getInstance( region );
+        JCS<String, String> jcs = JCS.getInstance( region );
 
         // Add items to cache
 
@@ -149,22 +149,22 @@ public class BlockDiskCacheSameRegionCon
         for ( int i = start; i <= end; i++ )
         {
             String key = i + ":key";
-            String value = (String) jcs.get( key );
+            String value = jcs.get( key );
 
             assertEquals( "Wrong value for key [" + key + "]", region + " data " + i + "-" + region, value );
         }
 
         // Test that getElements returns all the expected values
-        Set keys = new HashSet();
+        Set<String> keys = new HashSet<String>();
         for ( int i = start; i <= end; i++ )
         {
             keys.add( i + ":key" );
         }
 
-        Map elements = jcs.getCacheElements( keys );
+        Map<String, ICacheElement<String, String>> elements = jcs.getCacheElements( keys );
         for ( int i = start; i <= end; i++ )
         {
-            ICacheElement element = (ICacheElement) elements.get( i + ":key" );
+            ICacheElement<String, String> element = elements.get( i + ":key" );
             assertNotNull( "element " + i + ":key is missing", element );
             assertEquals( "value " + i + ":key", region + " data " + i + "-" + region, element.getVal() );
         }



Mime
View raw message