commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From t.@apache.org
Subject svn commit: r1586632 - in /commons/proper/jcs/trunk/src: java/org/apache/commons/jcs/auxiliary/disk/jdbc/hsql/ java/org/apache/commons/jcs/auxiliary/remote/ java/org/apache/commons/jcs/auxiliary/remote/http/client/ java/org/apache/commons/jcs/auxiliary...
Date Fri, 11 Apr 2014 12:33:33 GMT
Author: tv
Date: Fri Apr 11 12:33:33 2014
New Revision: 1586632

URL: http://svn.apache.org/r1586632
Log:
Clean up handling of cache manager

Modified:
    commons/proper/jcs/trunk/src/java/org/apache/commons/jcs/auxiliary/disk/jdbc/hsql/HSQLDiskCacheFactory.java
    commons/proper/jcs/trunk/src/java/org/apache/commons/jcs/auxiliary/remote/RemoteCacheManager.java
    commons/proper/jcs/trunk/src/java/org/apache/commons/jcs/auxiliary/remote/http/client/RemoteHttpCacheManager.java
    commons/proper/jcs/trunk/src/java/org/apache/commons/jcs/auxiliary/remote/http/server/AbstractRemoteCacheService.java
    commons/proper/jcs/trunk/src/java/org/apache/commons/jcs/auxiliary/remote/http/server/RemoteCacheServiceAdaptor.java
    commons/proper/jcs/trunk/src/java/org/apache/commons/jcs/auxiliary/remote/http/server/RemoteHttpCacheServlet.java
    commons/proper/jcs/trunk/src/java/org/apache/commons/jcs/engine/behavior/ICompositeCacheManager.java
    commons/proper/jcs/trunk/src/java/org/apache/commons/jcs/engine/control/CompositeCacheManager.java
    commons/proper/jcs/trunk/src/test/org/apache/commons/jcs/engine/control/MockCompositeCacheManager.java

Modified: commons/proper/jcs/trunk/src/java/org/apache/commons/jcs/auxiliary/disk/jdbc/hsql/HSQLDiskCacheFactory.java
URL: http://svn.apache.org/viewvc/commons/proper/jcs/trunk/src/java/org/apache/commons/jcs/auxiliary/disk/jdbc/hsql/HSQLDiskCacheFactory.java?rev=1586632&r1=1586631&r2=1586632&view=diff
==============================================================================
--- commons/proper/jcs/trunk/src/java/org/apache/commons/jcs/auxiliary/disk/jdbc/hsql/HSQLDiskCacheFactory.java
(original)
+++ commons/proper/jcs/trunk/src/java/org/apache/commons/jcs/auxiliary/disk/jdbc/hsql/HSQLDiskCacheFactory.java
Fri Apr 11 12:33:33 2014
@@ -35,7 +35,6 @@ import org.apache.commons.jcs.auxiliary.
 import org.apache.commons.jcs.auxiliary.disk.jdbc.JDBCDiskCacheManager;
 import org.apache.commons.jcs.engine.behavior.ICompositeCacheManager;
 import org.apache.commons.jcs.engine.behavior.IElementSerializer;
-import org.apache.commons.jcs.engine.control.CompositeCacheManager;
 import org.apache.commons.jcs.engine.logging.behavior.ICacheEventLogger;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
@@ -61,17 +60,18 @@ public class HSQLDiskCacheFactory
      * This factory method should create an instance of the hsqlcache.
      * <p>
      * @param rawAttr
-     * @param arg1
+     * @param cacheManager
      * @param cacheEventLogger
      * @param elementSerializer
      * @return AuxiliaryCache
      */
     @Override
-    public <K extends Serializable, V extends Serializable> AuxiliaryCache<K, V>
createCache( AuxiliaryCacheAttributes rawAttr, ICompositeCacheManager arg1,
-                                       ICacheEventLogger cacheEventLogger, IElementSerializer
elementSerializer )
+    public <K extends Serializable, V extends Serializable> AuxiliaryCache<K, V>
createCache( AuxiliaryCacheAttributes rawAttr,
+    									ICompositeCacheManager cacheManager,
+    									ICacheEventLogger cacheEventLogger,
+    									IElementSerializer elementSerializer )
     {
-        JDBCDiskCacheManager mgr = JDBCDiskCacheManager.getInstance( (JDBCDiskCacheAttributes)
rawAttr,
-                                                                     CompositeCacheManager.getUnconfiguredInstance(),
+        JDBCDiskCacheManager mgr = JDBCDiskCacheManager.getInstance( (JDBCDiskCacheAttributes)
rawAttr, cacheManager,
                                                                      cacheEventLogger, elementSerializer
);
         try
         {

Modified: commons/proper/jcs/trunk/src/java/org/apache/commons/jcs/auxiliary/remote/RemoteCacheManager.java
URL: http://svn.apache.org/viewvc/commons/proper/jcs/trunk/src/java/org/apache/commons/jcs/auxiliary/remote/RemoteCacheManager.java?rev=1586632&r1=1586631&r2=1586632&view=diff
==============================================================================
--- commons/proper/jcs/trunk/src/java/org/apache/commons/jcs/auxiliary/remote/RemoteCacheManager.java
(original)
+++ commons/proper/jcs/trunk/src/java/org/apache/commons/jcs/auxiliary/remote/RemoteCacheManager.java
Fri Apr 11 12:33:33 2014
@@ -37,7 +37,6 @@ import org.apache.commons.jcs.engine.beh
 import org.apache.commons.jcs.engine.behavior.ICompositeCacheManager;
 import org.apache.commons.jcs.engine.behavior.IElementSerializer;
 import org.apache.commons.jcs.engine.behavior.IShutdownObserver;
-import org.apache.commons.jcs.engine.control.CompositeCacheManager;
 import org.apache.commons.jcs.engine.logging.behavior.ICacheEventLogger;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
@@ -53,9 +52,6 @@ import org.apache.commons.logging.LogFac
 public class RemoteCacheManager
     implements AuxiliaryCacheManager, IShutdownObserver
 {
-    /** Don't change */
-    private static final long serialVersionUID = 798077557166389498L;
-
     /** The logger */
     private static final Log log = LogFactory.getLog( RemoteCacheManager.class );
 
@@ -128,11 +124,7 @@ public class RemoteCacheManager
         this.elementSerializer = elementSerializer;
 
         // register shutdown observer
-        // TODO add the shutdown observable methods to the interface
-        if ( this.cacheMgr instanceof CompositeCacheManager )
-        {
-            ( (CompositeCacheManager) this.cacheMgr ).registerShutdownObserver( this );
-        }
+        this.cacheMgr.registerShutdownObserver( this );
 
         String registry = "//" + host + ":" + port + "/" + service;
         if ( log.isInfoEnabled() )

Modified: commons/proper/jcs/trunk/src/java/org/apache/commons/jcs/auxiliary/remote/http/client/RemoteHttpCacheManager.java
URL: http://svn.apache.org/viewvc/commons/proper/jcs/trunk/src/java/org/apache/commons/jcs/auxiliary/remote/http/client/RemoteHttpCacheManager.java?rev=1586632&r1=1586631&r2=1586632&view=diff
==============================================================================
--- commons/proper/jcs/trunk/src/java/org/apache/commons/jcs/auxiliary/remote/http/client/RemoteHttpCacheManager.java
(original)
+++ commons/proper/jcs/trunk/src/java/org/apache/commons/jcs/auxiliary/remote/http/client/RemoteHttpCacheManager.java
Fri Apr 11 12:33:33 2014
@@ -31,7 +31,6 @@ import org.apache.commons.jcs.auxiliary.
 import org.apache.commons.jcs.engine.behavior.ICompositeCacheManager;
 import org.apache.commons.jcs.engine.behavior.IElementSerializer;
 import org.apache.commons.jcs.engine.behavior.IShutdownObserver;
-import org.apache.commons.jcs.engine.control.CompositeCacheManager;
 import org.apache.commons.jcs.engine.logging.behavior.ICacheEventLogger;
 import org.apache.commons.jcs.utils.config.OptionConverter;
 import org.apache.commons.logging.Log;
@@ -88,11 +87,7 @@ public class RemoteHttpCacheManager
         this.elementSerializer = elementSerializer;
 
         // register shutdown observer
-        // TODO add the shutdown observable methods to the interface
-        if ( this.cacheMgr instanceof CompositeCacheManager )
-        {
-            ( (CompositeCacheManager) this.cacheMgr ).registerShutdownObserver( this );
-        }
+        this.cacheMgr.registerShutdownObserver( this );
     }
 
     /**

Modified: commons/proper/jcs/trunk/src/java/org/apache/commons/jcs/auxiliary/remote/http/server/AbstractRemoteCacheService.java
URL: http://svn.apache.org/viewvc/commons/proper/jcs/trunk/src/java/org/apache/commons/jcs/auxiliary/remote/http/server/AbstractRemoteCacheService.java?rev=1586632&r1=1586631&r2=1586632&view=diff
==============================================================================
--- commons/proper/jcs/trunk/src/java/org/apache/commons/jcs/auxiliary/remote/http/server/AbstractRemoteCacheService.java
(original)
+++ commons/proper/jcs/trunk/src/java/org/apache/commons/jcs/auxiliary/remote/http/server/AbstractRemoteCacheService.java
Fri Apr 11 12:33:33 2014
@@ -28,7 +28,6 @@ import org.apache.commons.jcs.engine.beh
 import org.apache.commons.jcs.engine.behavior.ICacheServiceNonLocal;
 import org.apache.commons.jcs.engine.behavior.ICompositeCacheManager;
 import org.apache.commons.jcs.engine.control.CompositeCache;
-import org.apache.commons.jcs.engine.control.CompositeCacheManager;
 import org.apache.commons.jcs.engine.logging.CacheEvent;
 import org.apache.commons.jcs.engine.logging.behavior.ICacheEvent;
 import org.apache.commons.jcs.engine.logging.behavior.ICacheEventLogger;
@@ -573,7 +572,7 @@ public abstract class AbstractRemoteCach
     /**
      * @param cacheManager the cacheManager to set
      */
-    protected void setCacheManager( CompositeCacheManager cacheManager )
+    protected void setCacheManager( ICompositeCacheManager cacheManager )
     {
         this.cacheManager = cacheManager;
     }

Modified: commons/proper/jcs/trunk/src/java/org/apache/commons/jcs/auxiliary/remote/http/server/RemoteCacheServiceAdaptor.java
URL: http://svn.apache.org/viewvc/commons/proper/jcs/trunk/src/java/org/apache/commons/jcs/auxiliary/remote/http/server/RemoteCacheServiceAdaptor.java?rev=1586632&r1=1586631&r2=1586632&view=diff
==============================================================================
--- commons/proper/jcs/trunk/src/java/org/apache/commons/jcs/auxiliary/remote/http/server/RemoteCacheServiceAdaptor.java
(original)
+++ commons/proper/jcs/trunk/src/java/org/apache/commons/jcs/auxiliary/remote/http/server/RemoteCacheServiceAdaptor.java
Fri Apr 11 12:33:33 2014
@@ -29,7 +29,7 @@ import org.apache.commons.jcs.auxiliary.
 import org.apache.commons.jcs.auxiliary.remote.value.RemoteCacheResponse;
 import org.apache.commons.jcs.engine.behavior.ICacheElement;
 import org.apache.commons.jcs.engine.behavior.ICacheServiceNonLocal;
-import org.apache.commons.jcs.engine.control.CompositeCacheManager;
+import org.apache.commons.jcs.engine.behavior.ICompositeCacheManager;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 
@@ -58,7 +58,7 @@ public class RemoteCacheServiceAdaptor<K
      * <p>
      * @param cacheManager
      */
-    public RemoteCacheServiceAdaptor( CompositeCacheManager cacheManager )
+    public RemoteCacheServiceAdaptor( ICompositeCacheManager cacheManager )
     {
         ICacheServiceNonLocal<K, V> rcs = RemoteHttpCacheSeviceFactory.createRemoteHttpCacheService(
cacheManager );
         setRemoteCacheService( rcs );

Modified: commons/proper/jcs/trunk/src/java/org/apache/commons/jcs/auxiliary/remote/http/server/RemoteHttpCacheServlet.java
URL: http://svn.apache.org/viewvc/commons/proper/jcs/trunk/src/java/org/apache/commons/jcs/auxiliary/remote/http/server/RemoteHttpCacheServlet.java?rev=1586632&r1=1586631&r2=1586632&view=diff
==============================================================================
--- commons/proper/jcs/trunk/src/java/org/apache/commons/jcs/auxiliary/remote/http/server/RemoteHttpCacheServlet.java
(original)
+++ commons/proper/jcs/trunk/src/java/org/apache/commons/jcs/auxiliary/remote/http/server/RemoteHttpCacheServlet.java
Fri Apr 11 12:33:33 2014
@@ -218,7 +218,7 @@ public class RemoteHttpCacheServlet
      */
     protected synchronized void ensureCacheManager() throws CacheException
     {
-        if ( cacheMgr == null )
+        if ( cacheMgr == null || !cacheMgr.isInitialized() )
         {
             cacheMgr = CompositeCacheManager.getInstance();
         }

Modified: commons/proper/jcs/trunk/src/java/org/apache/commons/jcs/engine/behavior/ICompositeCacheManager.java
URL: http://svn.apache.org/viewvc/commons/proper/jcs/trunk/src/java/org/apache/commons/jcs/engine/behavior/ICompositeCacheManager.java?rev=1586632&r1=1586631&r2=1586632&view=diff
==============================================================================
--- commons/proper/jcs/trunk/src/java/org/apache/commons/jcs/engine/behavior/ICompositeCacheManager.java
(original)
+++ commons/proper/jcs/trunk/src/java/org/apache/commons/jcs/engine/behavior/ICompositeCacheManager.java
Fri Apr 11 12:33:33 2014
@@ -29,7 +29,7 @@ import org.apache.commons.jcs.engine.con
  *
  * @author Aaron Smuts
  */
-public interface ICompositeCacheManager
+public interface ICompositeCacheManager extends IShutdownObservable
 {
     /**
      * Gets the cache attribute of the CacheHub object

Modified: commons/proper/jcs/trunk/src/java/org/apache/commons/jcs/engine/control/CompositeCacheManager.java
URL: http://svn.apache.org/viewvc/commons/proper/jcs/trunk/src/java/org/apache/commons/jcs/engine/control/CompositeCacheManager.java?rev=1586632&r1=1586631&r2=1586632&view=diff
==============================================================================
--- commons/proper/jcs/trunk/src/java/org/apache/commons/jcs/engine/control/CompositeCacheManager.java
(original)
+++ commons/proper/jcs/trunk/src/java/org/apache/commons/jcs/engine/control/CompositeCacheManager.java
Fri Apr 11 12:33:33 2014
@@ -51,7 +51,6 @@ import org.apache.commons.jcs.engine.beh
 import org.apache.commons.jcs.engine.behavior.ICompositeCacheManager;
 import org.apache.commons.jcs.engine.behavior.IElementAttributes;
 import org.apache.commons.jcs.engine.behavior.IProvideScheduler;
-import org.apache.commons.jcs.engine.behavior.IShutdownObservable;
 import org.apache.commons.jcs.engine.behavior.IShutdownObserver;
 import org.apache.commons.jcs.engine.stats.CacheStats;
 import org.apache.commons.jcs.engine.stats.behavior.ICacheStats;
@@ -70,7 +69,7 @@ import org.apache.commons.logging.LogFac
  * It is recommended that you use the JCS convenience class for all cache access.
  */
 public class CompositeCacheManager
-    implements IRemoteCacheConstants, ICompositeCacheManager, IShutdownObservable, IProvideScheduler
+    implements IRemoteCacheConstants, ICompositeCacheManager, IProvideScheduler
 {
     /** The logger */
     private static final Log log = LogFactory.getLog( CompositeCacheManager.class );

Modified: commons/proper/jcs/trunk/src/test/org/apache/commons/jcs/engine/control/MockCompositeCacheManager.java
URL: http://svn.apache.org/viewvc/commons/proper/jcs/trunk/src/test/org/apache/commons/jcs/engine/control/MockCompositeCacheManager.java?rev=1586632&r1=1586631&r2=1586632&view=diff
==============================================================================
--- commons/proper/jcs/trunk/src/test/org/apache/commons/jcs/engine/control/MockCompositeCacheManager.java
(original)
+++ commons/proper/jcs/trunk/src/test/org/apache/commons/jcs/engine/control/MockCompositeCacheManager.java
Fri Apr 11 12:33:33 2014
@@ -25,6 +25,7 @@ import java.util.Properties;
 import org.apache.commons.jcs.engine.CompositeCacheAttributes;
 import org.apache.commons.jcs.engine.ElementAttributes;
 import org.apache.commons.jcs.engine.behavior.ICompositeCacheManager;
+import org.apache.commons.jcs.engine.behavior.IShutdownObserver;
 
 /** For testing. */
 public class MockCompositeCacheManager
@@ -98,4 +99,22 @@ public class MockCompositeCacheManager
     {
         return "Mock";
     }
+
+	/**
+	 * @see org.apache.commons.jcs.engine.behavior.IShutdownObservable#registerShutdownObserver(org.apache.commons.jcs.engine.behavior.IShutdownObserver)
+	 */
+	@Override
+	public void registerShutdownObserver(IShutdownObserver observer)
+	{
+		// Do nothing
+	}
+
+	/**
+	 * @see org.apache.commons.jcs.engine.behavior.IShutdownObservable#deregisterShutdownObserver(org.apache.commons.jcs.engine.behavior.IShutdownObserver)
+	 */
+	@Override
+	public void deregisterShutdownObserver(IShutdownObserver observer)
+	{
+		// Do nothing
+	}
 }



Mime
View raw message