commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From t.@apache.org
Subject svn commit: r1344374 [8/14] - in /commons/proper/jcs/trunk: ./ auxiliary-builds/javagroups/src/java/org/apache/jcs/auxiliary/javagroups/ auxiliary-builds/jdk14/src/java/org/apache/jcs/auxiliary/javagroups/ auxiliary-builds/jdk14/src/java/org/apache/jcs...
Date Wed, 30 May 2012 18:14:51 GMT
Modified: commons/proper/jcs/trunk/src/java/org/apache/jcs/engine/control/CompositeCache.java
URL: http://svn.apache.org/viewvc/commons/proper/jcs/trunk/src/java/org/apache/jcs/engine/control/CompositeCache.java?rev=1344374&r1=1344373&r2=1344374&view=diff
==============================================================================
--- commons/proper/jcs/trunk/src/java/org/apache/jcs/engine/control/CompositeCache.java (original)
+++ commons/proper/jcs/trunk/src/java/org/apache/jcs/engine/control/CompositeCache.java Wed May 30 18:14:43 2012
@@ -34,7 +34,6 @@ import org.apache.jcs.access.exception.C
 import org.apache.jcs.access.exception.ObjectNotFoundException;
 import org.apache.jcs.auxiliary.AuxiliaryCache;
 import org.apache.jcs.engine.CacheConstants;
-import org.apache.jcs.engine.CacheElement;
 import org.apache.jcs.engine.behavior.ICache;
 import org.apache.jcs.engine.behavior.ICacheElement;
 import org.apache.jcs.engine.behavior.ICacheType;
@@ -49,7 +48,7 @@ import org.apache.jcs.engine.control.eve
 import org.apache.jcs.engine.control.group.GroupId;
 import org.apache.jcs.engine.match.KeyMatcherPatternImpl;
 import org.apache.jcs.engine.match.behavior.IKeyMatcher;
-import org.apache.jcs.engine.memory.MemoryCache;
+import org.apache.jcs.engine.memory.behavior.IMemoryCache;
 import org.apache.jcs.engine.memory.lru.LRUMemoryCache;
 import org.apache.jcs.engine.memory.util.MemoryElementDescriptor;
 import org.apache.jcs.engine.stats.CacheStats;
@@ -65,8 +64,8 @@ import org.apache.jcs.engine.stats.behav
  * <p>
  * This is the core of a JCS region. Hence, this simple class is the core of JCS.
  */
-public class CompositeCache
-    implements ICache, Serializable
+public class CompositeCache<K extends Serializable, V extends Serializable>
+    implements ICache<K, V>, Serializable
 {
     /** For serialization. Don't change. */
     private static final long serialVersionUID = -2838097410378294960L;
@@ -75,13 +74,13 @@ public class CompositeCache
     private final static Log log = LogFactory.getLog( CompositeCache.class );
 
     /**
-     * EventQueue for handling element events. Lazy initialized. One for each region. To be more eficient, the manager
+     * EventQueue for handling element events. Lazy initialized. One for each region. To be more efficient, the manager
      * should pass a shared queue in.
      */
     public IElementEventQueue elementEventQ;
 
     /** Auxiliary caches. */
-    private AuxiliaryCache[] auxCaches = new AuxiliaryCache[0];
+    private AuxiliaryCache<K, V>[] auxCaches = new AuxiliaryCache[0];
 
     /** is this alive? */
     private boolean alive = true;
@@ -120,10 +119,10 @@ public class CompositeCache
      * The cache hub can only have one memory cache. This could be made more flexible in the future,
      * but they are tied closely together. More than one doesn't make much sense.
      */
-    private MemoryCache memCache;
+    private IMemoryCache<K, V> memCache;
 
     /** Key matcher used by the getMatching API */
-    protected IKeyMatcher keyMatcher = new KeyMatcherPatternImpl();
+    protected IKeyMatcher<K> keyMatcher = new KeyMatcherPatternImpl<K>();
 
     /**
      * Constructor for the Cache object
@@ -151,7 +150,7 @@ public class CompositeCache
      * <p>
      * @param auxCaches
      */
-    public void setAuxCaches( AuxiliaryCache[] auxCaches )
+    public void setAuxCaches( AuxiliaryCache<K, V>[] auxCaches )
     {
         this.auxCaches = auxCaches;
 
@@ -167,7 +166,7 @@ public class CompositeCache
      * @param ce
      * @exception IOException
      */
-    public void update( ICacheElement ce )
+    public void update( ICacheElement<K, V> ce )
         throws IOException
     {
         update( ce, false );
@@ -179,7 +178,7 @@ public class CompositeCache
      * @param ce
      * @exception IOException
      */
-    public void localUpdate( ICacheElement ce )
+    public void localUpdate( ICacheElement<K, V> ce )
         throws IOException
     {
         update( ce, true );
@@ -189,11 +188,11 @@ public class CompositeCache
      * Put an item into the cache. If it is localOnly, then do no notify remote or lateral
      * auxiliaries.
      * <p>
-     * @param cacheElement the ICacheElement
+     * @param cacheElement the ICacheElement<K, V>
      * @param localOnly Whether the operation should be restricted to local auxiliaries.
      * @exception IOException
      */
-    protected void update( ICacheElement cacheElement, boolean localOnly )
+    protected void update( ICacheElement<K, V> cacheElement, boolean localOnly )
         throws IOException
     {
 
@@ -240,7 +239,7 @@ public class CompositeCache
      * @param localOnly
      * @throws IOException
      */
-    protected void updateAuxiliaries( ICacheElement cacheElement, boolean localOnly )
+    protected void updateAuxiliaries( ICacheElement<K, V> cacheElement, boolean localOnly )
         throws IOException
     {
         // UPDATE AUXILLIARY CACHES
@@ -253,17 +252,17 @@ public class CompositeCache
         {
             if ( auxCaches.length > 0 )
             {
-                log.debug( "Updating auxilliary caches" );
+                log.debug( "Updating auxiliary caches" );
             }
             else
             {
-                log.debug( "No auxilliary cache to update" );
+                log.debug( "No auxiliary cache to update" );
             }
         }
 
         for ( int i = 0; i < auxCaches.length; i++ )
         {
-            ICache aux = auxCaches[i];
+            ICache<K, V> aux = auxCaches[i];
 
             if ( log.isDebugEnabled() )
             {
@@ -353,7 +352,7 @@ public class CompositeCache
      * <p>
      * @param ce The CacheElement
      */
-    public void spoolToDisk( ICacheElement ce )
+    public void spoolToDisk( ICacheElement<K, V> ce )
     {
         // if the item is not spoolable, return
         if ( !ce.getElementAttributes().getIsSpool() )
@@ -368,7 +367,7 @@ public class CompositeCache
         // SPOOL TO DISK.
         for ( int i = 0; i < auxCaches.length; i++ )
         {
-            ICache aux = auxCaches[i];
+            ICache<K, V> aux = auxCaches[i];
 
             if ( aux != null && aux.getCacheType() == ICache.DISK_CACHE )
             {
@@ -428,7 +427,7 @@ public class CompositeCache
      * @return element from the cache, or null if not present
      * @see org.apache.jcs.engine.behavior.ICache#get(java.io.Serializable)
      */
-    public ICacheElement get( Serializable key )
+    public ICacheElement<K, V> get( K key )
     {
         return get( key, false );
     }
@@ -439,7 +438,7 @@ public class CompositeCache
      * @param key
      * @return ICacheElement
      */
-    public ICacheElement localGet( Serializable key )
+    public ICacheElement<K, V> localGet( K key )
     {
         return get( key, true );
     }
@@ -455,9 +454,9 @@ public class CompositeCache
      * @param localOnly
      * @return ICacheElement
      */
-    protected ICacheElement get( Serializable key, boolean localOnly )
+    protected ICacheElement<K, V> get( K key, boolean localOnly )
     {
-        ICacheElement element = null;
+        ICacheElement<K, V> element = null;
 
         boolean found = false;
 
@@ -507,7 +506,7 @@ public class CompositeCache
 
                 for ( int i = 0; i < auxCaches.length; i++ )
                 {
-                    AuxiliaryCache aux = auxCaches[i];
+                    AuxiliaryCache<K, V> aux = auxCaches[i];
 
                     if ( aux != null )
                     {
@@ -600,10 +599,10 @@ public class CompositeCache
      * 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
      */
-    public Map<Serializable, ICacheElement> getMultiple( Set<Serializable> keys )
+    public Map<K, ICacheElement<K, V>> getMultiple( Set<K> keys )
     {
         return getMultiple( keys, false );
     }
@@ -613,10 +612,10 @@ public class CompositeCache
      * laterally for this data.
      * <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
      */
-    public Map<Serializable, ICacheElement> localGetMultiple( Set<Serializable> keys )
+    public Map<K, ICacheElement<K, V>> localGetMultiple( Set<K> keys )
     {
         return getMultiple( keys, true );
     }
@@ -633,9 +632,9 @@ public class CompositeCache
      * @param localOnly
      * @return ICacheElement
      */
-    protected Map<Serializable, ICacheElement> getMultiple( Set<Serializable> keys, boolean localOnly )
+    protected Map<K, ICacheElement<K, V>> getMultiple( Set<K> keys, boolean localOnly )
     {
-        Map<Serializable, ICacheElement> elements = new HashMap<Serializable, ICacheElement>();
+        Map<K, ICacheElement<K, V>> elements = new HashMap<K, ICacheElement<K, V>>();
 
         if ( log.isDebugEnabled() )
         {
@@ -650,7 +649,7 @@ public class CompositeCache
             // If fewer than all items were found in memory, then keep looking.
             if ( elements.size() != keys.size() )
             {
-                Set<Serializable> remainingKeys = pruneKeysFound( keys, elements );
+                Set<K> remainingKeys = pruneKeysFound( keys, elements );
                 elements.putAll( getMultipleFromAuxiliaryCaches( remainingKeys, localOnly ) );
             }
         }
@@ -680,16 +679,16 @@ public class CompositeCache
      * @return the elements found in the memory cache
      * @throws IOException
      */
-    private Map<Serializable, ICacheElement> getMultipleFromMemory( Set<Serializable> keys )
+    private Map<K, ICacheElement<K, V>> getMultipleFromMemory( Set<K> keys )
         throws IOException
     {
-        Map<Serializable, ICacheElement> elementsFromMemory = memCache.getMultiple( keys );
+        Map<K, ICacheElement<K, V>> elementsFromMemory = memCache.getMultiple( keys );
 
-        Iterator<ICacheElement> elementFromMemoryIterator = new HashMap<Serializable, ICacheElement>( elementsFromMemory ).values().iterator();
+        Iterator<ICacheElement<K, V>> elementFromMemoryIterator = new HashMap<K, ICacheElement<K, V>>( elementsFromMemory ).values().iterator();
 
         while ( elementFromMemoryIterator.hasNext() )
         {
-            ICacheElement element = elementFromMemoryIterator.next();
+            ICacheElement<K, V> element = elementFromMemoryIterator.next();
 
             if ( element != null )
             {
@@ -729,20 +728,20 @@ public class CompositeCache
      * @return the elements found in the auxiliary caches
      * @throws IOException
      */
-    private Map<Serializable, ICacheElement> getMultipleFromAuxiliaryCaches( Set<Serializable> keys, boolean localOnly )
+    private Map<K, ICacheElement<K, V>> getMultipleFromAuxiliaryCaches( Set<K> keys, boolean localOnly )
         throws IOException
     {
-        Map<Serializable, ICacheElement> elements = new HashMap<Serializable, ICacheElement>();
-        Set<Serializable> remainingKeys = new HashSet<Serializable>( keys );
+        Map<K, ICacheElement<K, V>> elements = new HashMap<K, ICacheElement<K, V>>();
+        Set<K> remainingKeys = new HashSet<K>( keys );
 
         for ( int i = 0; i < auxCaches.length; i++ )
         {
-            AuxiliaryCache aux = auxCaches[i];
+            AuxiliaryCache<K, V> aux = auxCaches[i];
 
             if ( aux != null )
             {
-                Map<Serializable, ICacheElement> elementsFromAuxiliary =
-                    new HashMap<Serializable, ICacheElement>();
+                Map<K, ICacheElement<K, V>> elementsFromAuxiliary =
+                    new HashMap<K, ICacheElement<K, V>>();
 
                 long cacheType = aux.getCacheType();
 
@@ -791,10 +790,10 @@ public class CompositeCache
      * Build a map of all the matching elements in all of the auxiliaries and memory.
      * <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 for any matching keys
      */
-    public Map<Serializable, ICacheElement> getMatching( String pattern )
+    public Map<K, ICacheElement<K, V>> getMatching( String pattern )
     {
         return getMatching( pattern, false );
     }
@@ -804,10 +803,10 @@ public class CompositeCache
      * go remote or laterally for this data.
      * <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 for any matching keys
      */
-    public Map<Serializable, ICacheElement> localGetMatching( String pattern )
+    public Map<K, ICacheElement<K, V>> localGetMatching( String pattern )
     {
         return getMatching( pattern, true );
     }
@@ -822,12 +821,12 @@ public class CompositeCache
      * <p>
      * @param pattern
      * @param localOnly
-     * @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 matching keys
      */
-    protected Map<Serializable, ICacheElement> getMatching( String pattern, boolean localOnly )
+    protected Map<K, ICacheElement<K, V>> getMatching( String pattern, boolean localOnly )
     {
-        Map<Serializable, ICacheElement> elements = new HashMap<Serializable, ICacheElement>();
+        Map<K, ICacheElement<K, V>> elements = new HashMap<K, ICacheElement<K, V>>();
 
         if ( log.isDebugEnabled() )
         {
@@ -855,18 +854,18 @@ public class CompositeCache
      * set. Returns a map: key -> result.
      * <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 for any matching keys
      * @throws IOException
      */
-    protected Map<Serializable, ICacheElement> getMatchingFromMemory( String pattern )
+    protected Map<K, ICacheElement<K, V>> getMatchingFromMemory( String pattern )
         throws IOException
     {
         // find matches in key array
         // this avoids locking the memory cache, but it uses more memory
-        Object[] keyArray = memCache.getKeyArray();
+        Set<K> keyArray = memCache.getKeySet();
 
-        Set<Serializable> matchingKeys = getKeyMatcher().getMatchingKeysFromArray( pattern, keyArray );
+        Set<K> matchingKeys = getKeyMatcher().getMatchingKeysFromArray( pattern, keyArray );
 
         // call get multiple
         return getMultipleFromMemory( matchingKeys );
@@ -875,28 +874,28 @@ public class CompositeCache
     /**
      * If local invocation look in aux caches, even if not local look in disk auxiliaries.
      * <p>
-     * Moves in reverse order of definition. This will allow you to override those that are fromthe
+     * Moves in reverse order of definition. This will allow you to override those that are from the
      * remote with those on disk.
      * <p>
      * @param pattern
      * @param localOnly
-     * @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 matching keys
      * @throws IOException
      */
-    private Map<Serializable, ICacheElement> getMatchingFromAuxiliaryCaches( String pattern, boolean localOnly )
+    private Map<K, ICacheElement<K, V>> getMatchingFromAuxiliaryCaches( String pattern, boolean localOnly )
         throws IOException
     {
-        Map<Serializable, ICacheElement> elements = new HashMap<Serializable, ICacheElement>();
+        Map<K, ICacheElement<K, V>> elements = new HashMap<K, ICacheElement<K, V>>();
 
         for ( int i = auxCaches.length - 1; i >= 0; i-- )
         {
-            AuxiliaryCache aux = auxCaches[i];
+            AuxiliaryCache<K, V> aux = auxCaches[i];
 
             if ( aux != null )
             {
-                Map<Serializable, ICacheElement> elementsFromAuxiliary =
-                    new HashMap<Serializable, ICacheElement>();
+                Map<K, ICacheElement<K, V>> elementsFromAuxiliary =
+                    new HashMap<K, ICacheElement<K, V>>();
 
                 long cacheType = aux.getCacheType();
 
@@ -939,14 +938,14 @@ public class CompositeCache
      * @param elementsFromAuxiliary
      * @throws IOException
      */
-    private void processRetrievedElements( int i, Map<Serializable, ICacheElement> elementsFromAuxiliary )
+    private void processRetrievedElements( int i, Map<K, ICacheElement<K, V>> elementsFromAuxiliary )
         throws IOException
     {
-        Iterator<ICacheElement> elementFromAuxiliaryIterator = new HashMap<Serializable, ICacheElement>( elementsFromAuxiliary ).values().iterator();
+        Iterator<ICacheElement<K, V>> elementFromAuxiliaryIterator = new HashMap<K, ICacheElement<K, V>>( elementsFromAuxiliary ).values().iterator();
 
         while ( elementFromAuxiliaryIterator.hasNext() )
         {
-            ICacheElement element = elementFromAuxiliaryIterator.next();
+            ICacheElement<K, V> element = elementFromAuxiliaryIterator.next();
 
             // Item found in one of the auxiliary caches.
             if ( element != null )
@@ -991,7 +990,7 @@ public class CompositeCache
      * @param element
      * @throws IOException
      */
-    private void copyAuxiliaryRetrievedItemToMemory( ICacheElement element )
+    private void copyAuxiliaryRetrievedItemToMemory( ICacheElement<K, V> element )
         throws IOException
     {
         if ( memCache.getCacheAttributes().getMaxObjects() > 0 )
@@ -1015,11 +1014,11 @@ public class CompositeCache
      * @return the original set of cache keys, minus any cache keys present in the map keys of the
      *         foundElements map
      */
-    private Set<Serializable> pruneKeysFound( Set<Serializable> keys, Map<Serializable, ICacheElement> foundElements )
+    private Set<K> pruneKeysFound( Set<K> keys, Map<K, ICacheElement<K, V>> foundElements )
     {
-        Set<Serializable> remainingKeys = new HashSet<Serializable>( keys );
+        Set<K> remainingKeys = new HashSet<K>( keys );
 
-        for (Serializable key : foundElements.keySet())
+        for (K key : foundElements.keySet())
         {
             remainingKeys.remove( key );
         }
@@ -1033,7 +1032,7 @@ public class CompositeCache
      * @param element
      * @return true if the element is expired, else false.
      */
-    private boolean isExpired( ICacheElement element )
+    private boolean isExpired( ICacheElement<K, V> element )
     {
         try
         {
@@ -1096,13 +1095,13 @@ public class CompositeCache
      * @param group
      * @return A Set of keys, or null.
      */
-    public Set<Serializable> getGroupKeys( String group )
+    public Set<K> getGroupKeys( String group )
     {
-        HashSet<Serializable> allKeys = new HashSet<Serializable>();
+        HashSet<K> allKeys = new HashSet<K>();
         allKeys.addAll( memCache.getGroupKeys( group ) );
         for ( int i = 0; i < auxCaches.length; i++ )
         {
-            AuxiliaryCache aux = auxCaches[i];
+            AuxiliaryCache<K, V> aux = auxCaches[i];
             if ( aux != null )
             {
                 try
@@ -1125,7 +1124,7 @@ public class CompositeCache
      * @return true is it was removed
      * @see org.apache.jcs.engine.behavior.ICache#remove(java.io.Serializable)
      */
-    public boolean remove( Serializable key )
+    public boolean remove( K key )
     {
         return remove( key, false );
     }
@@ -1136,7 +1135,7 @@ public class CompositeCache
      * @param key
      * @return true if the item was already in the cache.
      */
-    public boolean localRemove( Serializable key )
+    public boolean localRemove( K key )
     {
         return remove( key, true );
     }
@@ -1158,7 +1157,7 @@ public class CompositeCache
      * @param localOnly
      * @return true if the item was in the cache, else false
      */
-    protected synchronized boolean remove( Serializable key, boolean localOnly )
+    protected synchronized boolean remove( K key, boolean localOnly )
     {
         // not thread safe, but just for debugging and testing.
         removeCount++;
@@ -1177,7 +1176,7 @@ public class CompositeCache
         // Removes from all auxiliary caches.
         for ( int i = 0; i < auxCaches.length; i++ )
         {
-            ICache aux = auxCaches[i];
+            ICache<K, V> aux = auxCaches[i];
 
             if ( aux == null )
             {
@@ -1265,7 +1264,7 @@ public class CompositeCache
         // Removes from all auxiliary disk caches.
         for ( int i = 0; i < auxCaches.length; i++ )
         {
-            ICache aux = auxCaches[i];
+            ICache<K, V> aux = auxCaches[i];
 
             if ( aux != null && ( aux.getCacheType() == ICache.DISK_CACHE || !localOnly ) )
             {
@@ -1315,14 +1314,20 @@ public class CompositeCache
         }
         alive = false;
 
+        // Now, shut down the event queue
+        if (elementEventQ != null)
+        {
+        	elementEventQ.destroy();
+        	elementEventQ = null;
+        }
+
         // Dispose of each auxiliary cache, Remote auxiliaries will be
         // skipped if 'fromRemote' is true.
-
         for ( int i = 0; i < auxCaches.length; i++ )
         {
             try
             {
-                ICache aux = auxCaches[i];
+                ICache<K, V> aux = auxCaches[i];
 
                 // Skip this auxiliary if:
                 // - The auxiliary is null
@@ -1406,19 +1411,19 @@ public class CompositeCache
             {
                 try
                 {
-                    ICache aux = auxCaches[i];
+                    ICache<K, V> aux = auxCaches[i];
 
                     if ( aux.getStatus() == CacheConstants.STATUS_ALIVE )
                     {
 
-                        Iterator<Map.Entry<Serializable, MemoryElementDescriptor>> itr =
+                        Iterator<Map.Entry<K, MemoryElementDescriptor<K, V>>> itr =
                             memCache.getIterator();
 
                         while (itr.hasNext())
                         {
-                            Map.Entry<Serializable, MemoryElementDescriptor> entry = itr.next();
+                            Map.Entry<K, MemoryElementDescriptor<K, V>> entry = itr.next();
 
-                            ICacheElement ce = entry.getValue().ce;
+                            ICacheElement<K, V> ce = entry.getValue().ce;
 
                             aux.update( ce );
                         }
@@ -1508,7 +1513,7 @@ public class CompositeCache
 
         for ( int i = 0; i < auxCaches.length; i++ )
         {
-            AuxiliaryCache aux = auxCaches[i];
+            AuxiliaryCache<K, V> aux = auxCaches[i];
             auxStats[i + 1] = aux.getStatistics();
         }
 
@@ -1583,10 +1588,10 @@ public class CompositeCache
      * @exception CacheException
      * @exception IOException
      */
-    public IElementAttributes getElementAttributes( Serializable key )
+    public IElementAttributes getElementAttributes( K key )
         throws CacheException, IOException
     {
-        CacheElement ce = (CacheElement) get( key );
+        ICacheElement<K, V> ce = get( key );
         if ( ce == null )
         {
             throw new ObjectNotFoundException( "key " + key + " is not found" );
@@ -1608,14 +1613,14 @@ public class CompositeCache
             try
             {
                 Class<?> c = Class.forName( cattr.getMemoryCacheName() );
-                memCache = (MemoryCache) c.newInstance();
+                memCache = (IMemoryCache<K, V>) c.newInstance();
                 memCache.initialize( this );
             }
             catch ( Exception e )
             {
                 log.warn( "Failed to init mem cache, using: LRUMemoryCache", e );
 
-                this.memCache = new LRUMemoryCache();
+                this.memCache = new LRUMemoryCache<K, V>();
                 this.memCache.initialize( this );
             }
         }
@@ -1630,7 +1635,7 @@ public class CompositeCache
      * <p>
      * @return the MemoryCache implementation
      */
-    public MemoryCache getMemoryCache()
+    public IMemoryCache<K, V> getMemoryCache()
     {
         return memCache;
     }
@@ -1681,7 +1686,7 @@ public class CompositeCache
      * @param ce
      * @param eventType
      */
-    private void handleElementEvent( ICacheElement ce, int eventType )
+    private void handleElementEvent( ICacheElement<K, V> ce, int eventType )
     {
         // handle event, might move to a new method
         ArrayList<IElementEventHandler> eventHandlers = ce.getElementAttributes().getElementEventHandlers();
@@ -1736,7 +1741,7 @@ public class CompositeCache
      * <p>
      * @param keyMatcher
      */
-    public void setKeyMatcher( IKeyMatcher keyMatcher )
+    public void setKeyMatcher( IKeyMatcher<K> keyMatcher )
     {
         if ( keyMatcher != null )
         {
@@ -1749,7 +1754,7 @@ public class CompositeCache
      * <p>
      * @return keyMatcher
      */
-    public IKeyMatcher getKeyMatcher()
+    public IKeyMatcher<K> getKeyMatcher()
     {
         return this.keyMatcher;
     }

Modified: commons/proper/jcs/trunk/src/java/org/apache/jcs/engine/control/CompositeCacheConfigurator.java
URL: http://svn.apache.org/viewvc/commons/proper/jcs/trunk/src/java/org/apache/jcs/engine/control/CompositeCacheConfigurator.java?rev=1344374&r1=1344373&r2=1344374&view=diff
==============================================================================
--- commons/proper/jcs/trunk/src/java/org/apache/jcs/engine/control/CompositeCacheConfigurator.java (original)
+++ commons/proper/jcs/trunk/src/java/org/apache/jcs/engine/control/CompositeCacheConfigurator.java Wed May 30 18:14:43 2012
@@ -21,6 +21,7 @@ package org.apache.jcs.engine.control;
 
 import java.io.FileInputStream;
 import java.io.IOException;
+import java.io.Serializable;
 import java.util.ArrayList;
 import java.util.Enumeration;
 import java.util.List;
@@ -216,7 +217,7 @@ public class CompositeCacheConfigurator
      *<p>
      * @param props
      */
-    protected void parseSystemRegions( Properties props )
+    protected <K extends Serializable, V extends Serializable> void parseSystemRegions( Properties props )
     {
         Enumeration<?> en = props.propertyNames();
         while ( en.hasMoreElements() )
@@ -226,13 +227,13 @@ public class CompositeCacheConfigurator
             {
                 String regionName = key.substring( SYSTEM_REGION_PREFIX.length() );
                 String value = OptionConverter.findAndSubst( key, props );
-                ICache cache;
+                ICache<K, V> cache;
                 synchronized ( regionName )
                 {
                     cache = parseRegion( props, regionName, value, null, SYSTEM_REGION_PREFIX );
                 }
                 compositeCacheManager.systemCaches.put( regionName, cache );
-                // to be availiable for remote reference they need to be here as
+                // to be available for remote reference they need to be here as
                 // well
                 compositeCacheManager.caches.put( regionName, cache );
             }
@@ -244,7 +245,7 @@ public class CompositeCacheConfigurator
      *<p>
      * @param props
      */
-    protected void parseRegions( Properties props )
+    protected <K extends Serializable, V extends Serializable> void parseRegions( Properties props )
     {
         List<String> regionNames = new ArrayList<String>();
 
@@ -259,7 +260,7 @@ public class CompositeCacheConfigurator
                 regionNames.add( regionName );
 
                 String auxiliaryList = OptionConverter.findAndSubst( key, props );
-                ICache cache;
+                ICache<K, V> cache;
                 synchronized ( regionName )
                 {
                     cache = parseRegion( props, regionName, auxiliaryList );
@@ -282,7 +283,8 @@ public class CompositeCacheConfigurator
      * @param value
      * @return CompositeCache
      */
-    protected CompositeCache parseRegion( Properties props, String regName, String value )
+    protected <K extends Serializable, V extends Serializable> CompositeCache<K, V> parseRegion(
+            Properties props, String regName, String value )
     {
         return parseRegion( props, regName, value, null, REGION_PREFIX );
     }
@@ -298,7 +300,8 @@ public class CompositeCacheConfigurator
      * @param cca
      * @return CompositeCache
      */
-    protected CompositeCache parseRegion( Properties props, String regName, String value, ICompositeCacheAttributes cca )
+    protected <K extends Serializable, V extends Serializable> CompositeCache<K, V> parseRegion(
+            Properties props, String regName, String value, ICompositeCacheAttributes cca )
     {
         return parseRegion( props, regName, value, cca, REGION_PREFIX );
     }
@@ -313,8 +316,9 @@ public class CompositeCacheConfigurator
      * @param regionPrefix
      * @return CompositeCache
      */
-    protected CompositeCache parseRegion( Properties props, String regName, String value,
-                                          ICompositeCacheAttributes cca, String regionPrefix )
+    protected <K extends Serializable, V extends Serializable> CompositeCache<K, V> parseRegion(
+            Properties props, String regName, String value,
+            ICompositeCacheAttributes cca, String regionPrefix )
     {
         // First, create or get the cache and element attributes, and create
         // the cache.
@@ -326,12 +330,12 @@ public class CompositeCacheConfigurator
 
         IElementAttributes ea = parseElementAttributes( props, regName, regionPrefix );
 
-        CompositeCache cache = new CompositeCache( regName, cca, ea );
+        CompositeCache<K, V> cache = new CompositeCache<K, V>( regName, cca, ea );
 
         if (value != null)
         {
             // Next, create the auxiliaries for the new cache
-            List<AuxiliaryCache> auxList = new ArrayList<AuxiliaryCache>();
+            List<AuxiliaryCache<K, V>> auxList = new ArrayList<AuxiliaryCache<K, V>>();
 
             if ( log.isDebugEnabled() )
             {
@@ -353,7 +357,7 @@ public class CompositeCacheConfigurator
                 }
             }
 
-            AuxiliaryCache auxCache;
+            AuxiliaryCache<K, V> auxCache;
             String auxName;
             while ( st.hasMoreTokens() )
             {
@@ -499,9 +503,9 @@ public class CompositeCacheConfigurator
      * @param regName the name of the region.
      * @return AuxiliaryCache
      */
-    protected AuxiliaryCache parseAuxiliary( CompositeCache cache, Properties props, String auxName, String regName )
+    protected <K extends Serializable, V extends Serializable> AuxiliaryCache<K, V> parseAuxiliary( CompositeCache<K, V> cache, Properties props, String auxName, String regName )
     {
-        AuxiliaryCache auxCache;
+        AuxiliaryCache<K, V> auxCache;
 
         if ( log.isDebugEnabled() )
         {
@@ -593,13 +597,13 @@ public class CompositeCacheConfigurator
      * @param auxPrefix - ex. AUXILIARY_PREFIX + auxName
      * @return IKeyMatcher
      */
-    public static IKeyMatcher parseKeyMatcher( Properties props, String auxPrefix )
+    public static <K extends Serializable> IKeyMatcher<K> parseKeyMatcher( Properties props, String auxPrefix )
     {
-        IKeyMatcher keyMatcher = null;
+        IKeyMatcher<K> keyMatcher = null;
 
         // auxFactory was not previously initialized.
         String keyMatcherClassName = auxPrefix + KEY_MATCHER_PREFIX;
-        keyMatcher = (IKeyMatcher) OptionConverter
+        keyMatcher = (IKeyMatcher<K>) OptionConverter
             .instantiateByKey( props, keyMatcherClassName,
                                IKeyMatcher.class, null );
         if ( keyMatcher != null )
@@ -615,7 +619,7 @@ public class CompositeCacheConfigurator
         else
         {
             // use the default standard serializer
-            keyMatcher = new KeyMatcherPatternImpl();
+            keyMatcher = new KeyMatcherPatternImpl<K>();
             if ( log.isInfoEnabled() )
             {
                 log.info( "Using standard key matcher [" + keyMatcher + "] for auxiliary [" + auxPrefix + "]" );

Modified: commons/proper/jcs/trunk/src/java/org/apache/jcs/engine/control/CompositeCacheManager.java
URL: http://svn.apache.org/viewvc/commons/proper/jcs/trunk/src/java/org/apache/jcs/engine/control/CompositeCacheManager.java?rev=1344374&r1=1344373&r2=1344374&view=diff
==============================================================================
--- commons/proper/jcs/trunk/src/java/org/apache/jcs/engine/control/CompositeCacheManager.java (original)
+++ commons/proper/jcs/trunk/src/java/org/apache/jcs/engine/control/CompositeCacheManager.java Wed May 30 18:14:43 2012
@@ -70,10 +70,12 @@ public class CompositeCacheManager
     protected final static Log log = LogFactory.getLog( CompositeCacheManager.class );
 
     /** Caches managed by this cache manager */
-    protected Hashtable<String, ICache> caches = new Hashtable<String, ICache>();
+    protected Hashtable<String, ICache<? extends Serializable, ? extends Serializable>> caches =
+        new Hashtable<String, ICache<? extends Serializable, ? extends Serializable>>();
 
     /** Internal system caches for this cache manager */
-    protected Hashtable<String, ICache> systemCaches = new Hashtable<String, ICache>();
+    protected Hashtable<String, ICache<? extends Serializable, ? extends Serializable>> systemCaches =
+        new Hashtable<String, ICache<? extends Serializable, ? extends Serializable>>();
 
     /** Number of clients accessing this cache manager */
     private int clients;
@@ -107,7 +109,7 @@ public class CompositeCacheManager
     /** Should we use system property substitutions. */
     private static final boolean DEFAULT_USE_SYSTEM_PROPERTIES = true;
 
-    /** Once configured, you can force a recofiguration of sorts. */
+    /** Once configured, you can force a reconfiguration of sorts. */
     private static final boolean DEFAULT_FORCE_RECONFIGURATION = false;
 
     /** Those waiting for notification of a shutdown. */
@@ -453,7 +455,7 @@ public class CompositeCacheManager
      * @param cacheName
      * @return CompositeCache -- the cache region controller
      */
-    public CompositeCache getCache( String cacheName )
+    public <K extends Serializable, V extends Serializable> CompositeCache<K, V>  getCache( String cacheName )
     {
         return getCache( cacheName, this.defaultCacheAttr.copy() );
     }
@@ -465,7 +467,7 @@ public class CompositeCacheManager
      * @param cattr
      * @return CompositeCache
      */
-    public CompositeCache getCache( String cacheName, ICompositeCacheAttributes cattr )
+    public <K extends Serializable, V extends Serializable> CompositeCache<K, V> getCache( String cacheName, ICompositeCacheAttributes cattr )
     {
         cattr.setCacheName( cacheName );
         return getCache( cattr, this.defaultElementAttr );
@@ -479,7 +481,7 @@ public class CompositeCacheManager
      * @param attr
      * @return CompositeCache
      */
-    public CompositeCache getCache( String cacheName, ICompositeCacheAttributes cattr, IElementAttributes attr )
+    public <K extends Serializable, V extends Serializable> CompositeCache<K, V>  getCache( String cacheName, ICompositeCacheAttributes cattr, IElementAttributes attr )
     {
         cattr.setCacheName( cacheName );
         return getCache( cattr, attr );
@@ -491,14 +493,14 @@ public class CompositeCacheManager
      * @param cattr
      * @return CompositeCache
      */
-    public CompositeCache getCache( ICompositeCacheAttributes cattr )
+    public <K extends Serializable, V extends Serializable> CompositeCache<K, V>  getCache( ICompositeCacheAttributes cattr )
     {
         return getCache( cattr, this.defaultElementAttr );
     }
 
     /**
      * If the cache has already been created, then the CacheAttributes and the element Attributes
-     * will be ignored. Currently there is no overiding the CacheAttributes once it is set up. You
+     * will be ignored. Currently there is no overriding the CacheAttributes once it is set up. You
      * can change the default ElementAttributes for a region later.
      * <p>
      * Overriding the default elemental attributes will require changing the way the attributes are
@@ -509,9 +511,10 @@ public class CompositeCacheManager
      * @param attr
      * @return CompositeCache
      */
-    public CompositeCache getCache( ICompositeCacheAttributes cattr, IElementAttributes attr )
+    @SuppressWarnings("unchecked")
+    public <K extends Serializable, V extends Serializable> CompositeCache<K, V>  getCache( ICompositeCacheAttributes cattr, IElementAttributes attr )
     {
-        CompositeCache cache;
+        CompositeCache<K, V> cache;
 
         if ( log.isDebugEnabled() )
         {
@@ -520,7 +523,7 @@ public class CompositeCacheManager
 
         synchronized ( caches )
         {
-            cache = (CompositeCache) caches.get( cattr.getCacheName() );
+            cache = (CompositeCache<K, V>) caches.get( cattr.getCacheName() );
             if ( cache == null )
             {
                 cattr.setCacheName( cattr.getCacheName() );
@@ -551,7 +554,7 @@ public class CompositeCacheManager
      */
     public void freeCache( String name, boolean fromRemote )
     {
-        CompositeCache cache = (CompositeCache) caches.remove( name );
+        CompositeCache<?, ?> cache = (CompositeCache<?, ?>) caches.remove( name );
 
         if ( cache != null )
         {
@@ -622,9 +625,9 @@ public class CompositeCacheManager
                 log.debug( "Last client called release. There are " + caches.size() + " caches which will be disposed" );
             }
 
-            for (ICache c : caches.values() )
+            for (ICache<?, ?> c : caches.values() )
             {
-                CompositeCache cache = (CompositeCache) c;
+                CompositeCache<?, ?> cache = (CompositeCache<?, ?>) c;
 
                 if ( cache != null )
                 {
@@ -732,9 +735,9 @@ public class CompositeCacheManager
     public ICacheStats[] getStatistics()
     {
         ArrayList<ICacheStats> cacheStats = new ArrayList<ICacheStats>();
-        for (ICache c :  caches.values())
+        for (ICache<?, ?> c :  caches.values())
         {
-            CompositeCache cache = (CompositeCache) c;
+            CompositeCache<?, ?> cache = (CompositeCache<?, ?>) c;
             if ( cache != null )
             {
                 cacheStats.add( cache.getStatistics() );

Modified: commons/proper/jcs/trunk/src/java/org/apache/jcs/engine/control/group/GroupAttrName.java
URL: http://svn.apache.org/viewvc/commons/proper/jcs/trunk/src/java/org/apache/jcs/engine/control/group/GroupAttrName.java?rev=1344374&r1=1344373&r2=1344374&view=diff
==============================================================================
--- commons/proper/jcs/trunk/src/java/org/apache/jcs/engine/control/group/GroupAttrName.java (original)
+++ commons/proper/jcs/trunk/src/java/org/apache/jcs/engine/control/group/GroupAttrName.java Wed May 30 18:14:43 2012
@@ -24,7 +24,7 @@ import java.io.Serializable;
 /**
  * Description of the Class
  */
-public class GroupAttrName
+public class GroupAttrName<T extends Serializable>
     implements Serializable
 {
     /** Don't change */
@@ -34,7 +34,7 @@ public class GroupAttrName
     public final GroupId groupId;
 
     /** the name of the attribute */
-    public final Object attrName;
+    public final T attrName;
 
     /** Cached toString value */
     private String toString;
@@ -44,15 +44,14 @@ public class GroupAttrName
      * @param groupId
      * @param attrName
      */
-    public GroupAttrName( GroupId groupId, Object attrName )
+    public GroupAttrName( GroupId groupId, T attrName )
     {
         this.groupId = groupId;
         this.attrName = attrName;
 
-        if ( groupId == null || attrName == null )
+        if ( groupId == null )
         {
-            throw new IllegalArgumentException( "groupId " + groupId + " and attrName " + attrName
-                + ", must not be null." );
+            throw new IllegalArgumentException( "groupId must not be null." );
         }
     }
 
@@ -67,8 +66,23 @@ public class GroupAttrName
         {
             return false;
         }
-        GroupAttrName to = (GroupAttrName) obj;
-        return groupId.equals( to.groupId ) && attrName.equals( to.attrName );
+        GroupAttrName<?> to = (GroupAttrName<?>) obj;
+
+        if (groupId.equals( to.groupId ))
+        {
+            if (attrName == null && to.attrName == null)
+            {
+                return true;
+            }
+            else if (attrName == null || to.attrName == null)
+            {
+                return false;
+            }
+
+            return  attrName.equals( to.attrName );
+        }
+
+        return false;
     }
 
     /**
@@ -76,6 +90,11 @@ public class GroupAttrName
      */
     public int hashCode()
     {
+        if (attrName == null)
+        {
+            return groupId.hashCode();
+        }
+
         return groupId.hashCode() ^ attrName.hashCode();
     }
 

Modified: commons/proper/jcs/trunk/src/java/org/apache/jcs/engine/logging/CacheEvent.java
URL: http://svn.apache.org/viewvc/commons/proper/jcs/trunk/src/java/org/apache/jcs/engine/logging/CacheEvent.java?rev=1344374&r1=1344373&r2=1344374&view=diff
==============================================================================
--- commons/proper/jcs/trunk/src/java/org/apache/jcs/engine/logging/CacheEvent.java (original)
+++ commons/proper/jcs/trunk/src/java/org/apache/jcs/engine/logging/CacheEvent.java Wed May 30 18:14:43 2012
@@ -6,29 +6,29 @@ import org.apache.commons.lang3.builder.
 import org.apache.jcs.engine.logging.behavior.ICacheEvent;
 
 /** It's returned from create and passed into log. */
-public class CacheEvent
-    implements ICacheEvent
+public class CacheEvent<K extends Serializable>
+    implements ICacheEvent<K>
 {
     /** Don't change. */
     private static final long serialVersionUID = -5913139566421714330L;
-    
+
     /** The time at which this object was created. */
-    private long createTime = System.currentTimeMillis();
-    
+    private final long createTime = System.currentTimeMillis();
+
     /** The auxiliary or other source of the event. */
     private String source;
-    
+
     /** The cache region */
     private String region;
-    
+
     /** The event name: update, get, remove, etc. */
     private String eventName;
-    
+
     /** disk location, ip, etc. */
     private String optionalDetails;
-    
+
     /** The key that was put or retrieved. */
-    private Serializable key;
+    private K key;
 
     /**
      * @param source the source to set
@@ -97,7 +97,7 @@ public class CacheEvent
     /**
      * @param key the key to set
      */
-    public void setKey( Serializable key )
+    public void setKey( K key )
     {
         this.key = key;
     }
@@ -105,11 +105,11 @@ public class CacheEvent
     /**
      * @return the key
      */
-    public Serializable getKey()
+    public K getKey()
     {
         return key;
     }
-    
+
     /**
      * The time at which this object was created.
      * <p>
@@ -119,8 +119,8 @@ public class CacheEvent
     {
         return createTime;
     }
-    
-    /** 
+
+    /**
      * @return reflection toString
      */
     public String toString()

Modified: commons/proper/jcs/trunk/src/java/org/apache/jcs/engine/logging/CacheEventLoggerDebugLogger.java
URL: http://svn.apache.org/viewvc/commons/proper/jcs/trunk/src/java/org/apache/jcs/engine/logging/CacheEventLoggerDebugLogger.java?rev=1344374&r1=1344373&r2=1344374&view=diff
==============================================================================
--- commons/proper/jcs/trunk/src/java/org/apache/jcs/engine/logging/CacheEventLoggerDebugLogger.java (original)
+++ commons/proper/jcs/trunk/src/java/org/apache/jcs/engine/logging/CacheEventLoggerDebugLogger.java Wed May 30 18:14:43 2012
@@ -28,10 +28,10 @@ public class CacheEventLoggerDebugLogger
      * @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 )
     {
-        ICacheEvent event = new CacheEvent();
+        ICacheEvent<T> event = new CacheEvent<T>();
         event.setSource( source );
         event.setRegion( region );
         event.setEventName( eventName );
@@ -70,7 +70,7 @@ public class CacheEventLoggerDebugLogger
     /**
      * @param event
      */
-    public void logICacheEvent( ICacheEvent event )
+    public <T extends Serializable> void logICacheEvent( ICacheEvent<T> event )
     {
         if ( log.isDebugEnabled() )
         {

Propchange: commons/proper/jcs/trunk/src/java/org/apache/jcs/engine/logging/CacheEventLoggerDebugLogger.java
            ('svn:mergeinfo' removed)

Modified: commons/proper/jcs/trunk/src/java/org/apache/jcs/engine/logging/behavior/ICacheEvent.java
URL: http://svn.apache.org/viewvc/commons/proper/jcs/trunk/src/java/org/apache/jcs/engine/logging/behavior/ICacheEvent.java?rev=1344374&r1=1344373&r2=1344374&view=diff
==============================================================================
--- commons/proper/jcs/trunk/src/java/org/apache/jcs/engine/logging/behavior/ICacheEvent.java (original)
+++ commons/proper/jcs/trunk/src/java/org/apache/jcs/engine/logging/behavior/ICacheEvent.java Wed May 30 18:14:43 2012
@@ -3,7 +3,7 @@ package org.apache.jcs.engine.logging.be
 import java.io.Serializable;
 
 /** Defines the common fields required by a cache event. */
-public interface ICacheEvent
+public interface ICacheEvent<K extends Serializable>
     extends Serializable
 {
     /**
@@ -49,10 +49,10 @@ public interface ICacheEvent
     /**
      * @param key the key to set
      */
-    public void setKey( Serializable key );
+    public void setKey( K key );
 
     /**
      * @return the key
      */
-    public Serializable getKey();
+    public K getKey();
 }

Modified: commons/proper/jcs/trunk/src/java/org/apache/jcs/engine/logging/behavior/ICacheEventLogger.java
URL: http://svn.apache.org/viewvc/commons/proper/jcs/trunk/src/java/org/apache/jcs/engine/logging/behavior/ICacheEventLogger.java?rev=1344374&r1=1344373&r2=1344374&view=diff
==============================================================================
--- commons/proper/jcs/trunk/src/java/org/apache/jcs/engine/logging/behavior/ICacheEventLogger.java (original)
+++ commons/proper/jcs/trunk/src/java/org/apache/jcs/engine/logging/behavior/ICacheEventLogger.java Wed May 30 18:14:43 2012
@@ -44,15 +44,15 @@ public interface ICacheEventLogger
      * @param key - the cache key
      * @return ICacheEvent
      */
-    ICacheEvent createICacheEvent( String source, String region, String eventName, String optionalDetails,
-                                   Serializable key );
+    <T extends Serializable> ICacheEvent<T> createICacheEvent( String source, String region,
+            String eventName, String optionalDetails, T key );
 
     /**
      * Logs an event.
      * <p>
      * @param event - the event created in createICacheEvent
      */
-    void logICacheEvent( ICacheEvent event );
+    <T extends Serializable> void logICacheEvent( ICacheEvent<T> event );
 
     /**
      * Logs an event. These are internal application events that do not correspond to ICache calls.

Propchange: commons/proper/jcs/trunk/src/java/org/apache/jcs/engine/logging/behavior/ICacheEventLogger.java
            ('svn:mergeinfo' removed)

Modified: commons/proper/jcs/trunk/src/java/org/apache/jcs/engine/match/KeyMatcherPatternImpl.java
URL: http://svn.apache.org/viewvc/commons/proper/jcs/trunk/src/java/org/apache/jcs/engine/match/KeyMatcherPatternImpl.java?rev=1344374&r1=1344373&r2=1344374&view=diff
==============================================================================
--- commons/proper/jcs/trunk/src/java/org/apache/jcs/engine/match/KeyMatcherPatternImpl.java (original)
+++ commons/proper/jcs/trunk/src/java/org/apache/jcs/engine/match/KeyMatcherPatternImpl.java Wed May 30 18:14:43 2012
@@ -9,9 +9,12 @@ import java.util.regex.Pattern;
 import org.apache.jcs.engine.match.behavior.IKeyMatcher;
 
 /** This implementation of the KeyMatcher uses standard Java Pattern matching. */
-public class KeyMatcherPatternImpl
-    implements IKeyMatcher
+public class KeyMatcherPatternImpl<K extends Serializable>
+    implements IKeyMatcher<K>
 {
+    /** TODO serialVersionUID */
+    private static final long serialVersionUID = 6667352064144381264L;
+
     /**
      * Creates a pattern and find matches on the array.
      * <p>
@@ -19,26 +22,26 @@ public class KeyMatcherPatternImpl
      * @param keyArray
      * @return Set of the matching keys
      */
-    public Set<Serializable> getMatchingKeysFromArray( String pattern, Object[] keyArray )
+    public Set<K> getMatchingKeysFromArray( String pattern, Set<K> keyArray )
     {
         Pattern compiledPattern = Pattern.compile( pattern );
 
-        Set<Serializable> matchingKeys = new HashSet<Serializable>();
+        Set<K> matchingKeys = new HashSet<K>();
 
         // Look for matches
-        for ( int i = 0; i < keyArray.length; i++ )
+        for (K key : keyArray)
         {
-            Object key = keyArray[i];
             // TODO we might want to match on the toString.
             if ( key instanceof String )
             {
                 Matcher matcher = compiledPattern.matcher( (String) key );
                 if ( matcher.matches() )
                 {
-                    matchingKeys.add( (Serializable) key );
+                    matchingKeys.add( key );
                 }
             }
         }
+
         return matchingKeys;
     }
 }

Modified: commons/proper/jcs/trunk/src/java/org/apache/jcs/engine/match/behavior/IKeyMatcher.java
URL: http://svn.apache.org/viewvc/commons/proper/jcs/trunk/src/java/org/apache/jcs/engine/match/behavior/IKeyMatcher.java?rev=1344374&r1=1344373&r2=1344374&view=diff
==============================================================================
--- commons/proper/jcs/trunk/src/java/org/apache/jcs/engine/match/behavior/IKeyMatcher.java (original)
+++ commons/proper/jcs/trunk/src/java/org/apache/jcs/engine/match/behavior/IKeyMatcher.java Wed May 30 18:14:43 2012
@@ -4,7 +4,7 @@ import java.io.Serializable;
 import java.util.Set;
 
 /** Key matchers need to implement this interface. */
-public interface IKeyMatcher extends Serializable
+public interface IKeyMatcher<K extends Serializable> extends Serializable
 {
     /**
      * Creates a pattern and find matches on the array.
@@ -13,5 +13,5 @@ public interface IKeyMatcher extends Ser
      * @param keyArray
      * @return Set of the matching keys
      */
-    Set<Serializable> getMatchingKeysFromArray( String pattern, Object[] keyArray );
+    Set<K> getMatchingKeysFromArray( String pattern, Set<K> keyArray );
 }

Modified: commons/proper/jcs/trunk/src/java/org/apache/jcs/engine/memory/AbstractDoulbeLinkedListMemoryCache.java
URL: http://svn.apache.org/viewvc/commons/proper/jcs/trunk/src/java/org/apache/jcs/engine/memory/AbstractDoulbeLinkedListMemoryCache.java?rev=1344374&r1=1344373&r2=1344374&view=diff
==============================================================================
--- commons/proper/jcs/trunk/src/java/org/apache/jcs/engine/memory/AbstractDoulbeLinkedListMemoryCache.java (original)
+++ commons/proper/jcs/trunk/src/java/org/apache/jcs/engine/memory/AbstractDoulbeLinkedListMemoryCache.java Wed May 30 18:14:43 2012
@@ -5,8 +5,10 @@ import java.io.Serializable;
 import java.util.ArrayList;
 import java.util.Hashtable;
 import java.util.Iterator;
+import java.util.LinkedHashSet;
 import java.util.Map;
 import java.util.Map.Entry;
+import java.util.Set;
 
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
@@ -14,7 +16,6 @@ import org.apache.jcs.engine.CacheConsta
 import org.apache.jcs.engine.behavior.ICacheElement;
 import org.apache.jcs.engine.control.CompositeCache;
 import org.apache.jcs.engine.control.group.GroupAttrName;
-import org.apache.jcs.engine.control.group.GroupId;
 import org.apache.jcs.engine.memory.util.MemoryElementDescriptor;
 import org.apache.jcs.engine.stats.StatElement;
 import org.apache.jcs.engine.stats.Stats;
@@ -30,8 +31,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 +41,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 +58,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 +71,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 +85,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 +94,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 +117,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 +168,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 +215,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 +233,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 +245,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 +306,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 +322,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() ) )
                     {
@@ -335,17 +336,18 @@ public abstract class AbstractDoulbeLink
                 }
             }
         }
-        else if ( key instanceof GroupId )
+        else if ( key instanceof GroupAttrName )
         {
             // 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 ) )
+                    if ( k instanceof GroupAttrName &&
+                        ((GroupAttrName<?>)k).groupId.equals(((GroupAttrName<?>)key).groupId))
                     {
                         list.remove( entry.getValue() );
                         itr.remove();
@@ -357,7 +359,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 +392,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 +406,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 +422,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 +453,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 ) )
@@ -463,7 +465,7 @@ public abstract class AbstractDoulbeLink
                 log.error( "key toString=" + key.toString() );
                 if ( key instanceof GroupAttrName )
                 {
-                    GroupAttrName name = (GroupAttrName) key;
+                    GroupAttrName<?> name = (GroupAttrName<?>) key;
                     log.error( "GroupID hashcode=" + name.groupId.hashCode() );
                     log.error( "GroupID.class=" + name.groupId.getClass() );
                     log.error( "AttrName hashcode=" + name.attrName.hashCode() );
@@ -479,7 +481,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 +495,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 +524,7 @@ public abstract class AbstractDoulbeLink
      * <p>
      * @param key
      */
-    private void verifyCache( Serializable key )
+    private void verifyCache( K key )
     {
         if ( !log.isDebugEnabled() )
         {
@@ -532,7 +534,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 +553,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 +575,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 +608,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 +639,7 @@ public abstract class AbstractDoulbeLink
         }
 
         /** @return ( (MemoryElementDescriptor) e.getValue() ).ce */
-        public ICacheElement getValue()
+        public ICacheElement<K, V> getValue()
         {
             return e.getValue().ce;
         }
@@ -654,7 +656,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 +669,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 +679,13 @@ public abstract class AbstractDoulbeLink
      * @return An Object[]
      */
     @Override
-    public Object[] getKeyArray()
+    public Set<K> getKeySet()
     {
         // need a better locking strategy here.
         synchronized ( this )
         {
             // may need to lock to map here?
-            return map.keySet().toArray();
+            return new LinkedHashSet<K>(map.keySet());
         }
     }
 
@@ -691,7 +693,7 @@ public abstract class AbstractDoulbeLink
      * This returns semi-structured information on the memory cache, such as the size, put count,
      * hit count, and miss count.
      * <p>
-     * @see org.apache.jcs.engine.memory.MemoryCache#getStatistics()
+     * @see org.apache.jcs.engine.memory.IMemoryCache#getStatistics()
      */
     @Override
     public synchronized IStats getStatistics()

Modified: commons/proper/jcs/trunk/src/java/org/apache/jcs/engine/memory/AbstractMemoryCache.java
URL: http://svn.apache.org/viewvc/commons/proper/jcs/trunk/src/java/org/apache/jcs/engine/memory/AbstractMemoryCache.java?rev=1344374&r1=1344373&r2=1344374&view=diff
==============================================================================
--- commons/proper/jcs/trunk/src/java/org/apache/jcs/engine/memory/AbstractMemoryCache.java (original)
+++ commons/proper/jcs/trunk/src/java/org/apache/jcs/engine/memory/AbstractMemoryCache.java Wed May 30 18:14:43 2012
@@ -40,6 +40,7 @@ import org.apache.jcs.engine.behavior.IE
 import org.apache.jcs.engine.control.CompositeCache;
 import org.apache.jcs.engine.control.group.GroupAttrName;
 import org.apache.jcs.engine.control.group.GroupId;
+import org.apache.jcs.engine.memory.behavior.IMemoryCache;
 import org.apache.jcs.engine.memory.shrinking.ShrinkerThread;
 import org.apache.jcs.engine.memory.util.MemoryElementDescriptor;
 import org.apache.jcs.engine.stats.Stats;
@@ -51,8 +52,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 IMemoryCache<K, V>, Serializable
 {
     /** Don't change. */
     private static final long serialVersionUID = -4494626991630099575L;
@@ -64,7 +65,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 +74,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 +91,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 +108,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 +118,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 +127,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 +137,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 +177,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,15 +206,15 @@ 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;
 
     /**
-     * Get an Array of the keys for all elements in the memory cache
+     * Get a set of the keys for all elements in the memory cache
      * <p>
-     * @return An Object[]
+     * @return A set of the key type
      */
-    public abstract Object[] getKeyArray();
+    public abstract Set<K> getKeySet();
 
     /**
      * Removes all cached items from the cache.
@@ -287,7 +288,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 +299,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 +311,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 +343,7 @@ public abstract class AbstractMemoryCach
      * <p>
      * @return The cache value
      */
-    public CompositeCache getCompositeCache()
+    public CompositeCache<K, V> getCompositeCache()
     {
         return this.cache;
     }
@@ -351,19 +352,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 ) )
+                if ( k instanceof GroupAttrName && ( (GroupAttrName<K>) k ).groupId.equals( groupId ) )
                 {
-                    keys.add((Serializable) ( (GroupAttrName) k ).attrName );
+                    keys.add(( (GroupAttrName<K>) k ).attrName );
                 }
             }
         }

Modified: commons/proper/jcs/trunk/src/java/org/apache/jcs/engine/memory/MemoryCache.java
URL: http://svn.apache.org/viewvc/commons/proper/jcs/trunk/src/java/org/apache/jcs/engine/memory/MemoryCache.java?rev=1344374&r1=1344373&r2=1344374&view=diff
==============================================================================
--- commons/proper/jcs/trunk/src/java/org/apache/jcs/engine/memory/MemoryCache.java (original)
+++ commons/proper/jcs/trunk/src/java/org/apache/jcs/engine/memory/MemoryCache.java Wed May 30 18:14:43 2012
@@ -1,37 +0,0 @@
-package org.apache.jcs.engine.memory;
-
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *   http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-import org.apache.jcs.engine.memory.behavior.IMemoryCache;
-
-/**
- * For the framework. Insures methods a MemoryCache needs to access. Not sure why we use this.
- * Should use the IMemoryCache interface. I'll change it later.
- * <p>
- * This extends IMemoryCache. There was an aborted attempt to change the interface naming
- * convention to not use the "I" prefix. At this point, there are too many "I" interfaces to get rid
- * of.
- * <p>
- */
-public interface MemoryCache
-    extends IMemoryCache
-{
-    // temporary, for backward compatibility.
-}

Modified: commons/proper/jcs/trunk/src/java/org/apache/jcs/engine/memory/behavior/IMemoryCache.java
URL: http://svn.apache.org/viewvc/commons/proper/jcs/trunk/src/java/org/apache/jcs/engine/memory/behavior/IMemoryCache.java?rev=1344374&r1=1344373&r2=1344374&view=diff
==============================================================================
--- commons/proper/jcs/trunk/src/java/org/apache/jcs/engine/memory/behavior/IMemoryCache.java (original)
+++ commons/proper/jcs/trunk/src/java/org/apache/jcs/engine/memory/behavior/IMemoryCache.java Wed May 30 18:14:43 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,17 +70,17 @@ 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.
+     * Get a set of the keys for all elements in the memory cache.
      * <p>
-     * @return Object[]
+     * @return a set of the key type
      * @TODO This should probably be done in chunks with a range passed in. This
      *       will be a problem if someone puts a 1,000,000 or so items in a
      *       region.
      */
-    Object[] getKeyArray();
+    Set<K> getKeySet();
 
     /**
      * 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/trunk/src/java/org/apache/jcs/engine/memory/fifo/FIFOMemoryCache.java
URL: http://svn.apache.org/viewvc/commons/proper/jcs/trunk/src/java/org/apache/jcs/engine/memory/fifo/FIFOMemoryCache.java?rev=1344374&r1=1344373&r2=1344374&view=diff
==============================================================================
--- commons/proper/jcs/trunk/src/java/org/apache/jcs/engine/memory/fifo/FIFOMemoryCache.java (original)
+++ commons/proper/jcs/trunk/src/java/org/apache/jcs/engine/memory/fifo/FIFOMemoryCache.java Wed May 30 18:14:43 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
     }



Mime
View raw message