Author: tv Date: Sun Sep 25 12:12:01 2016 New Revision: 1762194 URL: http://svn.apache.org/viewvc?rev=1762194&view=rev Log: JCS-130: Simplify RemoteHttpCacheFactory & friends. Get rid of criss-cross static calls. Remote RemoteHttpCacheManager
Added: commons/proper/jcs/trunk/commons-jcs-core/src/test/java/org/apache/commons/jcs/auxiliary/remote/http/client/RemoteHttpCacheFactoryUnitTest.java - copied, changed from r1749389, commons/proper/jcs/trunk/commons-jcs-core/src/test/java/org/apache/commons/jcs/auxiliary/remote/http/client/RemoteHttpCacheManagerUnitTest.java Removed: commons/proper/jcs/trunk/commons-jcs-core/src/main/java/org/apache/commons/jcs/auxiliary/remote/http/client/RemoteHttpCacheManager.java commons/proper/jcs/trunk/commons-jcs-core/src/test/java/org/apache/commons/jcs/auxiliary/remote/http/client/RemoteHttpCacheManagerUnitTest.java Modified: commons/proper/jcs/trunk/commons-jcs-core/src/main/java/org/apache/commons/jcs/auxiliary/remote/AbstractRemoteCacheNoWaitFacade.java commons/proper/jcs/trunk/commons-jcs-core/src/main/java/org/apache/commons/jcs/auxiliary/remote/RemoteCacheManager.java commons/proper/jcs/trunk/commons-jcs-core/src/main/java/org/apache/commons/jcs/auxiliary/remote/RemoteCacheNoWaitFacade.java commons/proper/jcs/trunk/commons-jcs-core/src/main/java/org/apache/commons/jcs/auxiliary/remote/http/client/RemoteHttpCache.java commons/proper/jcs/trunk/commons-jcs-core/src/main/java/org/apache/commons/jcs/auxiliary/remote/http/client/RemoteHttpCacheFactory.java commons/proper/jcs/trunk/commons-jcs-core/src/main/java/org/apache/commons/jcs/auxiliary/remote/http/client/RemoteHttpCacheMonitor.java Modified: commons/proper/jcs/trunk/commons-jcs-core/src/main/java/org/apache/commons/jcs/auxiliary/remote/AbstractRemoteCacheNoWaitFacade.java URL: http://svn.apache.org/viewvc/commons/proper/jcs/trunk/commons-jcs-core/src/main/java/org/apache/commons/jcs/auxiliary/remote/AbstractRemoteCacheNoWaitFacade.java?rev=1762194&r1=1762193&r2=1762194&view=diff ============================================================================== --- commons/proper/jcs/trunk/commons-jcs-core/src/main/java/org/apache/commons/jcs/auxiliary/remote/AbstractRemoteCacheNoWaitFacade.java (original) +++ commons/proper/jcs/trunk/commons-jcs-core/src/main/java/org/apache/commons/jcs/auxiliary/remote/AbstractRemoteCacheNoWaitFacade.java Sun Sep 25 12:12:01 2016 @@ -50,7 +50,7 @@ public abstract class AbstractRemoteCach private static final Log log = LogFactory.getLog( AbstractRemoteCacheNoWaitFacade.class ); /** The connection to a remote server, or a zombie. */ - private List<RemoteCacheNoWait<K, V>> noWaits; + protected List<RemoteCacheNoWait<K, V>> noWaits; /** holds failover and cluster information */ private IRemoteCacheAttributes remoteCacheAttributes; @@ -76,7 +76,6 @@ public abstract class AbstractRemoteCach for (ICache<K, V> nw : noWaits) { RemoteCacheNoWait<K,V> rcnw = (RemoteCacheNoWait<K,V>) nw; - ((RemoteCache<K, V>)rcnw.getRemoteCache()).setFacade(this); this.noWaits.add(rcnw); } this.remoteCacheAttributes = rca; Modified: commons/proper/jcs/trunk/commons-jcs-core/src/main/java/org/apache/commons/jcs/auxiliary/remote/RemoteCacheManager.java URL: http://svn.apache.org/viewvc/commons/proper/jcs/trunk/commons-jcs-core/src/main/java/org/apache/commons/jcs/auxiliary/remote/RemoteCacheManager.java?rev=1762194&r1=1762193&r2=1762194&view=diff ============================================================================== --- commons/proper/jcs/trunk/commons-jcs-core/src/main/java/org/apache/commons/jcs/auxiliary/remote/RemoteCacheManager.java (original) +++ commons/proper/jcs/trunk/commons-jcs-core/src/main/java/org/apache/commons/jcs/auxiliary/remote/RemoteCacheManager.java Sun Sep 25 12:12:01 2016 @@ -54,7 +54,8 @@ public class RemoteCacheManager private static final Log log = LogFactory.getLog( RemoteCacheManager.class ); /** Contains instances of RemoteCacheNoWait managed by a RemoteCacheManager instance. */ - final ConcurrentMap<String, RemoteCacheNoWait<?, ?>> caches = new ConcurrentHashMap<String, RemoteCacheNoWait<?, ?>>(); + private final ConcurrentMap<String, RemoteCacheNoWait<?, ?>> caches = + new ConcurrentHashMap<String, RemoteCacheNoWait<?, ?>>(); /** Lock for initialization of caches */ private ReentrantLock cacheLock = new ReentrantLock(); @@ -281,7 +282,7 @@ public class RemoteCacheManager * @param cattr the cache configuration * @return the instance */ - private <K, V> RemoteCacheNoWait<K, V> newRemoteCacheNoWait(IRemoteCacheAttributes cattr) + protected <K, V> RemoteCacheNoWait<K, V> newRemoteCacheNoWait(IRemoteCacheAttributes cattr) { RemoteCacheNoWait<K, V> remoteCacheNoWait; // create a listener first and pass it to the remotecache @@ -339,6 +340,8 @@ public class RemoteCacheManager log.error( "Problem releasing " + c.getCacheName(), ex ); } } + + caches.clear(); } finally { Modified: commons/proper/jcs/trunk/commons-jcs-core/src/main/java/org/apache/commons/jcs/auxiliary/remote/RemoteCacheNoWaitFacade.java URL: http://svn.apache.org/viewvc/commons/proper/jcs/trunk/commons-jcs-core/src/main/java/org/apache/commons/jcs/auxiliary/remote/RemoteCacheNoWaitFacade.java?rev=1762194&r1=1762193&r2=1762194&view=diff ============================================================================== --- commons/proper/jcs/trunk/commons-jcs-core/src/main/java/org/apache/commons/jcs/auxiliary/remote/RemoteCacheNoWaitFacade.java (original) +++ commons/proper/jcs/trunk/commons-jcs-core/src/main/java/org/apache/commons/jcs/auxiliary/remote/RemoteCacheNoWaitFacade.java Sun Sep 25 12:12:01 2016 @@ -66,6 +66,12 @@ public class RemoteCacheNoWaitFacade<K, { super( noWaits, rca, cacheMgr, cacheEventLogger, elementSerializer ); this.cacheFactory = cacheFactory; + + for (RemoteCacheNoWait<K,V> rcnw : this.noWaits) + { + ((RemoteCache<K, V>)rcnw.getRemoteCache()).setFacade(this); + this.noWaits.add(rcnw); + } } /** Modified: commons/proper/jcs/trunk/commons-jcs-core/src/main/java/org/apache/commons/jcs/auxiliary/remote/http/client/RemoteHttpCache.java URL: http://svn.apache.org/viewvc/commons/proper/jcs/trunk/commons-jcs-core/src/main/java/org/apache/commons/jcs/auxiliary/remote/http/client/RemoteHttpCache.java?rev=1762194&r1=1762193&r2=1762194&view=diff ============================================================================== --- commons/proper/jcs/trunk/commons-jcs-core/src/main/java/org/apache/commons/jcs/auxiliary/remote/http/client/RemoteHttpCache.java (original) +++ commons/proper/jcs/trunk/commons-jcs-core/src/main/java/org/apache/commons/jcs/auxiliary/remote/http/client/RemoteHttpCache.java Sun Sep 25 12:12:01 2016 @@ -1,5 +1,7 @@ package org.apache.commons.jcs.auxiliary.remote.http.client; +import java.io.IOException; + /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file @@ -26,8 +28,6 @@ import org.apache.commons.jcs.engine.beh import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; -import java.io.IOException; - /** * This uses an http client as the service. */ @@ -37,6 +37,9 @@ public class RemoteHttpCache<K, V> /** The logger. */ private static final Log log = LogFactory.getLog( RemoteHttpCache.class ); + /** for error notifications */ + private RemoteHttpCacheMonitor monitor; + /** Keep the child copy here for the restore process. */ private RemoteHttpCacheAttributes remoteHttpCacheAttributes; @@ -49,13 +52,15 @@ public class RemoteHttpCache<K, V> * @param remoteHttpCacheAttributes * @param remote * @param listener + * @param monitor the cache monitor */ public RemoteHttpCache( RemoteHttpCacheAttributes remoteHttpCacheAttributes, ICacheServiceNonLocal<K, V> remote, - IRemoteCacheListener<K, V> listener ) + IRemoteCacheListener<K, V> listener, RemoteHttpCacheMonitor monitor ) { super( remoteHttpCacheAttributes, remote, listener ); - setRemoteHttpCacheAttributes( remoteHttpCacheAttributes ); + this.remoteHttpCacheAttributes = remoteHttpCacheAttributes; + this.monitor = monitor; } /** @@ -79,7 +84,7 @@ public class RemoteHttpCache<K, V> setRemoteCacheService( new ZombieCacheServiceNonLocal<K, V>( getRemoteCacheAttributes().getZombieQueueMaxSize() ) ); - RemoteHttpCacheMonitor.getInstance().notifyError( this ); + monitor.notifyError( this ); } if ( ex instanceof IOException ) @@ -99,14 +104,6 @@ public class RemoteHttpCache<K, V> } /** - * @param remoteHttpCacheAttributes the remoteHttpCacheAttributes to set - */ - public void setRemoteHttpCacheAttributes( RemoteHttpCacheAttributes remoteHttpCacheAttributes ) - { - this.remoteHttpCacheAttributes = remoteHttpCacheAttributes; - } - - /** * @return the remoteHttpCacheAttributes */ public RemoteHttpCacheAttributes getRemoteHttpCacheAttributes() Modified: commons/proper/jcs/trunk/commons-jcs-core/src/main/java/org/apache/commons/jcs/auxiliary/remote/http/client/RemoteHttpCacheFactory.java URL: http://svn.apache.org/viewvc/commons/proper/jcs/trunk/commons-jcs-core/src/main/java/org/apache/commons/jcs/auxiliary/remote/http/client/RemoteHttpCacheFactory.java?rev=1762194&r1=1762193&r2=1762194&view=diff ============================================================================== --- commons/proper/jcs/trunk/commons-jcs-core/src/main/java/org/apache/commons/jcs/auxiliary/remote/http/client/RemoteHttpCacheFactory.java (original) +++ commons/proper/jcs/trunk/commons-jcs-core/src/main/java/org/apache/commons/jcs/auxiliary/remote/http/client/RemoteHttpCacheFactory.java Sun Sep 25 12:12:01 2016 @@ -1,36 +1,18 @@ package org.apache.commons.jcs.auxiliary.remote.http.client; -/* - * 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 java.util.ArrayList; -import java.util.HashMap; - import org.apache.commons.jcs.auxiliary.AbstractAuxiliaryCacheFactory; import org.apache.commons.jcs.auxiliary.AuxiliaryCache; import org.apache.commons.jcs.auxiliary.AuxiliaryCacheAttributes; -import org.apache.commons.jcs.auxiliary.remote.RemoteCacheNoWaitFacade; +import org.apache.commons.jcs.auxiliary.remote.RemoteCacheNoWait; +import org.apache.commons.jcs.auxiliary.remote.behavior.IRemoteCacheClient; +import org.apache.commons.jcs.auxiliary.remote.http.client.behavior.IRemoteHttpCacheClient; import org.apache.commons.jcs.auxiliary.remote.server.behavior.RemoteType; -import org.apache.commons.jcs.engine.behavior.ICache; import org.apache.commons.jcs.engine.behavior.ICompositeCacheManager; import org.apache.commons.jcs.engine.behavior.IElementSerializer; import org.apache.commons.jcs.engine.logging.behavior.ICacheEventLogger; +import org.apache.commons.jcs.utils.config.OptionConverter; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; /** * The RemoteCacheFactory creates remote caches for the cache hub. It returns a no wait facade which @@ -41,9 +23,11 @@ import org.apache.commons.jcs.engine.log public class RemoteHttpCacheFactory extends AbstractAuxiliaryCacheFactory { - /** store reference of facades to initiate failover */ - private static final HashMap<String, RemoteCacheNoWaitFacade<?, ?>> facades = - new HashMap<String, RemoteCacheNoWaitFacade<?, ?>>(); + /** The logger */ + private static final Log log = LogFactory.getLog( RemoteHttpCacheFactory.class ); + + /** Monitor thread instance */ + private RemoteHttpCacheMonitor monitor; /** * For LOCAL clients we get a handle to all the failovers, but we do not register a listener @@ -64,29 +48,82 @@ public class RemoteHttpCacheFactory { RemoteHttpCacheAttributes rca = (RemoteHttpCacheAttributes) iaca; - ArrayList<ICache<K, V>> noWaits = new ArrayList<ICache<K, V>>(); - - RemoteHttpCacheManager rcm = RemoteHttpCacheManager.getInstance( cacheMgr, cacheEventLogger, elementSerializer ); // TODO, use the configured value. rca.setRemoteType( RemoteType.LOCAL ); - ICache<K, V> ic = rcm.getCache( rca ); - noWaits.add( ic ); - // FIXME Remove null parameter - RemoteCacheNoWaitFacade<K, V> rcnwf = - new RemoteCacheNoWaitFacade<K, V>(noWaits, rca, cacheMgr, cacheEventLogger, elementSerializer, null ); + RemoteHttpClientListener<K, V> listener = new RemoteHttpClientListener<K, V>( rca, cacheMgr, elementSerializer ); + + IRemoteHttpCacheClient<K, V> remoteService = createRemoteHttpCacheClientForAttributes(rca); - getFacades().put( rca.getCacheName(), rcnwf ); + IRemoteCacheClient<K, V> remoteCacheClient = + new RemoteHttpCache<K, V>( rca, remoteService, listener, monitor ); + remoteCacheClient.setCacheEventLogger( cacheEventLogger ); + remoteCacheClient.setElementSerializer( elementSerializer ); - return rcnwf; + RemoteCacheNoWait<K, V> remoteCacheNoWait = new RemoteCacheNoWait<K, V>( remoteCacheClient ); + remoteCacheNoWait.setCacheEventLogger( cacheEventLogger ); + remoteCacheNoWait.setElementSerializer( elementSerializer ); + + return remoteCacheNoWait; } /** - * The facades are what the cache hub talks to. - * @return Returns the facades. + * This is an extension point. The manager and other classes will only create + * RemoteHttpCacheClient through this method. + + * @param cattr the cache configuration + * @return the client instance */ - public static HashMap<String, RemoteCacheNoWaitFacade<?, ?>> getFacades() + protected <V, K> IRemoteHttpCacheClient<K, V> createRemoteHttpCacheClientForAttributes(RemoteHttpCacheAttributes cattr) { - return facades; + IRemoteHttpCacheClient<K, V> remoteService = OptionConverter.instantiateByClassName( cattr + .getRemoteHttpClientClassName(), null ); + + if ( remoteService == null ) + { + if ( log.isInfoEnabled() ) + { + log.info( "Creating the default client for " + cattr.getCacheName()); + } + remoteService = new RemoteHttpCacheClient<K, V>( ); + } + + remoteService.initialize( cattr ); + return remoteService; + } + + /** + * @see org.apache.commons.jcs.auxiliary.AbstractAuxiliaryCacheFactory#initialize() + */ + @Override + public void initialize() + { + super.initialize(); + monitor = new RemoteHttpCacheMonitor(this); + monitor.setDaemon(true); + monitor.start(); + } + + /** + * @see org.apache.commons.jcs.auxiliary.AbstractAuxiliaryCacheFactory#dispose() + */ + @Override + public void dispose() + { + if (monitor != null) + { + monitor.notifyShutdown(); + try + { + monitor.join(5000); + } + catch (InterruptedException e) + { + // swallow + } + monitor = null; + } + + super.dispose(); } } Modified: commons/proper/jcs/trunk/commons-jcs-core/src/main/java/org/apache/commons/jcs/auxiliary/remote/http/client/RemoteHttpCacheMonitor.java URL: http://svn.apache.org/viewvc/commons/proper/jcs/trunk/commons-jcs-core/src/main/java/org/apache/commons/jcs/auxiliary/remote/http/client/RemoteHttpCacheMonitor.java?rev=1762194&r1=1762193&r2=1762194&view=diff ============================================================================== --- commons/proper/jcs/trunk/commons-jcs-core/src/main/java/org/apache/commons/jcs/auxiliary/remote/http/client/RemoteHttpCacheMonitor.java (original) +++ commons/proper/jcs/trunk/commons-jcs-core/src/main/java/org/apache/commons/jcs/auxiliary/remote/http/client/RemoteHttpCacheMonitor.java Sun Sep 25 12:12:01 2016 @@ -34,35 +34,23 @@ import org.apache.commons.jcs.engine.Cac */ public class RemoteHttpCacheMonitor extends AbstractAuxiliaryCacheMonitor { - /** The remote cache that we are monitoring */ - private static RemoteHttpCacheMonitor instance; - /** Set of remote caches to monitor. This are added on error, if not before. */ - private final ConcurrentHashMap<RemoteHttpCache<?, ?>, RemoteHttpCache<?, ?>> remoteHttpCaches = - new ConcurrentHashMap<RemoteHttpCache<?, ?>, RemoteHttpCache<?, ?>>(); + private final ConcurrentHashMap<RemoteHttpCache<?, ?>, RemoteHttpCache<?, ?>> remoteHttpCaches; - /** Constructor for the RemoteCacheMonitor object */ - private RemoteHttpCacheMonitor() - { - super("JCS-RemoteHttpCacheMonitor"); - setIdlePeriod(3000L); - } + /** Factory instance */ + private RemoteHttpCacheFactory factory = null; /** - * Returns the singleton instance. - * <p> - * @return The instance value + * Constructor for the RemoteCacheMonitor object + * + * @param factory the factory to set */ - public static RemoteHttpCacheMonitor getInstance() + public RemoteHttpCacheMonitor(RemoteHttpCacheFactory factory) { - synchronized ( RemoteHttpCacheMonitor.class ) - { - if ( instance == null ) - { - return instance = new RemoteHttpCacheMonitor(); - } - } - return instance; + super("JCS-RemoteHttpCacheMonitor"); + this.factory = factory; + this.remoteHttpCaches = new ConcurrentHashMap<RemoteHttpCache<?, ?>, RemoteHttpCache<?, ?>>(); + setIdlePeriod(3000L); } /** @@ -94,13 +82,18 @@ public class RemoteHttpCacheMonitor exte // performance reasons. // If exception is thrown owing to synchronization, // just skip the monitoring until the next round. - /** Main processing method for the RemoteCacheMonitor object */ + /** Main processing method for the RemoteHttpCacheMonitor object */ @Override - public void doWork() + protected void doWork() { + // If no factory has been set, skip + if (factory == null) + { + return; + } + // If any cache is in error, it strongly suggests all caches - // managed by the - // same RmicCacheManager instance are in error. So we fix + // managed by the same RmicCacheManager instance are in error. So we fix // them once and for all. for (RemoteHttpCache<?, ?> remoteCache : this.remoteHttpCaches.values()) { @@ -110,8 +103,8 @@ public class RemoteHttpCacheMonitor exte { RemoteHttpCacheAttributes attributes = remoteCache.getRemoteHttpCacheAttributes(); - IRemoteHttpCacheClient<Serializable, Serializable> remoteService = RemoteHttpCacheManager.getInstance() - .createRemoteHttpCacheClientForAttributes( attributes ); + IRemoteHttpCacheClient<Serializable, Serializable> remoteService = + factory.createRemoteHttpCacheClientForAttributes( attributes ); if ( log.isInfoEnabled() ) { Copied: commons/proper/jcs/trunk/commons-jcs-core/src/test/java/org/apache/commons/jcs/auxiliary/remote/http/client/RemoteHttpCacheFactoryUnitTest.java (from r1749389, commons/proper/jcs/trunk/commons-jcs-core/src/test/java/org/apache/commons/jcs/auxiliary/remote/http/client/RemoteHttpCacheManagerUnitTest.java) URL: http://svn.apache.org/viewvc/commons/proper/jcs/trunk/commons-jcs-core/src/test/java/org/apache/commons/jcs/auxiliary/remote/http/client/RemoteHttpCacheFactoryUnitTest.java?p2=commons/proper/jcs/trunk/commons-jcs-core/src/test/java/org/apache/commons/jcs/auxiliary/remote/http/client/RemoteHttpCacheFactoryUnitTest.java&p1=commons/proper/jcs/trunk/commons-jcs-core/src/test/java/org/apache/commons/jcs/auxiliary/remote/http/client/RemoteHttpCacheManagerUnitTest.java&r1=1749389&r2=1762194&rev=1762194&view=diff ============================================================================== --- commons/proper/jcs/trunk/commons-jcs-core/src/test/java/org/apache/commons/jcs/auxiliary/remote/http/client/RemoteHttpCacheManagerUnitTest.java (original) +++ commons/proper/jcs/trunk/commons-jcs-core/src/test/java/org/apache/commons/jcs/auxiliary/remote/http/client/RemoteHttpCacheFactoryUnitTest.java Sun Sep 25 12:12:01 2016 @@ -1,5 +1,12 @@ package org.apache.commons.jcs.auxiliary.remote.http.client; +import org.apache.commons.jcs.auxiliary.AuxiliaryCache; +import org.apache.commons.jcs.auxiliary.remote.http.client.behavior.IRemoteHttpCacheClient; +import org.apache.commons.jcs.engine.behavior.ICompositeCacheManager; +import org.apache.commons.jcs.engine.behavior.IElementSerializer; +import org.apache.commons.jcs.engine.control.MockCompositeCacheManager; +import org.apache.commons.jcs.engine.logging.behavior.ICacheEventLogger; + /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file @@ -20,34 +27,23 @@ package org.apache.commons.jcs.auxiliary */ import junit.framework.TestCase; -import org.apache.commons.jcs.auxiliary.AuxiliaryCache; -import org.apache.commons.jcs.auxiliary.remote.http.client.behavior.IRemoteHttpCacheClient; -import org.apache.commons.jcs.engine.behavior.ICompositeCacheManager; -import org.apache.commons.jcs.engine.behavior.IElementSerializer; -import org.apache.commons.jcs.engine.control.MockCompositeCacheManager; -import org.apache.commons.jcs.engine.logging.behavior.ICacheEventLogger; /** Unit tests for the manager. */ -public class RemoteHttpCacheManagerUnitTest +public class RemoteHttpCacheFactoryUnitTest extends TestCase { /** Verify that we get the default. */ public void testCreateRemoteHttpCacheClient_Bad() { // SETUP - ICompositeCacheManager cacheMgr = new MockCompositeCacheManager(); - ICacheEventLogger cacheEventLogger = null; - IElementSerializer elementSerializer = null; - String remoteHttpClientClassName = "junk"; RemoteHttpCacheAttributes cattr = new RemoteHttpCacheAttributes(); cattr.setRemoteHttpClientClassName( remoteHttpClientClassName ); - RemoteHttpCacheManager manager = RemoteHttpCacheManager.getInstance( cacheMgr, cacheEventLogger, - elementSerializer ); + RemoteHttpCacheFactory factory = new RemoteHttpCacheFactory(); // DO WORK - IRemoteHttpCacheClient<String, String> result = manager.createRemoteHttpCacheClientForAttributes( cattr ); + IRemoteHttpCacheClient<String, String> result = factory.createRemoteHttpCacheClientForAttributes( cattr ); // VEIFY assertNotNull( "Should have a cache.", result ); @@ -56,20 +52,14 @@ public class RemoteHttpCacheManagerUnitT } /** Verify that we get the default. */ - public void testCreateRemoteHttpCacheClient_deafult() + public void testCreateRemoteHttpCacheClient_default() { // SETUP - ICompositeCacheManager cacheMgr = new MockCompositeCacheManager(); - ICacheEventLogger cacheEventLogger = null; - IElementSerializer elementSerializer = null; - RemoteHttpCacheAttributes cattr = new RemoteHttpCacheAttributes(); - - RemoteHttpCacheManager manager = RemoteHttpCacheManager.getInstance( cacheMgr, cacheEventLogger, - elementSerializer ); + RemoteHttpCacheFactory factory = new RemoteHttpCacheFactory(); // DO WORK - IRemoteHttpCacheClient<String, String> result = manager.createRemoteHttpCacheClientForAttributes( cattr ); + IRemoteHttpCacheClient<String, String> result = factory.createRemoteHttpCacheClientForAttributes( cattr ); // VEIFY assertNotNull( "Should have a cache.", result ); @@ -85,12 +75,10 @@ public class RemoteHttpCacheManagerUnitT IElementSerializer elementSerializer = null; RemoteHttpCacheAttributes cattr = new RemoteHttpCacheAttributes(); - - RemoteHttpCacheManager manager = RemoteHttpCacheManager.getInstance( cacheMgr, cacheEventLogger, - elementSerializer ); + RemoteHttpCacheFactory factory = new RemoteHttpCacheFactory(); // DO WORK - AuxiliaryCache<String, String> result = manager.getCache( cattr ); + AuxiliaryCache<String, String> result = factory.createCache(cattr, cacheMgr, cacheEventLogger, elementSerializer); // VEIFY assertNotNull( "Should have a cache.", result );