Commits

Anonymous committed a394db4

Submitter: Andres March

fixed a few test cases

Comments (0)

Files changed (14)

src/core/java/com/opensymphony/oscache/algorithm/FIFOCache.java

-/*
- * Copyright (c) 2002-2003 by OpenSymphony
- * All rights reserved.
- */
-package com.opensymphony.oscache.algorithm;
-
-import java.util.Collection;
-import java.util.Iterator;
-import java.util.LinkedHashSet;
-import java.util.LinkedList;
-import java.util.List;
-
-import com.opensymphony.oscache.core.MemoryCache;
-
-/**
- * FIFO (First In First Out) based queue algorithm for the cache.
- *
- * No synchronization is required in this class since the
- * <code>AbstractConcurrentReadCache</code> already takes care of any
- * synchronization requirements.
- *
- * @version        $Revision$
- * @author        <a href="mailto:mike@atlassian.com">Mike Cannon-Brookes</a>
- * @author        <a href="mailto:abergevin@pyxis-tech.com">Alain Bergevin</a>
- * @author        <a href="&#109;a&#105;&#108;&#116;&#111;:chris&#64;swebtec.&#99;&#111;&#109;">Chris Miller</a>
- */
-public class FIFOCache extends MemoryCache {
-    /**
-     * A queue containing all cache keys
-     */
-    private Collection list;
-
-    /**
-     * A flag indicating whether we are using a List or a Set for the key collection
-     */
-    private boolean isSet = false;
-
-    /**
-     * Constructs a FIFO Cache.
-     */
-    public FIFOCache() {
-        super();
-
-        // Check if we're running under JRE 1.4+. If so we can use a LinkedHashSet
-        // instead of a LinkedList for a big performance boost when removing elements.
-        try {
-            Class.forName("java.util.LinkedHashSet");
-            list = new LinkedHashSet();
-            isSet = true;
-        } catch (ClassNotFoundException e) {
-            list = new LinkedList();
-        }
-    }
-
-    /**
-     * Constructs a FIFO Cache of the specified capacity.
-     *
-     * @param capacity The maximum cache capacity.
-     */
-    public FIFOCache(int capacity) {
-        super(capacity);
-    }
-
-    /**
-     * An object was retrieved from the cache. This implementation
-     * does noting since this event has no impact on the FIFO algorithm.
-     *
-     * @param key The cache key of the item that was retrieved.
-     */
-    protected void itemRetrieved(Object key) {
-    }
-
-    /**
-     * An object was put in the cache. This implementation just adds
-     * the key to the end of the list if it doesn't exist in the list
-     * already.
-     *
-     * @param key The cache key of the item that was put.
-     */
-    protected void itemPut(Object key) {
-        if (!list.contains(key)) {
-            list.add(key);
-        }
-    }
-
-    /**
-     * An item needs to be removed from the cache. The FIFO implementation
-     * removes the first element in the list (ie, the item that has been in
-     * the cache for the longest time).
-     *
-     * @return The key of whichever item was removed.
-     */
-    protected Object removeItem() {
-        Object toRemove;
-
-        if (isSet) {
-            Iterator it = list.iterator();
-            toRemove = it.next();
-            it.remove();
-        } else {
-            toRemove = ((List) list).remove(0);
-        }
-
-        return toRemove;
-    }
-
-    /**
-     * Remove specified key since that object has been removed from the cache.
-     *
-     * @param key The cache key of the item that was removed.
-     */
-    protected void itemRemoved(Object key) {
-        list.remove(key);
-    }
-}

src/core/java/com/opensymphony/oscache/algorithm/FIFOEvictionAlgorithm.java

+/*
+ * Copyright (c) 2002-2003 by OpenSymphony
+ * All rights reserved.
+ */
+package com.opensymphony.oscache.algorithm;
+
+import java.util.Iterator;
+import java.util.LinkedHashSet;
+import java.util.Properties;
+import java.util.Set;
+
+import com.opensymphony.oscache.core.EvictionAlgorithm;
+
+/**
+ * FIFO (First In First Out) based queue algorithm for the cache.
+ * 
+ */
+public class FIFOEvictionAlgorithm implements EvictionAlgorithm {
+	/**
+	 * A configuration parameter that specifies the maximum size of the cache
+	 * before elements start getting evicted.
+	 */
+	public static final String SIZE_PARAM = "maxSize";
+
+	private static final int DEFAULT_SIZE = 1000;
+
+	private int maxSize = DEFAULT_SIZE;
+
+	private Set elements = new LinkedHashSet();
+
+	/**
+	 * Configures the LRU policy. Valid parameters are:
+	 * <ul>
+	 * <li>{@link #SIZE_PARAM} - the maximum number of entries to hold in the
+	 * cache</li>
+	 * </ul>
+	 * 
+	 * @param params
+	 */
+	public void init(Properties params) {
+		String sizeStr = (String) params.get(SIZE_PARAM);
+		if (sizeStr != null) {
+			try {
+				maxSize = Integer.parseInt(sizeStr);
+			} catch (NumberFormatException e) {
+				// log.warn("The '" + SIZE_PARAM + "' parameter for the FIFO
+				// eviciton policy is not a valid integer. Defaulting to " +
+				// DEFAULT_SIZE);
+			}
+		}
+	}
+
+	/**
+	 * An object was retrieved from the cache. This implementation does noting
+	 * since this event has no impact on the FIFO algorithm.
+	 * 
+	 * @param key
+	 *            The cache key of the item that was retrieved.
+	 */
+	public void evaluateGet(Object key) {
+	}
+
+	/**
+	 * An object was put in the cache. This implementation just adds the key to
+	 * the end of the list if it doesn't exist in the list already.
+	 * 
+	 * @param key
+	 *            The cache key of the item that was put.
+	 */
+	public Object evaluatePut(Object key) {
+		if (!elements.contains(key)) {
+			elements.add(key);
+		}
+		return evict();
+	}
+
+	/**
+	 * An item needs to be removed from the cache. The FIFO implementation
+	 * removes the first element in the list (ie, the item that has been in the
+	 * cache for the longest time).
+	 * 
+	 * @return The key of whichever item was removed.
+	 */
+	public Object evict() {
+		Object toEvict = null;
+		if (elements.size() > maxSize) {
+			// Remove the first element (this is the one that was used
+			// least-recently)
+			Iterator it = elements.iterator();
+			toEvict = it.next();
+			it.remove();
+		}
+		return toEvict;
+	}
+
+	/**
+	 * Remove specified key since that object has been removed from the cache.
+	 * 
+	 * @param key
+	 *            The cache key of the item that was removed.
+	 */
+	public void evaluateRemove(Object key) {
+		elements.remove(key);
+	}
+}

src/core/java/com/opensymphony/oscache/algorithm/LRUEvictionAlgorithm.java

 import com.opensymphony.oscache.core.EvictionAlgorithm;
 
 /**
- * An {@link EvictionAlgorithm} that evicts cache entries based on
- * a least recently used (LRU) algorithm.
+ * An {@link EvictionAlgorithm} that evicts cache entries based on a least
+ * recently used (LRU) algorithm.
  */
 public class LRUEvictionAlgorithm implements EvictionAlgorithm {
-  
-  /**
-   * A configuration parameter that specifies the maximum size of the cache before
-   * elements start getting evicted.
-   */
-  public static final String SIZE_PARAM = "maxSize";
-  private static final int DEFAULT_SIZE = 1000;
 
-  private int maxSize = DEFAULT_SIZE;
+	/**
+	 * A configuration parameter that specifies the maximum size of the cache
+	 * before elements start getting evicted.
+	 */
+	public static final String SIZE_PARAM = "maxSize";
 
-  private Set elements = new LinkedHashSet();
+	private static final int DEFAULT_SIZE = 1000;
 
-  /**
-   * Configures the LRU policy. Valid parameters are:
-   * <ul>
-   * <li>{@link #SIZE_PARAM} - the maximum number of entries to hold in the cache</li>
-   * </ul>
-   *
-   * @param params
-   */
-  public void init(Properties params) {
-    String sizeStr = (String) params.get(SIZE_PARAM);
-    if (sizeStr != null) {
-      try {
-        maxSize = Integer.parseInt(sizeStr);
-      } catch (NumberFormatException e) {
-        //log.warn("The '" + SIZE_PARAM + "' parameter for the LRU eviciton policy is not a valid integer. Defaulting to " + DEFAULT_SIZE);
-      }
-    }
-  }
+	private int maxSize = DEFAULT_SIZE;
 
-  /**
-   * Called when an object is put in the cache. This causes the LRU algorithm
-   * to update its internal data structure.
-   */
-  public void put(Object key, Object value) {
-    // Move the key to the back of the set
-    elements.remove(key);
-    elements.add(key);
-  }
+	private Set elements = new LinkedHashSet();
 
-  /**
-   * Called when an object is retrieved from the cache. This causes the LRU
-   * algorithm to update its internal data structure.
-   */
-  public void get(Object key, Object value) {
-    // Move the key to the back of the set
-    elements.remove(key);
-    elements.add(key);
-  }
+	/**
+	 * Configures the LRU policy. Valid parameters are:
+	 * <ul>
+	 * <li>{@link #SIZE_PARAM} - the maximum number of entries to hold in the
+	 * cache</li>
+	 * </ul>
+	 * 
+	 * @param params
+	 */
+	public void init(Properties params) {
+		String sizeStr = (String) params.get(SIZE_PARAM);
+		if (sizeStr != null) {
+			try {
+				maxSize = Integer.parseInt(sizeStr);
+			} catch (NumberFormatException e) {
+				// log.warn("The '" + SIZE_PARAM + "' parameter for the LRU
+				// eviciton policy is not a valid integer. Defaulting to " +
+				// DEFAULT_SIZE);
+			}
+		}
+	}
 
-  /**
-   * Called when an object is removed from the cache. This causes the LRU
-   * algorithm to update its internal data structure.
-   *
-   * @param key
-   * @param value
-   */
-  public void remove(Object key, Object value) {
-    elements.remove(key);
-  }
+	/**
+	 * Called when an object is put in the cache. This causes the LRU algorithm
+	 * to update its internal data structure.
+	 */
+	public Object evaluatePut(Object key) {
+		// Move the key to the back of the set
+		elements.remove(key);
+		elements.add(key);
+		return evict();
+	}
 
-  /**
-   * Evict a cache entry if the cache has grown too large. The entry to be evicted
-   * will be the one that was used least-recently.
-   *
-   * @return the object that was evicted, or <code>null</code> if the cache
-   *         has not yet reached the specified maximum size.
-   */
-  public Object evict() {
-    Object toEvict = null;
-    if (elements.size() > maxSize) {
-      // Remove the first element (this is the one that was used least-recently)
-      Iterator it = elements.iterator();
-      toEvict = it.next();
-      it.remove();
-    }
-    return toEvict;
-  }
+	/**
+	 * Called when an object is retrieved from the cache. This causes the LRU
+	 * algorithm to update its internal data structure.
+	 */
+	public void evaluateGet(Object key) {
+		// Move the key to the back of the set
+		elements.remove(key);
+		elements.add(key);
+	}
+
+	/**
+	 * Called when an object is removed from the cache. This causes the LRU
+	 * algorithm to update its internal data structure.
+	 * 
+	 * @param key
+	 * @param value
+	 */
+	public void evaluateRemove(Object key) {
+		elements.remove(key);
+	}
+
+	/**
+	 * Evict a cache entry if the cache has grown too large. The entry to be
+	 * evicted will be the one that was used least-recently.
+	 * 
+	 * @return the object that was evicted, or <code>null</code> if the cache
+	 *         has not yet reached the specified maximum size.
+	 */
+	public Object evict() {
+		Object toEvict = null;
+		if (elements.size() > maxSize) {
+			// Remove the first element (this is the one that was used
+			// least-recently)
+			Iterator it = elements.iterator();
+			toEvict = it.next();
+			it.remove();
+		}
+		return toEvict;
+	}
 }

src/core/java/com/opensymphony/oscache/algorithm/UnlimitedEvictionAlgorithm.java

 
 import java.util.Properties;
 
+import com.opensymphony.oscache.core.CacheEntry;
 import com.opensymphony.oscache.core.EvictionAlgorithm;
 
 /**
- * An {@link EvictionAlgorithm} that never evicts cache entries - the
- * cache grows without bound.
+ * An {@link EvictionAlgorithm} that never evicts cache entries - the cache
+ * grows without bound.
  */
 public class UnlimitedEvictionAlgorithm implements EvictionAlgorithm {
 
-  /**
-   * Initialises the unlimited eviction policy. This policy takes
-   * no parameters, there is nothing to configure.
-   */
-  public void init(Properties params) {
-  }
+	/**
+	 * Initialises the unlimited eviction policy. This policy takes no
+	 * parameters, there is nothing to configure.
+	 */
+	public void init(Properties params) {
+	}
 
-  /**
-   * Called whenever an object is put in the cache. This implementation
-   * does nothing.
-   */
-  public void put(Object key, Object value) {
-  }
+	/**
+	 * Called whenever an object is put in the cache. This implementation does
+	 * nothing.
+	 */
+	public Object evaluatePut(Object key) {
+		return null;
+	}
 
-  /**
-   * Called whenever an object is retrieved from the cache. This
-   * implementation does nothing.
-   */
-  public void get(Object key, Object value) {
-  }
+	/**
+	 * Called whenever an object is retrieved from the cache. This
+	 * implementation does nothing.
+	 */
+	public void evaluateGet(Object key) {
+	}
 
-  /**
-   * Called whenever an object is removed from the cache. This
-   * implementation does nothing.
-   */
-  public void remove(Object key, Object value) {
-  }
+	/**
+	 * Called whenever an object is removed from the cache. This implementation
+	 * does nothing.
+	 */
+	public void evaluateRemove(Object key) {
+	}
 
-  /**
-   * Because this is an unlimited cache, no cache entries ever get
-   * evicted by this implementation.
-   *
-   * @return always returns <code>null</code>.
-   */
-  public Object evict() {
-    return null;
-  }
+	/**
+	 * Because this is an unlimited cache, no cache entries ever get evicted by
+	 * this implementation.
+	 * 
+	 * @return always returns <code>null</code>.
+	 */
+	public Object evict() {
+		return null;
+	}
 }

src/core/java/com/opensymphony/oscache/core/AbstractCacheAdministrator.java

 	 * Holds a list of all the registered listeners. listeners are specified
 	 * using the {@link #CACHE_LISTENERS_KEY} configuration key.
 	 */
-	private List listeners;
+	protected List listeners;
 
 	/**
 	 * The algorithm class being used, as specified by the
 	 */
 	protected int cacheCapacity = -1;
 
-	private Map regions = new HashMap();
+	protected Map regions = new HashMap();
 
 	/**
 	 * Create the AbstractCacheAdministrator. This will initialize all values
 		}
 	}
 
-	private Cache getCache(String regionName) {
-		
+	public Cache getCache(String regionName) {		
 		return (Cache) regions.get(regionName);
 	}
 
 	 * Sets the algorithm to use for the cache.
 	 * 
 	 * @see com.opensymphony.oscache.core.algorithm.LRUCache
-	 * @see com.opensymphony.oscache.core.algorithm.FIFOCache
+	 * @see com.opensymphony.oscache.core.algorithm.FIFOEvictionAlgorithm
 	 * @see com.opensymphony.oscache.core.algorithm.UnlimitedCache
 	 * @param newAlgorithmClass
 	 *            The class to use (eg.

src/core/java/com/opensymphony/oscache/core/BaseCache.java

 
 	private Map groupMap;
 
+	private int capacity;
+
 	/**
 	 * Clears the entire cache. This will result in a
 	 * {@link CacheEvent#CLEAR_EVENT} being fired even if the cache already
 			if (this.isStale(cacheEntry, refreshPeriod, cronExpiry)) {
 				content = null;
 			}
-			algorithm.get(key, cacheEntry);
 		}
 		return content;
 
 	public synchronized Object remove(Object key) {
 		CacheEntry result = removeInternal(key);
 		if (result != null) {
-			algorithm.remove(key, result);
+			algorithm.evaluateRemove(key);
 			fireEvent(result, CacheEvent.REMOVE);
 		}
 		return result;
 			EntryRefreshPolicy policy) {
 		CacheEntry newEntry = new CacheEntry(key, value, groups, policy);
 		CacheEntry oldEntry = putInternal(newEntry);
-		algorithm.put(key, newEntry);
+		Object evictionKey = algorithm.evaluatePut(key);
 
 		// Remove an entry from the cache if the eviction algorithm says we need
 		// to
-		Object evictionKey = algorithm.evict();
 		if (evictionKey != null) {
 			remove(evictionKey);
 		}
 	public synchronized CacheEntry getEntry(Object key) {
 		CacheEntry cacheEntry = getInternal(key);
 		if (cacheEntry != null) {
-			algorithm.get(key, cacheEntry);
+			algorithm.evaluateGet(key);
 		}
 		return cacheEntry;
 	}
 		}
 	}
 
+	public int getCapacity() {
+		return capacity;
+	}
+
 }

src/core/java/com/opensymphony/oscache/core/Cache.java

 	
 	public void setEvictionAlgorithm(EvictionAlgorithm algorithm);
 
+	public abstract int getCapacity();
+
 }

src/core/java/com/opensymphony/oscache/core/EvictionAlgorithm.java

    * of this method may want to use this information to update its
    * eviction data.
    *
-   * @param key   the key of the object that was put in the cache.
-   * @param value the value of the object that was put in the cache.
+   * @param entry   the entry of the object that was put in the cache.
+   * @return entry evicted due to the put action
    */
-  void put(Object key, Object value);
+  Object evaluatePut(Object key);
 
   /**
    * Called whenever an object was retrieved from the cache. The
    * @param key   the key of the object that was retrieved from the cache.
    * @param value the value of the object that was retrieved from the cache.
    */
-  void get(Object key, Object value);
+  void evaluateGet(Object key);
 
   /**
    * Called whenever an object is removed from the cache. The
    * @param key   the key of the object that was removed from the cache.
    * @param value the value of the object that was removed from the cache.
    */
-  void remove(Object key, Object value);
+  void evaluateRemove(Object key);
 
   /**
    * Causes the eviction policy to evict a cache entry if required.

src/core/java/com/opensymphony/oscache/extra/ScopeEventListenerImpl.java

  */
 package com.opensymphony.oscache.extra;
 
+import com.opensymphony.oscache.events.CacheEvent;
 import com.opensymphony.oscache.events.ScopeEvent;
 import com.opensymphony.oscache.events.ScopeEventListener;
-import com.opensymphony.oscache.events.ScopeEventType;
 
 /**
  * Implementation of a ScopeEventListener that keeps track of the scope flush events.
      */
     public void scopeFlushed(ScopeEvent event) {
         // Get the event type and process it
-        ScopeEventType eventType = event.getEventType();
+        int eventType = event.getEventType();
 
-        if (eventType == ScopeEventType.ALL_SCOPES_FLUSHED) {
+        if (eventType == ScopeEvent.ALL_SCOPES_FLUSHED) {
             // All 4 scopes were flushed, increment the counters
             for (int count = 1; count <= NB_SCOPES; count++) {
                 scopeFlushCount[count]++;
             }
-        } else if (eventType == ScopeEventType.SCOPE_FLUSHED) {
+        } else if (eventType == ScopeEvent.SCOPE_FLUSHED) {
             // Get back the scope from the event and increment the flush count
             scopeFlushCount[event.getScope()]++;
         } else {
 
         return returnString.toString();
     }
+
+	public void onChange(CacheEvent event) {
+		// TODO Auto-generated method stub
+		
+	}
 }

src/core/java/com/opensymphony/oscache/web/ServletCache.java

  * @param scope The scope of all entries in this hashmap
  */
     public ServletCache(ServletCacheAdministrator admin, int scope) {
-        super(admin.isMemoryCaching(), admin.isUnlimitedDiskCache(), admin.isOverflowPersistence());
+        super();
         setScope(scope);
         this.admin = admin;
     }
  * @param scope The cache scope
  */
     public ServletCache(ServletCacheAdministrator admin, String algorithmClass, int limit, int scope) {
-        super(admin.isMemoryCaching(), admin.isUnlimitedDiskCache(), admin.isOverflowPersistence(), admin.isBlocking(), limit);
+        super(limit);
         setScope(scope);
         this.admin = admin;
     }

src/core/java/com/opensymphony/oscache/web/ServletCacheAdministrator.java

  */
 package com.opensymphony.oscache.web;
 
-import com.opensymphony.oscache.core.*;
-import com.opensymphony.oscache.events.CacheListener;
-import com.opensymphony.oscache.events.ScopeEvent;
-import com.opensymphony.oscache.events.ScopeEventListener;
-import com.opensymphony.oscache.events.ScopeEventType;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-
 import java.io.Serializable;
-
-import java.util.*;
+import java.util.Date;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.Map;
+import java.util.Properties;
+import java.util.Set;
+import java.util.TreeMap;
 
 import javax.servlet.ServletContext;
 import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpSession;
 import javax.servlet.jsp.PageContext;
 
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+import com.opensymphony.oscache.core.AbstractCacheAdministrator;
+import com.opensymphony.oscache.core.Cache;
+import com.opensymphony.oscache.core.CacheEntry;
+import com.opensymphony.oscache.core.EntryRefreshPolicy;
+import com.opensymphony.oscache.events.CacheListener;
+import com.opensymphony.oscache.events.ScopeEvent;
+import com.opensymphony.oscache.events.ScopeEventListener;
+
 /**
  * A ServletCacheAdministrator creates, flushes and administers the cache.
  * <p>
     */
     public String getCacheKey() {
         if (cacheKey == null) {
-            cacheKey = getProperty(CACHE_KEY_KEY);
+            cacheKey = config.getProperty(CACHE_KEY_KEY);
 
             if (cacheKey == null) {
                 cacheKey = DEFAULT_CACHE_KEY;
         synchronized (flushTimes) {
             if (date != null) {
                 // Trigger a SCOPE_FLUSHED event
-                dispatchScopeEvent(ScopeEventType.SCOPE_FLUSHED, scope, date, null);
+                dispatchScopeEvent(ScopeEvent.SCOPE_FLUSHED, scope, date, null);
                 flushTimes.put(new Integer(scope), date);
             } else {
                 logError("setFlushTime called with a null date.");
     * @param listener  The object that listens to events.
     */
     public void addScopeEventListener(ScopeEventListener listener) {
-        listenerList.add(ScopeEventListener.class, listener);
+        listeners.add(listener);
     }
 
-    /**
-    * Cancels a pending cache update. This should only be called by a thread
-    * that received a {@link NeedsRefreshException} and was unable to generate
-    * some new cache content.
-    *
-    * @param scope The cache scope
-    * @param request The servlet request
-    * @param key The cache entry key to cancel the update of.
-    */
-    public void cancelUpdate(int scope, HttpServletRequest request, String key) {
-        Cache cache = getCache(request, scope);
-        key = this.generateEntryKey(key, request, scope);
-        cache.cancelUpdate(key);
-    }
 
     /**
     * Flush all scopes at a particular time
         }
 
         // Trigger a flushAll event
-        dispatchScopeEvent(ScopeEventType.ALL_SCOPES_FLUSHED, -1, date, null);
+        dispatchScopeEvent(ScopeEvent.ALL_SCOPES_FLUSHED, -1, date, null);
     }
 
     /**
     * @param capacity The new capacity
     */
     public void setCacheCapacity(int scope, HttpServletRequest request, int capacity) {
-        setCacheCapacity(capacity);
         getCache(request, scope).setCapacity(capacity);
     }
 
     * @param listener  The object that currently listens to events.
     */
     public void removeScopeEventListener(ScopeEventListener listener) {
-        listenerList.remove(ScopeEventListener.class, listener);
+        listeners.remove(listener);
     }
 
     /**
 
         newCache = (ServletCache) configureStandardListeners(newCache);
 
-        if (config.getProperty(CACHE_ENTRY_EVENT_LISTENERS_KEY) != null) {
+        if (config.getProperty(CACHE_LISTENERS_KEY) != null) {
             // Add any event listeners that have been specified in the configuration
-            CacheListener[] listeners = initCacheListeners();
+            initCacheListeners();
 
-            for (int i = 0; i < listeners.length; i++) {
-                if (listeners[i] instanceof ScopeEventListener) {
-                    newCache.addCacheEventListener(listeners[i], ScopeEventListener.class);
+            for (int i = 0; i < listeners.size(); i++) {
+            	if (listeners.get(i) instanceof ScopeEventListener) {
+                    newCache.addCacheListener((CacheListener)listeners.get(i));
                 }
             }
         }
     * @param date        Date of flushing
     * @param origin      The origin of the event
     */
-    private void dispatchScopeEvent(ScopeEventType eventType, int scope, Date date, String origin) {
+    private void dispatchScopeEvent(int eventType, int scope, Date date, String origin) {
         // Create the event
-        ScopeEvent event = new ScopeEvent(eventType, scope, date, origin);
+        ScopeEvent event = new ScopeEvent(null, eventType, scope, date);
 
-        // Guaranteed to return a non-null array
-        Object[] listeners = listenerList.getListenerList();
 
         // Process the listeners last to first, notifying
         // those that are interested in this event
-        for (int i = listeners.length - 2; i >= 0; i -= 2) {
-            if (listeners[i] == ScopeEventListener.class) {
-                ((ScopeEventListener) listeners[i + 1]).scopeFlushed(event);
+        for (int i = listeners.size() - 2; i >= 0; i -= 2) {
+            if (listeners.get(i) == ScopeEventListener.class) {
+                ((ScopeEventListener) listeners.get(i + 1)).scopeFlushed(event);
             }
         }
     }
     *  generation for hosting multiple sites
     */
     private void initHostDomainInKey() {
-        String propStr = getProperty(CACHE_USE_HOST_DOMAIN_KEY);
+        String propStr = config.getProperty(CACHE_USE_HOST_DOMAIN_KEY);
 
         useHostDomainInKey = "true".equalsIgnoreCase(propStr);
     }

src/core/test/com/opensymphony/oscache/core/TestConcurrency.java

 			.getLog(GeneralCacheAdministrator.class); // TestConcurrency.class
 
 	// Static variables required thru all the tests
-	private static GeneralCacheAdministrator admin = null;
+	private static Cache admin = null;
 
 	// Constants needed in the tests
 	private final String KEY = "key";
 			Properties config = new Properties();
 			config.setProperty(AbstractCacheAdministrator.CACHE_CAPACITY_KEY,
 					"70");
-			config.setProperty(AbstractCacheAdministrator.CACHE_BLOCKING_KEY,
-					"false");
-			admin = new GeneralCacheAdministrator();
+			admin = new MemoryCache();
 			assertNotNull(admin);
 		}
 	}
 
 			try {
 				// Get from the cache
-				admin.getFromCache(KEY, refreshPeriod);
+				admin.get(KEY, refreshPeriod);
 			
 				admin.put(KEY, VALUE);
 			} catch (Exception e) {
 
 			// Flush occasionally
 			if ((i % (UNIQUE_KEYS + 1)) == 0) {
-				admin.getCache().flushEntry(key);
+				admin.remove(key);
 			}
 		}
 

src/core/test/com/opensymphony/oscache/core/algorithm/TestAbstractCache.java

  */
 package com.opensymphony.oscache.core.algorithm;
 
+import com.opensymphony.oscache.core.BaseCache;
+import com.opensymphony.oscache.core.Cache;
+import com.opensymphony.oscache.core.EvictionAlgorithm;
+
 import junit.framework.TestCase;
 
 /**
      * Test the capacity setting
      */
     public void testGetSetMaxEntries() {
-        getCache().set(MAX_ENTRIES);
-        assertEquals(MAX_ENTRIES, getCache().getMaxEntries());
+    	getAlgorithm().setCapacity(MAX_ENTRIES);
+        assertEquals(MAX_ENTRIES, getAlgorithm().getCapacity());
 
         // Specify an invalid capacity
         try {
-            getCache().setMaxEntries(INVALID_MAX_ENTRIES);
+        	getAlgorithm().setCapacity(INVALID_MAX_ENTRIES);
             fail("Cache capacity set with an invalid argument");
         } catch (Exception e) {
             // This is what we expect
     }
 
     /**
-     * Test the setting of the memory cache
-     */
-    public void testGetSetMemoryCache() {
-        getCache().setMemoryCaching(true);
-        assertTrue(getCache().isMemoryCaching());
-    }
-
-    /**
      * Test the iterator retrieval
      */
     public abstract void testIterator();
      */
     public abstract void testRemoveItem();
 
-    /**
-     * Test the PersistenceListener setter. Since the persistance listener is
-     * an interface, just call the setter with null
-     */
-    public void testSetPersistenceListener() {
-        getCache().setPersistenceListener(null);
-    }
 
     // Abstract method that returns an instance of an admin
-    protected abstract AbstractConcurrentReadCache getCache();
+    protected abstract EvictionAlgorithm getAlgorithm();
 }

src/core/test/com/opensymphony/oscache/core/algorithm/TestFIFOCache.java

  */
 package com.opensymphony.oscache.core.algorithm;
 
-import com.opensymphony.oscache.algorithm.FIFOCache;
-
 import junit.framework.Test;
 import junit.framework.TestSuite;
 
+import com.opensymphony.oscache.algorithm.FIFOEvictionAlgorithm;
+import com.opensymphony.oscache.core.Cache;
+import com.opensymphony.oscache.core.MemoryCache;
+
 /**
  * Test class for the FIFOCache class. It tests that the algorithm reacts as
  * expected when entries are removed
- *
+ * 
  * $Id$
- * @version        $Revision$
+ * 
+ * @version $Revision$
  * @author <a href="mailto:abergevin@pyxis-tech.com">Alain Bergevin</a>
  */
 public final class TestFIFOCache extends TestQueueCache {
-    /**
-     * FIFO Cache object
-     */
-    private static FIFOCache cache = null;
+	/**
+	 * FIFO Cache object
+	 */
+	private static FIFOEvictionAlgorithm cache = null;
 
-    /**
-     * Constructor
-     * <p>
-     * @param str The test name (required by JUnit)
-     */
-    public TestFIFOCache(String str) {
-        super(str);
-    }
+	/**
+	 * Constructor
+	 * <p>
+	 * 
+	 * @param str
+	 *            The test name (required by JUnit)
+	 */
+	public TestFIFOCache(String str) {
+		super(str);
+	}
 
-    /**
-     * This methods returns the name of this test class to JUnit
-     * <p>
-     * @return The test for this class
-     */
-    public static Test suite() {
-        return new TestSuite(TestFIFOCache.class);
-    }
+	/**
+	 * This methods returns the name of this test class to JUnit
+	 * <p>
+	 * 
+	 * @return The test for this class
+	 */
+	public static Test suite() {
+		return new TestSuite(TestFIFOCache.class);
+	}
 
-    /**
-     * Abstract method used by the TestAbstractCache class
-     * <p>
-     * @return  A cache instance
-     */
-    public AbstractConcurrentReadCache getCache() {
-        return cache;
-    }
+	/**
+	 * Abstract method used by the TestAbstractCache class
+	 * <p>
+	 * 
+	 * @return A cache instance
+	 */
+	public Cache getCache() {
+		return cache;
+	}
 
-    /**
-     * This method is invoked before each testXXXX methods of the
-     * class. It set ups the variables required for each tests.
-     */
-    public void setUp() {
-        // Create a cache instance on first invocation
-        if (cache == null) {
-            cache = new FIFOCache();
-            assertNotNull(cache);
-        }
-    }
+	/**
+	 * This method is invoked before each testXXXX methods of the class. It set
+	 * ups the variables required for each tests.
+	 */
+	public void setUp() {
+		// Create a cache instance on first invocation
+		if (cache == null) {
+			FIFOEvictionAlgorithm alg = new FIFOEvictionAlgorithm();
+			cache = new MemoryCache();
+			cache.setEvictionAlgorithm(alg);
+			assertNotNull(cache);
+		}
+	}
 
-    /**
-     * Test the cache algorithm
-     */
-    public void testRemoveItem() {
-        // Add 2 elements in the cache and ensure that the one to remove is the first
-        // inserted
-        cache.itemPut(KEY);
-        cache.itemPut(KEY + 1);
-        assertTrue(KEY.equals(cache.removeItem()));
-    }
+	/**
+	 * Test the cache algorithm
+	 */
+	public void testRemoveItem() {
+		// Add 2 elements in the cache and ensure that the one to remove is the
+		// first
+		// inserted
+		cache.itemPut(KEY);
+		cache.itemPut(KEY + 1);
+		assertTrue(KEY.equals(cache.removeItem()));
+	}
 }