Return-Path: Delivered-To: apmail-jakarta-jcs-dev-archive@www.apache.org Received: (qmail 10342 invoked from network); 10 Oct 2008 17:36:31 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 10 Oct 2008 17:36:31 -0000 Received: (qmail 58919 invoked by uid 500); 10 Oct 2008 17:36:30 -0000 Delivered-To: apmail-jakarta-jcs-dev-archive@jakarta.apache.org Received: (qmail 58899 invoked by uid 500); 10 Oct 2008 17:36:30 -0000 Mailing-List: contact jcs-dev-help@jakarta.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: "JCS Developers List" Delivered-To: mailing list jcs-dev@jakarta.apache.org Received: (qmail 58888 invoked by uid 500); 10 Oct 2008 17:36:30 -0000 Delivered-To: apmail-jakarta-jcs-commits@jakarta.apache.org Received: (qmail 58885 invoked by uid 500); 10 Oct 2008 17:36:30 -0000 Delivered-To: apmail-jakarta-jcs-cvs@jakarta.apache.org Received: (qmail 58882 invoked by uid 99); 10 Oct 2008 17:36:30 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 10 Oct 2008 10:36:30 -0700 X-ASF-Spam-Status: No, hits=-2000.0 required=10.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 10 Oct 2008 17:35:33 +0000 Received: by eris.apache.org (Postfix, from userid 65534) id 2BCDC23888A6; Fri, 10 Oct 2008 10:35:39 -0700 (PDT) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r703528 - in /jakarta/jcs/trunk/src: java/org/apache/jcs/auxiliary/ java/org/apache/jcs/auxiliary/disk/ java/org/apache/jcs/auxiliary/lateral/ java/org/apache/jcs/auxiliary/remote/ java/org/apache/jcs/auxiliary/remote/server/ java/org/apach... Date: Fri, 10 Oct 2008 17:35:38 -0000 To: jcs-cvs@jakarta.apache.org From: asmuts@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20081010173539.2BCDC23888A6@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: asmuts Date: Fri Oct 10 10:35:38 2008 New Revision: 703528 URL: http://svn.apache.org/viewvc?rev=703528&view=rev Log: added the ability to specify a custom event queue Added: jakarta/jcs/trunk/src/test/org/apache/jcs/engine/CacheEventQueueFactoryUnitTest.java jakarta/jcs/trunk/src/test/org/apache/jcs/engine/MockCacheEventQueue.java Modified: jakarta/jcs/trunk/src/java/org/apache/jcs/auxiliary/AbstractAuxiliaryCacheAttributes.java jakarta/jcs/trunk/src/java/org/apache/jcs/auxiliary/AuxiliaryCacheAttributes.java jakarta/jcs/trunk/src/java/org/apache/jcs/auxiliary/disk/AbstractDiskCache.java jakarta/jcs/trunk/src/java/org/apache/jcs/auxiliary/lateral/LateralCacheNoWait.java jakarta/jcs/trunk/src/java/org/apache/jcs/auxiliary/remote/RemoteCacheNoWait.java jakarta/jcs/trunk/src/java/org/apache/jcs/auxiliary/remote/server/RemoteCacheServer.java jakarta/jcs/trunk/src/java/org/apache/jcs/engine/CacheEventQueue.java jakarta/jcs/trunk/src/java/org/apache/jcs/engine/CacheEventQueueFactory.java jakarta/jcs/trunk/src/java/org/apache/jcs/engine/PooledCacheEventQueue.java jakarta/jcs/trunk/src/java/org/apache/jcs/engine/behavior/ICacheEventQueue.java jakarta/jcs/trunk/src/java/org/apache/jcs/engine/behavior/ICacheListener.java Modified: jakarta/jcs/trunk/src/java/org/apache/jcs/auxiliary/AbstractAuxiliaryCacheAttributes.java URL: http://svn.apache.org/viewvc/jakarta/jcs/trunk/src/java/org/apache/jcs/auxiliary/AbstractAuxiliaryCacheAttributes.java?rev=703528&r1=703527&r2=703528&view=diff ============================================================================== --- jakarta/jcs/trunk/src/java/org/apache/jcs/auxiliary/AbstractAuxiliaryCacheAttributes.java (original) +++ jakarta/jcs/trunk/src/java/org/apache/jcs/auxiliary/AbstractAuxiliaryCacheAttributes.java Fri Oct 10 10:35:38 2008 @@ -15,8 +15,6 @@ * the License. */ -import org.apache.jcs.engine.behavior.ICacheEventQueue; - /** * This has common attributes used by all auxiliaries. */ @@ -32,8 +30,8 @@ /** name */ protected String name; - /** eventQueueType -- pooled or single threaded */ - protected int eventQueueType; + /** eventQueueType -- custom classname, pooled, or single threaded */ + protected String eventQueueType; /** Named when pooled */ protected String eventQueuePoolName; @@ -79,27 +77,11 @@ /** * SINGLE is the default. If you choose POOLED, the value of EventQueuePoolName will be used *

- * @param s SINGLE or POOLED + * @param queueType SINGLE or POOLED or a classname */ - public void setEventQueueType( String s ) + public void setEventQueueType( String queueType ) { - if ( s != null ) - { - if ( s.equalsIgnoreCase( POOLED_QUEUE_TYPE ) ) - { - this.eventQueueType = ICacheEventQueue.POOLED_QUEUE_TYPE; - } - else - { - // single by default - this.eventQueueType = ICacheEventQueue.SINGLE_QUEUE_TYPE; - } - } - else - { - // null, single by default - this.eventQueueType = ICacheEventQueue.SINGLE_QUEUE_TYPE; - } + this.eventQueueType = queueType; } /** @@ -107,24 +89,7 @@ */ public String getEventQueueType() { - if ( this.eventQueueType == ICacheEventQueue.POOLED_QUEUE_TYPE ) - { - return POOLED_QUEUE_TYPE; - } - else - { - return SINGLE_QUEUE_TYPE; - } - } - - /** - * Returns the value used by the factory. - *

- * @return code - */ - public int getEventQueueTypeFactoryCode() - { - return this.eventQueueType; + return eventQueueType; } /** Modified: jakarta/jcs/trunk/src/java/org/apache/jcs/auxiliary/AuxiliaryCacheAttributes.java URL: http://svn.apache.org/viewvc/jakarta/jcs/trunk/src/java/org/apache/jcs/auxiliary/AuxiliaryCacheAttributes.java?rev=703528&r1=703527&r2=703528&view=diff ============================================================================== --- jakarta/jcs/trunk/src/java/org/apache/jcs/auxiliary/AuxiliaryCacheAttributes.java (original) +++ jakarta/jcs/trunk/src/java/org/apache/jcs/auxiliary/AuxiliaryCacheAttributes.java Fri Oct 10 10:35:38 2008 @@ -30,6 +30,7 @@ /** Uses a thread pool. */ public static final String POOLED_QUEUE_TYPE = "POOLED"; + /** * Sets the name of the cache, referenced by the appropriate manager. *

@@ -71,13 +72,6 @@ public String getEventQueueType(); /** - * Returns the value used by the factory. - *

- * @return code - */ - public int getEventQueueTypeFactoryCode(); - - /** * If you choose a POOLED event queue type, the value of EventQueuePoolName will be used. This * is ignored if the pool type is SINGLE *

Modified: jakarta/jcs/trunk/src/java/org/apache/jcs/auxiliary/disk/AbstractDiskCache.java URL: http://svn.apache.org/viewvc/jakarta/jcs/trunk/src/java/org/apache/jcs/auxiliary/disk/AbstractDiskCache.java?rev=703528&r1=703527&r2=703528&view=diff ============================================================================== --- jakarta/jcs/trunk/src/java/org/apache/jcs/auxiliary/disk/AbstractDiskCache.java (original) +++ jakarta/jcs/trunk/src/java/org/apache/jcs/auxiliary/disk/AbstractDiskCache.java Fri Oct 10 10:35:38 2008 @@ -121,7 +121,7 @@ CacheEventQueueFactory fact = new CacheEventQueueFactory(); this.cacheEventQueue = fact.createCacheEventQueue( new MyCacheListener(), CacheInfo.listenerId, cacheName, dcattr.getEventQueuePoolName(), dcattr - .getEventQueueTypeFactoryCode() ); + .getEventQueueType() ); // create purgatory initPurgatory(); Modified: jakarta/jcs/trunk/src/java/org/apache/jcs/auxiliary/lateral/LateralCacheNoWait.java URL: http://svn.apache.org/viewvc/jakarta/jcs/trunk/src/java/org/apache/jcs/auxiliary/lateral/LateralCacheNoWait.java?rev=703528&r1=703527&r2=703528&view=diff ============================================================================== --- jakarta/jcs/trunk/src/java/org/apache/jcs/auxiliary/lateral/LateralCacheNoWait.java (original) +++ jakarta/jcs/trunk/src/java/org/apache/jcs/auxiliary/lateral/LateralCacheNoWait.java Fri Oct 10 10:35:38 2008 @@ -94,7 +94,7 @@ CacheEventQueueFactory fact = new CacheEventQueueFactory(); this.q = fact.createCacheEventQueue( new CacheAdaptor( cache ), LateralCacheInfo.listenerId, cache .getCacheName(), cache.getAuxiliaryCacheAttributes().getEventQueuePoolName(), cache - .getAuxiliaryCacheAttributes().getEventQueueTypeFactoryCode() ); + .getAuxiliaryCacheAttributes().getEventQueueType() ); // need each no wait to handle each of its real updates and removes, // since there may @@ -318,7 +318,7 @@ CacheEventQueueFactory fact = new CacheEventQueueFactory(); this.q = fact.createCacheEventQueue( new CacheAdaptor( cache ), LateralCacheInfo.listenerId, cache .getCacheName(), cache.getAuxiliaryCacheAttributes().getEventQueuePoolName(), cache - .getAuxiliaryCacheAttributes().getEventQueueTypeFactoryCode() ); + .getAuxiliaryCacheAttributes().getEventQueueType() ); } /** Modified: jakarta/jcs/trunk/src/java/org/apache/jcs/auxiliary/remote/RemoteCacheNoWait.java URL: http://svn.apache.org/viewvc/jakarta/jcs/trunk/src/java/org/apache/jcs/auxiliary/remote/RemoteCacheNoWait.java?rev=703528&r1=703527&r2=703528&view=diff ============================================================================== --- jakarta/jcs/trunk/src/java/org/apache/jcs/auxiliary/remote/RemoteCacheNoWait.java (original) +++ jakarta/jcs/trunk/src/java/org/apache/jcs/auxiliary/remote/RemoteCacheNoWait.java Fri Oct 10 10:35:38 2008 @@ -108,7 +108,7 @@ CacheEventQueueFactory factory = new CacheEventQueueFactory(); this.cacheEventQueue = factory.createCacheEventQueue( new CacheAdaptor( remoteCacheClient ), remoteCacheClient .getListenerId(), remoteCacheClient.getCacheName(), remoteCacheClient.getAuxiliaryCacheAttributes() - .getEventQueuePoolName(), remoteCacheClient.getAuxiliaryCacheAttributes().getEventQueueTypeFactoryCode() ); + .getEventQueuePoolName(), remoteCacheClient.getAuxiliaryCacheAttributes().getEventQueueType() ); if ( remoteCacheClient.getStatus() == CacheConstants.STATUS_ERROR ) { @@ -367,7 +367,7 @@ CacheEventQueueFactory fact = new CacheEventQueueFactory(); this.cacheEventQueue = fact.createCacheEventQueue( new CacheAdaptor( remoteCacheClient ), remoteCacheClient .getListenerId(), remoteCacheClient.getCacheName(), remoteCacheClient.getAuxiliaryCacheAttributes() - .getEventQueuePoolName(), remoteCacheClient.getAuxiliaryCacheAttributes().getEventQueueTypeFactoryCode() ); + .getEventQueuePoolName(), remoteCacheClient.getAuxiliaryCacheAttributes().getEventQueueType() ); if ( previousQueue.isWorking() ) { Modified: jakarta/jcs/trunk/src/java/org/apache/jcs/auxiliary/remote/server/RemoteCacheServer.java URL: http://svn.apache.org/viewvc/jakarta/jcs/trunk/src/java/org/apache/jcs/auxiliary/remote/server/RemoteCacheServer.java?rev=703528&r1=703527&r2=703528&view=diff ============================================================================== --- jakarta/jcs/trunk/src/java/org/apache/jcs/auxiliary/remote/server/RemoteCacheServer.java (original) +++ jakarta/jcs/trunk/src/java/org/apache/jcs/auxiliary/remote/server/RemoteCacheServer.java Fri Oct 10 10:35:38 2008 @@ -1252,7 +1252,7 @@ CacheEventQueueFactory fact = new CacheEventQueueFactory(); ICacheEventQueue q = fact.createCacheEventQueue( listener, id, cacheName, remoteCacheServerAttributes - .getEventQueuePoolName(), remoteCacheServerAttributes.getEventQueueTypeFactoryCode() ); + .getEventQueuePoolName(), remoteCacheServerAttributes.getEventQueueType() ); eventQMap.put( new Long( listener.getListenerId() ), q ); Modified: jakarta/jcs/trunk/src/java/org/apache/jcs/engine/CacheEventQueue.java URL: http://svn.apache.org/viewvc/jakarta/jcs/trunk/src/java/org/apache/jcs/engine/CacheEventQueue.java?rev=703528&r1=703527&r2=703528&view=diff ============================================================================== --- jakarta/jcs/trunk/src/java/org/apache/jcs/engine/CacheEventQueue.java (original) +++ jakarta/jcs/trunk/src/java/org/apache/jcs/engine/CacheEventQueue.java Fri Oct 10 10:35:38 2008 @@ -47,7 +47,7 @@ private static final Log log = LogFactory.getLog( CacheEventQueue.class ); /** The type of queue -- there are pooled and single */ - private static final int queueType = SINGLE_QUEUE_TYPE; + private static final String queueType = SINGLE_QUEUE_TYPE; /** default */ private static final int DEFAULT_WAIT_TO_DIE_MILLIS = 10000; @@ -124,6 +124,22 @@ public CacheEventQueue( ICacheListener listener, long listenerId, String cacheName, int maxFailure, int waitBeforeRetry ) { + initialize( listener, listenerId, cacheName, maxFailure, waitBeforeRetry, null ); + } + + /** + * Initializes the queue. + * <,p> + * @param listener + * @param listenerId + * @param cacheName + * @param maxFailure + * @param waitBeforeRetry + * @param threadPoolName + */ + public void initialize( ICacheListener listener, long listenerId, String cacheName, int maxFailure, + int waitBeforeRetry, String threadPoolName ) + { if ( listener == null ) { throw new IllegalArgumentException( "listener must not be null" ); @@ -140,14 +156,13 @@ log.debug( "Constructed: " + this ); } } - + /** * What type of queue is this. *

- * (non-Javadoc) - * @see org.apache.jcs.engine.behavior.ICacheEventQueue#getQueueType() + * @return queueType */ - public int getQueueType() + public String getQueueType() { return queueType; } @@ -164,6 +179,7 @@ /** * Returns the time to wait for events before killing the background thread. + *

* @return int */ public int getWaitToDieMillis() Modified: jakarta/jcs/trunk/src/java/org/apache/jcs/engine/CacheEventQueueFactory.java URL: http://svn.apache.org/viewvc/jakarta/jcs/trunk/src/java/org/apache/jcs/engine/CacheEventQueueFactory.java?rev=703528&r1=703527&r2=703528&view=diff ============================================================================== --- jakarta/jcs/trunk/src/java/org/apache/jcs/engine/CacheEventQueueFactory.java (original) +++ jakarta/jcs/trunk/src/java/org/apache/jcs/engine/CacheEventQueueFactory.java Fri Oct 10 10:35:38 2008 @@ -23,9 +23,11 @@ import org.apache.commons.logging.LogFactory; import org.apache.jcs.engine.behavior.ICacheEventQueue; import org.apache.jcs.engine.behavior.ICacheListener; +import org.apache.jcs.utils.config.OptionConverter; /** - * This class hands out event Queues. This allows us to change the implementation more easily. + * This class hands out event Queues. This allows us to change the implementation more easily. You + * can confugure the cache to use a custom type. *

* @author aaronsm */ @@ -41,11 +43,11 @@ * @param listenerId * @param cacheName * @param threadPoolName - * @param poolType + * @param poolType - SINGLE, QUEUED, or classname * @return ICacheEventQueue */ public ICacheEventQueue createCacheEventQueue( ICacheListener listener, long listenerId, String cacheName, - String threadPoolName, int poolType ) + String threadPoolName, String poolType ) { return createCacheEventQueue( listener, listenerId, cacheName, 10, 500, threadPoolName, poolType ); } @@ -64,21 +66,38 @@ */ public ICacheEventQueue createCacheEventQueue( ICacheListener listener, long listenerId, String cacheName, int maxFailure, int waitBeforeRetry, String threadPoolName, - int poolType ) + String poolType ) { if ( log.isDebugEnabled() ) { log.debug( "threadPoolName = [" + threadPoolName + "] poolType = " + poolType + " " ); } - if ( poolType == ICacheEventQueue.SINGLE_QUEUE_TYPE ) + ICacheEventQueue eventQueue = null; + if ( ICacheEventQueue.SINGLE_QUEUE_TYPE.equalsIgnoreCase( poolType ) ) { - return new CacheEventQueue( listener, listenerId, cacheName, maxFailure, waitBeforeRetry ); + eventQueue = new CacheEventQueue( listener, listenerId, cacheName, maxFailure, waitBeforeRetry ); + } + else if ( ICacheEventQueue.POOLED_QUEUE_TYPE.equalsIgnoreCase( poolType ) ) + { + eventQueue = new PooledCacheEventQueue( listener, listenerId, cacheName, maxFailure, waitBeforeRetry, + threadPoolName ); } else { - return new PooledCacheEventQueue( listener, listenerId, cacheName, maxFailure, waitBeforeRetry, - threadPoolName ); + eventQueue = (ICacheEventQueue) OptionConverter.instantiateByClassName( poolType, ICacheEventQueue.class, + null ); + if ( eventQueue != null ) + { + eventQueue.initialize( listener, listenerId, cacheName, maxFailure, waitBeforeRetry, threadPoolName ); + } + else + { + log.warn( "Could not instantiate custom event queue [" + poolType + + "]. Will use standard single threaded queue." ); + eventQueue = new CacheEventQueue( listener, listenerId, cacheName, maxFailure, waitBeforeRetry ); + } } + return eventQueue; } } Modified: jakarta/jcs/trunk/src/java/org/apache/jcs/engine/PooledCacheEventQueue.java URL: http://svn.apache.org/viewvc/jakarta/jcs/trunk/src/java/org/apache/jcs/engine/PooledCacheEventQueue.java?rev=703528&r1=703527&r2=703528&view=diff ============================================================================== --- jakarta/jcs/trunk/src/java/org/apache/jcs/engine/PooledCacheEventQueue.java (original) +++ jakarta/jcs/trunk/src/java/org/apache/jcs/engine/PooledCacheEventQueue.java Fri Oct 10 10:35:38 2008 @@ -53,13 +53,14 @@ public class PooledCacheEventQueue implements ICacheEventQueue { - private static final int queueType = POOLED_QUEUE_TYPE; + /** The type of event queue */ + private static final String queueType = POOLED_QUEUE_TYPE; + /** The logger */ private static final Log log = LogFactory.getLog( PooledCacheEventQueue.class ); - // time to wait for an event before snuffing the background thread - // if the queue is empty. - // make configurable later + /** time to wait for an event before snuffing the background thread + if the queue is empty. make configurable later */ private int waitToDieMillis = 10000; private ICacheListener listener; @@ -70,14 +71,14 @@ private int maxFailure; - // in milliseconds + /** in milliseconds */ private int waitBeforeRetry; private boolean destroyed = true; private boolean working = true; - // The Thread Pool to execute events with. + /** The Thread Pool to execute events with. */ private ThreadPool pool = null; /** @@ -93,6 +94,22 @@ public PooledCacheEventQueue( ICacheListener listener, long listenerId, String cacheName, int maxFailure, int waitBeforeRetry, String threadPoolName ) { + initialize( listener, listenerId, cacheName, maxFailure, waitBeforeRetry, threadPoolName ); + } + + /** + * Initializes the queue. + * <,p> + * @param listener + * @param listenerId + * @param cacheName + * @param maxFailure + * @param waitBeforeRetry + * @param threadPoolName + */ + public void initialize( ICacheListener listener, long listenerId, String cacheName, int maxFailure, + int waitBeforeRetry, String threadPoolName ) + { if ( listener == null ) { throw new IllegalArgumentException( "listener must not be null" ); @@ -113,14 +130,14 @@ if ( log.isDebugEnabled() ) { - log.debug( "Constructed: " + this ); + log.debug( "Initialized: " + this ); } } /** * @return the queue type */ - public int getQueueType() + public String getQueueType() { return queueType; } Modified: jakarta/jcs/trunk/src/java/org/apache/jcs/engine/behavior/ICacheEventQueue.java URL: http://svn.apache.org/viewvc/jakarta/jcs/trunk/src/java/org/apache/jcs/engine/behavior/ICacheEventQueue.java?rev=703528&r1=703527&r2=703528&view=diff ============================================================================== --- jakarta/jcs/trunk/src/java/org/apache/jcs/engine/behavior/ICacheEventQueue.java (original) +++ jakarta/jcs/trunk/src/java/org/apache/jcs/engine/behavior/ICacheEventQueue.java Fri Oct 10 10:35:38 2008 @@ -31,21 +31,35 @@ public interface ICacheEventQueue { /** + * Initializes the queue. + * <,p> + * @param listener + * @param listenerId + * @param cacheName + * @param maxFailure + * @param waitBeforeRetry + * @param threadPoolName + */ + public void initialize( ICacheListener listener, long listenerId, String cacheName, int maxFailure, + int waitBeforeRetry, String threadPoolName ); + + /** * Does not use a thread pool. */ - public static final int SINGLE_QUEUE_TYPE = 0; + public static final String SINGLE_QUEUE_TYPE = "SINGLE"; /** * Uses a thread pool */ - public static final int POOLED_QUEUE_TYPE = 1; + public static final String POOLED_QUEUE_TYPE = "POOLED"; + /** * Return the type of event queue we are using, either single or pooled. *

* @return the queue type: single or pooled */ - public abstract int getQueueType(); + public abstract String getQueueType(); /** * Adds a feature to the PutEvent attribute of the ICacheEventQueue object Modified: jakarta/jcs/trunk/src/java/org/apache/jcs/engine/behavior/ICacheListener.java URL: http://svn.apache.org/viewvc/jakarta/jcs/trunk/src/java/org/apache/jcs/engine/behavior/ICacheListener.java?rev=703528&r1=703527&r2=703528&view=diff ============================================================================== --- jakarta/jcs/trunk/src/java/org/apache/jcs/engine/behavior/ICacheListener.java (original) +++ jakarta/jcs/trunk/src/java/org/apache/jcs/engine/behavior/ICacheListener.java Fri Oct 10 10:35:38 2008 @@ -23,52 +23,54 @@ import java.io.Serializable; /** - * Used to receive a cache event notification.
- *
- * Note: objects which implement this interface are local listeners to cache - * changes, whereas objects which implement IRmiCacheListener are remote - * listeners to cache changes. - * + * Used to receive a cache event notification. + *

+ * Note: objects which implement this interface are local listeners to cache changes, whereas + * objects which implement IRmiCacheListener are remote listeners to cache changes. */ public interface ICacheListener { - /** Notifies the subscribers for a cache entry update. + /** + * Notifies the subscribers for a cache entry update. + *

* @param item - * @throws IOException*/ + * @throws IOException + */ public void handlePut( ICacheElement item ) throws IOException; - /** Notifies the subscribers for a cache entry removal. + /** + * Notifies the subscribers for a cache entry removal. + *

* @param cacheName * @param key - * @throws IOException*/ + * @throws IOException + */ public void handleRemove( String cacheName, Serializable key ) throws IOException; - /** Notifies the subscribers for a cache remove-all. + /** + * Notifies the subscribers for a cache remove-all. + *

* @param cacheName - * @throws IOException*/ + * @throws IOException + */ public void handleRemoveAll( String cacheName ) throws IOException; - /** Notifies the subscribers for freeing up the named cache. + /** + * Notifies the subscribers for freeing up the named cache. + *

* @param cacheName - * @throws IOException*/ + * @throws IOException + */ public void handleDispose( String cacheName ) throws IOException; /** - * Notifies the subscribers for releasing all caches. - * - * @param id - * The new listenerId value - */ - // public void handleRelease() throws IOException; - /** * sets unique identifier of listener home - * - * @param id - * The new listenerId value + *

+ * @param id The new listenerId value * @throws IOException */ public void setListenerId( long id ) @@ -76,11 +78,10 @@ /** * Gets the listenerId attribute of the ICacheListener object - * + *

* @return The listenerId value * @throws IOException */ public long getListenerId() throws IOException; - } Added: jakarta/jcs/trunk/src/test/org/apache/jcs/engine/CacheEventQueueFactoryUnitTest.java URL: http://svn.apache.org/viewvc/jakarta/jcs/trunk/src/test/org/apache/jcs/engine/CacheEventQueueFactoryUnitTest.java?rev=703528&view=auto ============================================================================== --- jakarta/jcs/trunk/src/test/org/apache/jcs/engine/CacheEventQueueFactoryUnitTest.java (added) +++ jakarta/jcs/trunk/src/test/org/apache/jcs/engine/CacheEventQueueFactoryUnitTest.java Fri Oct 10 10:35:38 2008 @@ -0,0 +1,66 @@ +package org.apache.jcs.engine; + +import org.apache.jcs.auxiliary.remote.MockRemoteCacheListener; +import org.apache.jcs.engine.behavior.ICacheEventQueue; +import org.apache.jcs.engine.behavior.ICacheListener; + +import junit.framework.TestCase; + +/** Unit tests for the CacheEventQueueFactory */ +public class CacheEventQueueFactoryUnitTest + extends TestCase +{ + /** Test create */ + public void testCreateCacheEventQueue_Single() + { + // SETUP + String eventQueueType = ICacheEventQueue.SINGLE_QUEUE_TYPE; + ICacheListener listener = new MockRemoteCacheListener(); + long listenerId = 1; + + CacheEventQueueFactory factory = new CacheEventQueueFactory(); + + // DO WORK + ICacheEventQueue result = factory.createCacheEventQueue( listener, listenerId, "cacheName", "threadPoolName", eventQueueType ); + + // VERIFY + assertNotNull( "Should have a result", result ); + assertTrue( "Wrong type", result instanceof CacheEventQueue ); + } + + /** Test create */ + public void testCreateCacheEventQueue_Pooled() + { + // SETUP + String eventQueueType = ICacheEventQueue.POOLED_QUEUE_TYPE; + ICacheListener listener = new MockRemoteCacheListener(); + long listenerId = 1; + + CacheEventQueueFactory factory = new CacheEventQueueFactory(); + + // DO WORK + ICacheEventQueue result = factory.createCacheEventQueue( listener, listenerId, "cacheName", "threadPoolName", eventQueueType ); + + // VERIFY + assertNotNull( "Should have a result", result ); + assertTrue( "Wrong type", result instanceof PooledCacheEventQueue ); + } + + /** Test create */ + public void testCreateCacheEventQueue_Custom() + { + // SETUP + String eventQueueType = MockCacheEventQueue.class.getName(); + ICacheListener listener = new MockRemoteCacheListener(); + long listenerId = 1; + + CacheEventQueueFactory factory = new CacheEventQueueFactory(); + + // DO WORK + ICacheEventQueue result = factory.createCacheEventQueue( listener, listenerId, "cacheName", "threadPoolName", eventQueueType ); + + // VERIFY + assertNotNull( "Should have a result", result ); + assertTrue( "Wrong type: " + result, result instanceof MockCacheEventQueue ); + } +} \ No newline at end of file Added: jakarta/jcs/trunk/src/test/org/apache/jcs/engine/MockCacheEventQueue.java URL: http://svn.apache.org/viewvc/jakarta/jcs/trunk/src/test/org/apache/jcs/engine/MockCacheEventQueue.java?rev=703528&view=auto ============================================================================== --- jakarta/jcs/trunk/src/test/org/apache/jcs/engine/MockCacheEventQueue.java (added) +++ jakarta/jcs/trunk/src/test/org/apache/jcs/engine/MockCacheEventQueue.java Fri Oct 10 10:35:38 2008 @@ -0,0 +1,14 @@ +package org.apache.jcs.engine; + +import org.apache.jcs.auxiliary.remote.MockRemoteCacheListener; + +/** For testing the factory */ +public class MockCacheEventQueue + extends CacheEventQueue +{ + /** junk */ + public MockCacheEventQueue() + { + super( new MockRemoteCacheListener(), 1, null, 1, 1 ); + } +} --------------------------------------------------------------------- To unsubscribe, e-mail: jcs-dev-unsubscribe@jakarta.apache.org For additional commands, e-mail: jcs-dev-help@jakarta.apache.org