commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From t.@apache.org
Subject svn commit: r1762121 - in /commons/proper/jcs/trunk/commons-jcs-core/src: main/java/org/apache/commons/jcs/auxiliary/remote/ main/java/org/apache/commons/jcs/auxiliary/remote/http/client/ main/java/org/apache/commons/jcs/auxiliary/remote/server/ test/j...
Date Sat, 24 Sep 2016 12:51:28 GMT
Author: tv
Date: Sat Sep 24 12:51:28 2016
New Revision: 1762121

URL: http://svn.apache.org/viewvc?rev=1762121&view=rev
Log:
JCS-130: Simplify RemoteCacheFactory & friends. Get rid of criss-cross static calls

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/RemoteCache.java
    commons/proper/jcs/trunk/commons-jcs-core/src/main/java/org/apache/commons/jcs/auxiliary/remote/RemoteCacheFactory.java
    commons/proper/jcs/trunk/commons-jcs-core/src/main/java/org/apache/commons/jcs/auxiliary/remote/RemoteCacheFailoverRunner.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/RemoteHttpCacheFactory.java
    commons/proper/jcs/trunk/commons-jcs-core/src/main/java/org/apache/commons/jcs/auxiliary/remote/server/RemoteCacheServerFactory.java
    commons/proper/jcs/trunk/commons-jcs-core/src/test/java/org/apache/commons/jcs/auxiliary/remote/TestRemoteCache.java
    commons/proper/jcs/trunk/commons-jcs-core/src/test/java/org/apache/commons/jcs/auxiliary/remote/server/BasicRemoteCacheClientServerUnitTest.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=1762121&r1=1762120&r2=1762121&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
Sat Sep 24 12:51:28 2016
@@ -75,7 +75,9 @@ public abstract class AbstractRemoteCach
         this.noWaits = new ArrayList<RemoteCacheNoWait<K,V>>();
         for (ICache<K, V> nw : noWaits)
         {
-            this.noWaits.add((RemoteCacheNoWait<K,V>) nw);
+            RemoteCacheNoWait<K,V> rcnw = (RemoteCacheNoWait<K,V>) nw;
+            ((RemoteCache<K, V>)rcnw.getRemoteCache()).setFacade(this);
+            this.noWaits.add(rcnw);
         }
         this.remoteCacheAttributes = rca;
         setCacheEventLogger( cacheEventLogger );

Modified: commons/proper/jcs/trunk/commons-jcs-core/src/main/java/org/apache/commons/jcs/auxiliary/remote/RemoteCache.java
URL: http://svn.apache.org/viewvc/commons/proper/jcs/trunk/commons-jcs-core/src/main/java/org/apache/commons/jcs/auxiliary/remote/RemoteCache.java?rev=1762121&r1=1762120&r2=1762121&view=diff
==============================================================================
--- commons/proper/jcs/trunk/commons-jcs-core/src/main/java/org/apache/commons/jcs/auxiliary/remote/RemoteCache.java
(original)
+++ commons/proper/jcs/trunk/commons-jcs-core/src/main/java/org/apache/commons/jcs/auxiliary/remote/RemoteCache.java
Sat Sep 24 12:51:28 2016
@@ -49,6 +49,9 @@ public class RemoteCache<K, V>
     /** for error notifications */
     private RemoteCacheMonitor monitor;
 
+    /** back link for failover initiation */
+    private AbstractRemoteCacheNoWaitFacade<K, V> facade;
+
     /**
      * Constructor for the RemoteCache object. This object communicates with a remote cache
server.
      * One of these exists for each region. This also holds a reference to a listener. The
same
@@ -100,6 +103,16 @@ public class RemoteCache<K, V>
     }
 
     /**
+     * Set facade
+     *
+     * @param facade the facade to set
+     */
+    protected void setFacade(AbstractRemoteCacheNoWaitFacade<K, V> facade)
+    {
+        this.facade = facade;
+    }
+
+    /**
      * Handles exception by disabling the remote cache service before re-throwing the exception
in
      * the form of an IOException.
      * <p>
@@ -128,15 +141,12 @@ public class RemoteCache<K, V>
         // process.
         monitor.notifyError();
 
-        // initiate failover if local
-        RemoteCacheNoWaitFacade<K, V> rcnwf = RemoteCacheFactory.getFacade( getRemoteCacheAttributes().getCacheName()
);
-
         if ( log.isDebugEnabled() )
         {
-            log.debug( "Initiating failover, rcnwf = " + rcnwf );
+            log.debug( "Initiating failover, rcnwf = " + facade );
         }
 
-        if ( rcnwf != null && rcnwf.getAuxiliaryCacheAttributes().getRemoteType()
== RemoteType.LOCAL )
+        if ( facade != null && facade.getAuxiliaryCacheAttributes().getRemoteType()
== RemoteType.LOCAL )
         {
             if ( log.isDebugEnabled() )
             {
@@ -144,7 +154,7 @@ public class RemoteCache<K, V>
             }
             // may need to remove the noWait index here. It will be 0 if it is
             // local since there is only 1 possible listener.
-            rcnwf.failover( rcnwf.getPrimaryServer() );
+            facade.failover( facade.getPrimaryServer() );
         }
 
         if ( ex instanceof IOException )

Modified: commons/proper/jcs/trunk/commons-jcs-core/src/main/java/org/apache/commons/jcs/auxiliary/remote/RemoteCacheFactory.java
URL: http://svn.apache.org/viewvc/commons/proper/jcs/trunk/commons-jcs-core/src/main/java/org/apache/commons/jcs/auxiliary/remote/RemoteCacheFactory.java?rev=1762121&r1=1762120&r2=1762121&view=diff
==============================================================================
--- commons/proper/jcs/trunk/commons-jcs-core/src/main/java/org/apache/commons/jcs/auxiliary/remote/RemoteCacheFactory.java
(original)
+++ commons/proper/jcs/trunk/commons-jcs-core/src/main/java/org/apache/commons/jcs/auxiliary/remote/RemoteCacheFactory.java
Sat Sep 24 12:51:28 2016
@@ -46,17 +46,14 @@ import org.apache.commons.jcs.engine.log
 public class RemoteCacheFactory
     extends AbstractAuxiliaryCacheFactory
 {
-    /** store reference of facades to initiate failover */
-    private static ConcurrentMap<String, RemoteCacheNoWaitFacade<?, ?>> facades;
-
     /** Monitor thread */
-    private static RemoteCacheMonitor monitor;
+    private RemoteCacheMonitor monitor;
 
     /** Contains mappings of RemoteLocation instance to RemoteCacheManager instance. */
-    private static ConcurrentMap<RemoteLocation, RemoteCacheManager> managers;
+    private ConcurrentMap<RemoteLocation, RemoteCacheManager> managers;
 
     /** Lock for initialization of manager instances */
-    private static Lock managerLock;
+    private Lock managerLock;
 
     /**
      * For LOCAL clients we get a handle to all the failovers, but we do not register a listener
@@ -156,9 +153,7 @@ public class RemoteCacheFactory
         }
 
         RemoteCacheNoWaitFacade<K, V> rcnwf =
-            new RemoteCacheNoWaitFacade<K, V>(noWaits, rca, cacheMgr, cacheEventLogger,
elementSerializer );
-
-        facades.put( rca.getCacheName(), rcnwf );
+            new RemoteCacheNoWaitFacade<K, V>(noWaits, rca, cacheMgr, cacheEventLogger,
elementSerializer, this );
 
         return rcnwf;
     }
@@ -166,18 +161,6 @@ public class RemoteCacheFactory
     // end createCache
 
     /**
-     * The facades are what the cache hub talks to.
-     *
-     * @param cacheName the name of the  cache facade
-     * @return Returns the facade for the given name.
-     */
-    @SuppressWarnings("unchecked") // Need to cast because of common map for all facades
-    public static <K, V> RemoteCacheNoWaitFacade<K, V> getFacade( String cacheName
)
-    {
-        return (RemoteCacheNoWaitFacade<K, V>) facades.get( cacheName );
-    }
-
-    /**
      * Returns an instance of RemoteCacheManager for the given connection parameters.
      * <p>
      * Host and Port uniquely identify a manager instance.
@@ -186,7 +169,7 @@ public class RemoteCacheFactory
      *
      * @return The instance value or null if no such manager exists
      */
-    public static RemoteCacheManager getManager( IRemoteCacheAttributes cattr )
+    public RemoteCacheManager getManager( IRemoteCacheAttributes cattr )
     {
         if ( cattr.getRemoteLocation() == null )
         {
@@ -213,17 +196,11 @@ public class RemoteCacheFactory
      * @param elementSerializer
      * @return The instance value, never null
      */
-    public static RemoteCacheManager getManager( IRemoteCacheAttributes cattr, ICompositeCacheManager
cacheMgr,
+    public RemoteCacheManager getManager( IRemoteCacheAttributes cattr, ICompositeCacheManager
cacheMgr,
                                                   ICacheEventLogger cacheEventLogger,
                                                   IElementSerializer elementSerializer )
     {
-        if ( cattr.getRemoteLocation() == null )
-        {
-            cattr.setRemoteLocation("", Registry.REGISTRY_PORT);
-        }
-
-        RemoteLocation loc = cattr.getRemoteLocation();
-        RemoteCacheManager ins = managers.get( loc );
+        RemoteCacheManager ins = getManager( cattr );
 
         if ( ins == null )
         {
@@ -231,12 +208,12 @@ public class RemoteCacheFactory
 
             try
             {
-                ins = managers.get( loc );
+                ins = managers.get( cattr.getRemoteLocation() );
 
                 if (ins == null)
                 {
                     ins = new RemoteCacheManager( cattr, cacheMgr, monitor, cacheEventLogger,
elementSerializer);
-                    managers.put( loc, ins );
+                    managers.put( cattr.getRemoteLocation(), ins );
                     monitor.addManager(ins);
                 }
             }
@@ -256,7 +233,6 @@ public class RemoteCacheFactory
 	public void initialize()
 	{
 		super.initialize();
-		facades = new ConcurrentHashMap<String, RemoteCacheNoWaitFacade<?, ?>>();
 
 		managers = new ConcurrentHashMap<RemoteLocation, RemoteCacheManager>();
 		managerLock = new ReentrantLock();
@@ -277,7 +253,6 @@ public class RemoteCacheFactory
 		}
 
 		managers.clear();
-		facades.clear();
 
         if (monitor != null)
         {

Modified: commons/proper/jcs/trunk/commons-jcs-core/src/main/java/org/apache/commons/jcs/auxiliary/remote/RemoteCacheFailoverRunner.java
URL: http://svn.apache.org/viewvc/commons/proper/jcs/trunk/commons-jcs-core/src/main/java/org/apache/commons/jcs/auxiliary/remote/RemoteCacheFailoverRunner.java?rev=1762121&r1=1762120&r2=1762121&view=diff
==============================================================================
--- commons/proper/jcs/trunk/commons-jcs-core/src/main/java/org/apache/commons/jcs/auxiliary/remote/RemoteCacheFailoverRunner.java
(original)
+++ commons/proper/jcs/trunk/commons-jcs-core/src/main/java/org/apache/commons/jcs/auxiliary/remote/RemoteCacheFailoverRunner.java
Sat Sep 24 12:51:28 2016
@@ -52,16 +52,21 @@ public class RemoteCacheFailoverRunner<K
     /** The facade returned to the composite cache. */
     private final RemoteCacheNoWaitFacade<K, V> facade;
 
+    /** Factory instance */
+    private final RemoteCacheFactory cacheFactory;
+
     /**
      * Constructor for the RemoteCacheFailoverRunner object. This allows the
      * FailoverRunner to modify the facade that the CompositeCache references.
      *
      * @param facade the facade the CompositeCache talks to.
+     * @param cacheFactory the cache factory instance
      */
-    public RemoteCacheFailoverRunner( RemoteCacheNoWaitFacade<K, V> facade )
+    public RemoteCacheFailoverRunner( RemoteCacheNoWaitFacade<K, V> facade, RemoteCacheFactory
cacheFactory )
     {
         super("JCS-RemoteCacheFailoverRunner");
         this.facade = facade;
+        this.cacheFactory = cacheFactory;
         setIdlePeriod(20000L);
     }
 
@@ -180,7 +185,7 @@ public class RemoteCacheFailoverRunner<K
 
                     RemoteCacheAttributes rca = (RemoteCacheAttributes) rca0.clone();
                     rca.setRemoteLocation(server);
-                    RemoteCacheManager rcm = RemoteCacheFactory.getManager( rca );
+                    RemoteCacheManager rcm = cacheFactory.getManager( rca );
 
                     if ( log.isDebugEnabled() )
                     {
@@ -294,7 +299,7 @@ public class RemoteCacheFailoverRunner<K
 
         RemoteCacheAttributes rca = (RemoteCacheAttributes) rca0.clone();
         rca.setRemoteLocation(server);
-        RemoteCacheManager rcm = RemoteCacheFactory.getManager( rca );
+        RemoteCacheManager rcm = cacheFactory.getManager( rca );
 
         if (rcm != null)
         {
@@ -336,7 +341,7 @@ public class RemoteCacheFailoverRunner<K
                                 // previous failed over configuration.
                                 RemoteCacheAttributes rcaOld = (RemoteCacheAttributes) rca0.clone();
                                 rcaOld.setRemoteLocation(serverOld);
-                                RemoteCacheManager rcmOld = RemoteCacheFactory.getManager(
rcaOld );
+                                RemoteCacheManager rcmOld = cacheFactory.getManager( rcaOld
);
 
                                 if ( rcmOld != null )
                                 {

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=1762121&r1=1762120&r2=1762121&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
Sat Sep 24 12:51:28 2016
@@ -260,34 +260,7 @@ public class RemoteCacheManager
 
                 if (remoteCacheNoWait == null)
                 {
-                    // create a listener first and pass it to the remotecache
-                    // sender.
-                    RemoteCacheListener<K, V> listener = null;
-                    try
-                    {
-                        listener = new RemoteCacheListener<K, V>( cattr, cacheMgr,
elementSerializer );
-                        addRemoteCacheListener( cattr, listener );
-                    }
-                    catch ( IOException ioe )
-                    {
-                        log.error( "Problem adding listener. Message: " + ioe.getMessage()
-                            + " | RemoteCacheListener = " + listener, ioe );
-                    }
-                    catch ( Exception e )
-                    {
-                        log.error( "Problem adding listener. Message: " + e.getMessage()
+ " | RemoteCacheListener = "
-                            + listener, e );
-                    }
-
-                    IRemoteCacheClient<K, V> remoteCacheClient =
-                        new RemoteCache<K, V>( cattr, (ICacheServiceNonLocal<K,
V>) remoteService, listener, monitor );
-                    remoteCacheClient.setCacheEventLogger( cacheEventLogger );
-                    remoteCacheClient.setElementSerializer( elementSerializer );
-
-                    remoteCacheNoWait = new RemoteCacheNoWait<K, V>( remoteCacheClient
);
-                    remoteCacheNoWait.setCacheEventLogger( cacheEventLogger );
-                    remoteCacheNoWait.setElementSerializer( elementSerializer );
-
+                    remoteCacheNoWait = newRemoteCacheNoWait(cattr);
                     caches.put( cattr.getCacheName(), remoteCacheNoWait );
                 }
             }
@@ -301,6 +274,46 @@ public class RemoteCacheManager
 
         return remoteCacheNoWait;
     }
+
+    /**
+     * Create new RemoteCacheNoWait instance
+     *
+     * @param cattr the cache configuration
+     * @return the instance
+     */
+    private <K, V> RemoteCacheNoWait<K, V> newRemoteCacheNoWait(IRemoteCacheAttributes
cattr)
+    {
+        RemoteCacheNoWait<K, V> remoteCacheNoWait;
+        // create a listener first and pass it to the remotecache
+        // sender.
+        RemoteCacheListener<K, V> listener = null;
+        try
+        {
+            listener = new RemoteCacheListener<K, V>( cattr, cacheMgr, elementSerializer
);
+            addRemoteCacheListener( cattr, listener );
+        }
+        catch ( IOException ioe )
+        {
+            log.error( "Problem adding listener. Message: " + ioe.getMessage()
+                + " | RemoteCacheListener = " + listener, ioe );
+        }
+        catch ( Exception e )
+        {
+            log.error( "Problem adding listener. Message: " + e.getMessage() + " | RemoteCacheListener
= "
+                + listener, e );
+        }
+
+        IRemoteCacheClient<K, V> remoteCacheClient =
+            new RemoteCache<K, V>( cattr, (ICacheServiceNonLocal<K, V>) remoteService,
listener, monitor );
+        remoteCacheClient.setCacheEventLogger( cacheEventLogger );
+        remoteCacheClient.setElementSerializer( elementSerializer );
+
+        remoteCacheNoWait = new RemoteCacheNoWait<K, V>( remoteCacheClient );
+        remoteCacheNoWait.setCacheEventLogger( cacheEventLogger );
+        remoteCacheNoWait.setElementSerializer( elementSerializer );
+
+        return remoteCacheNoWait;
+    }
 
     /** Shutdown all. */
     public void release()

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=1762121&r1=1762120&r2=1762121&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
Sat Sep 24 12:51:28 2016
@@ -44,6 +44,9 @@ public class RemoteCacheNoWaitFacade<K,
     /** log instance */
     private static final Log log = LogFactory.getLog( RemoteCacheNoWaitFacade.class );
 
+    /** Provide factory instance to RemoteCacheFailoverRunner */
+    private final RemoteCacheFactory cacheFactory;
+
     /**
      * Constructs with the given remote cache, and fires events to any listeners.
      * <p>
@@ -52,14 +55,17 @@ public class RemoteCacheNoWaitFacade<K,
      * @param cacheMgr
      * @param cacheEventLogger
      * @param elementSerializer
+     * @param cacheFactory
      */
     public RemoteCacheNoWaitFacade( List<ICache<K, V>> noWaits,
                                     RemoteCacheAttributes rca,
                                     ICompositeCacheManager cacheMgr,
                                     ICacheEventLogger cacheEventLogger,
-                                    IElementSerializer elementSerializer )
+                                    IElementSerializer elementSerializer,
+                                    RemoteCacheFactory cacheFactory)
     {
         super( noWaits, rca, cacheMgr, cacheEventLogger, elementSerializer );
+        this.cacheFactory = cacheFactory;
     }
 
     /**
@@ -80,7 +86,7 @@ public class RemoteCacheNoWaitFacade<K,
             if ( rcnw.getStatus() == CacheStatus.ERROR )
             {
                 // start failover, primary recovery process
-                RemoteCacheFailoverRunner<K, V> runner = new RemoteCacheFailoverRunner<K,
V>( this );
+                RemoteCacheFailoverRunner<K, V> runner = new RemoteCacheFailoverRunner<K,
V>( this, this.cacheFactory );
                 runner.setDaemon( true );
                 runner.start();
                 runner.notifyError();

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=1762121&r1=1762120&r2=1762121&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
Sat Sep 24 12:51:28 2016
@@ -72,8 +72,9 @@ public class RemoteHttpCacheFactory
         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 );
+            new RemoteCacheNoWaitFacade<K, V>(noWaits, rca, cacheMgr, cacheEventLogger,
elementSerializer, null );
 
         getFacades().put( rca.getCacheName(), rcnwf );
 

Modified: commons/proper/jcs/trunk/commons-jcs-core/src/main/java/org/apache/commons/jcs/auxiliary/remote/server/RemoteCacheServerFactory.java
URL: http://svn.apache.org/viewvc/commons/proper/jcs/trunk/commons-jcs-core/src/main/java/org/apache/commons/jcs/auxiliary/remote/server/RemoteCacheServerFactory.java?rev=1762121&r1=1762120&r2=1762121&view=diff
==============================================================================
--- commons/proper/jcs/trunk/commons-jcs-core/src/main/java/org/apache/commons/jcs/auxiliary/remote/server/RemoteCacheServerFactory.java
(original)
+++ commons/proper/jcs/trunk/commons-jcs-core/src/main/java/org/apache/commons/jcs/auxiliary/remote/server/RemoteCacheServerFactory.java
Sat Sep 24 12:51:28 2016
@@ -56,7 +56,7 @@ public class RemoteCacheServerFactory
     private static final Log log = LogFactory.getLog( RemoteCacheServerFactory.class );
 
     /** The single instance of the RemoteCacheServer object. */
-    private static RemoteCacheServer<? extends Serializable, ? extends Serializable>
remoteCacheServer;
+    private static RemoteCacheServer<?, ?> remoteCacheServer;
 
     /** The name of the service. */
     private static String serviceName = IRemoteCacheConstants.REMOTE_CACHE_SERVICE_VAL;

Modified: commons/proper/jcs/trunk/commons-jcs-core/src/test/java/org/apache/commons/jcs/auxiliary/remote/TestRemoteCache.java
URL: http://svn.apache.org/viewvc/commons/proper/jcs/trunk/commons-jcs-core/src/test/java/org/apache/commons/jcs/auxiliary/remote/TestRemoteCache.java?rev=1762121&r1=1762120&r2=1762121&view=diff
==============================================================================
--- commons/proper/jcs/trunk/commons-jcs-core/src/test/java/org/apache/commons/jcs/auxiliary/remote/TestRemoteCache.java
(original)
+++ commons/proper/jcs/trunk/commons-jcs-core/src/test/java/org/apache/commons/jcs/auxiliary/remote/TestRemoteCache.java
Sat Sep 24 12:51:28 2016
@@ -1,5 +1,17 @@
 package org.apache.commons.jcs.auxiliary.remote;
 
+import org.apache.commons.jcs.JCS;
+import org.apache.commons.jcs.access.CacheAccess;
+import org.apache.commons.jcs.auxiliary.AuxiliaryCache;
+import org.apache.commons.jcs.auxiliary.MockCacheEventLogger;
+import org.apache.commons.jcs.auxiliary.remote.server.RemoteCacheServerFactory;
+import org.apache.commons.jcs.engine.CacheElement;
+import org.apache.commons.jcs.engine.behavior.ICompositeCacheManager;
+import org.apache.commons.jcs.engine.control.MockCompositeCacheManager;
+import org.apache.commons.jcs.engine.control.MockElementSerializer;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
 /*
  * Licensed to the Apache Software Foundation (ASF) under one
  * or more contributor license agreements.  See the NOTICE file
@@ -21,18 +33,6 @@ package org.apache.commons.jcs.auxiliary
 
 import junit.framework.TestCase;
 
-import org.apache.commons.jcs.JCS;
-import org.apache.commons.jcs.access.CacheAccess;
-import org.apache.commons.jcs.auxiliary.AuxiliaryCache;
-import org.apache.commons.jcs.auxiliary.MockCacheEventLogger;
-import org.apache.commons.jcs.auxiliary.remote.server.RemoteCacheServerFactory;
-import org.apache.commons.jcs.engine.CacheElement;
-import org.apache.commons.jcs.engine.behavior.ICompositeCacheManager;
-import org.apache.commons.jcs.engine.control.MockCompositeCacheManager;
-import org.apache.commons.jcs.engine.control.MockElementSerializer;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-
 /**
  * @author Aaron SMuts
  */
@@ -108,7 +108,9 @@ public class TestRemoteCache
         rca.setRemoteLocation( "localhost", 1101 );
         rca.setCacheName( "testCache" );
 
-        RemoteCacheManager mgr = RemoteCacheFactory.getManager( rca, cacheMgr, new MockCacheEventLogger(),
new MockElementSerializer() );
+        RemoteCacheFactory factory = new RemoteCacheFactory();
+        factory.initialize();
+        RemoteCacheManager mgr = factory.getManager( rca, cacheMgr, new MockCacheEventLogger(),
new MockElementSerializer() );
         AuxiliaryCache<String, String> cache = mgr.getCache( rca );
 
         int numMes = 100;

Modified: commons/proper/jcs/trunk/commons-jcs-core/src/test/java/org/apache/commons/jcs/auxiliary/remote/server/BasicRemoteCacheClientServerUnitTest.java
URL: http://svn.apache.org/viewvc/commons/proper/jcs/trunk/commons-jcs-core/src/test/java/org/apache/commons/jcs/auxiliary/remote/server/BasicRemoteCacheClientServerUnitTest.java?rev=1762121&r1=1762120&r2=1762121&view=diff
==============================================================================
--- commons/proper/jcs/trunk/commons-jcs-core/src/test/java/org/apache/commons/jcs/auxiliary/remote/server/BasicRemoteCacheClientServerUnitTest.java
(original)
+++ commons/proper/jcs/trunk/commons-jcs-core/src/test/java/org/apache/commons/jcs/auxiliary/remote/server/BasicRemoteCacheClientServerUnitTest.java
Sat Sep 24 12:51:28 2016
@@ -147,7 +147,7 @@ public class BasicRemoteCacheClientServe
         attributes.setLocalPort(LOCAL_PORT);
         attributes.setCacheName("testSinglePut");
 
-        RemoteCacheManager remoteCacheManager = RemoteCacheFactory.getManager(attributes,
compositeCacheManager, new MockCacheEventLogger(), new MockElementSerializer());
+        RemoteCacheManager remoteCacheManager = factory.getManager(attributes, compositeCacheManager,
new MockCacheEventLogger(), new MockElementSerializer());
         AuxiliaryCache<String, String> cache = remoteCacheManager.getCache(attributes);
 
         // DO WORK
@@ -196,7 +196,7 @@ public class BasicRemoteCacheClientServe
 
         MockCacheEventLogger cacheEventLogger = new MockCacheEventLogger();
 
-        RemoteCacheManager remoteCacheManager = RemoteCacheFactory.getManager(attributes,
compositeCacheManager, cacheEventLogger, null);
+        RemoteCacheManager remoteCacheManager = factory.getManager(attributes, compositeCacheManager,
cacheEventLogger, null);
         AuxiliaryCache<String, String> cache = remoteCacheManager.getCache(attributes);
 
         // DO WORK
@@ -250,7 +250,7 @@ public class BasicRemoteCacheClientServe
         attributes.setLocalPort(LOCAL_PORT);
         attributes.setCacheName("testPutAndListen");
 
-        RemoteCacheManager remoteCacheManager = RemoteCacheFactory.getManager(attributes,
compositeCacheManager, new MockCacheEventLogger(), new MockElementSerializer());
+        RemoteCacheManager remoteCacheManager = factory.getManager(attributes, compositeCacheManager,
new MockCacheEventLogger(), new MockElementSerializer());
         AuxiliaryCache<String, String> cache = remoteCacheManager.getCache(attributes);
 
         MockRemoteCacheListener<String, String> listener = new MockRemoteCacheListener<String,
String>();
@@ -299,7 +299,7 @@ public class BasicRemoteCacheClientServe
         attributes.setLocalPort(LOCAL_PORT);
         attributes.setCacheName("testPutaMultipleAndListen");
 
-        RemoteCacheManager remoteCacheManager = RemoteCacheFactory.getManager(attributes,
compositeCacheManager, new MockCacheEventLogger(), new MockElementSerializer());
+        RemoteCacheManager remoteCacheManager = factory.getManager(attributes, compositeCacheManager,
new MockCacheEventLogger(), new MockElementSerializer());
         AuxiliaryCache<String, String> cache = remoteCacheManager.getCache(attributes);
 
         MockRemoteCacheListener<String, String> listener = new MockRemoteCacheListener<String,
String>();



Mime
View raw message