jakarta-jcs-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From asm...@apache.org
Subject svn commit: r230748 - in /jakarta/jcs/trunk: ./ src/java/org/apache/jcs/auxiliary/ src/java/org/apache/jcs/auxiliary/behavior/ src/java/org/apache/jcs/auxiliary/disk/hsql/ src/java/org/apache/jcs/auxiliary/disk/hsql/behavior/ src/java/org/apache/jcs/au...
Date Mon, 08 Aug 2005 04:21:23 GMT
Author: asmuts
Date: Sun Aug  7 21:21:01 2005
New Revision: 230748

URL: http://svn.apache.org/viewcvs?rev=230748&view=rev
Log:
Added system properties override functionality to the configure stage.
You can set system properties that will be put into the cache properties prior to configuration.
Added a simple test for the feature.

Removed soem unused interfaces.  There is inconsistency in the way interfaces are named.  . . .

Changed auxiliary cache interface to use the cache factory.  Many auxiliary listeners were
getting the factory by its get instance method.  This made it
almost impossible to unit test them.  I'm in the process of converting them all
to use the passed in cache manager.  This will allow us to mock
out the manager and the composite cache and create tests for the auxiliaries.
This is a work in progress.  The getCache method in the manager need to return an interface.  

Removed:
    jakarta/jcs/trunk/src/java/org/apache/jcs/auxiliary/behavior/
Modified:
    jakarta/jcs/trunk/project.xml
    jakarta/jcs/trunk/src/java/org/apache/jcs/auxiliary/AuxiliaryCacheAttributes.java
    jakarta/jcs/trunk/src/java/org/apache/jcs/auxiliary/AuxiliaryCacheFactory.java
    jakarta/jcs/trunk/src/java/org/apache/jcs/auxiliary/AuxiliaryCacheManager.java
    jakarta/jcs/trunk/src/java/org/apache/jcs/auxiliary/disk/hsql/HSQLCacheFactory.java
    jakarta/jcs/trunk/src/java/org/apache/jcs/auxiliary/disk/hsql/behavior/IHSQLCacheAttributes.java
    jakarta/jcs/trunk/src/java/org/apache/jcs/auxiliary/disk/indexed/IndexedDiskCacheFactory.java
    jakarta/jcs/trunk/src/java/org/apache/jcs/auxiliary/disk/jisp/JISPCacheFactory.java
    jakarta/jcs/trunk/src/java/org/apache/jcs/auxiliary/disk/jisp/behavior/IJISPCacheAttributes.java
    jakarta/jcs/trunk/src/java/org/apache/jcs/auxiliary/javagroups/JavaGroupsCache.java
    jakarta/jcs/trunk/src/java/org/apache/jcs/auxiliary/javagroups/JavaGroupsCacheFactory.java
    jakarta/jcs/trunk/src/java/org/apache/jcs/auxiliary/lateral/LateralCacheFactory.java
    jakarta/jcs/trunk/src/java/org/apache/jcs/auxiliary/lateral/LateralCacheManager.java
    jakarta/jcs/trunk/src/java/org/apache/jcs/auxiliary/lateral/socket/tcp/LateralTCPListener.java
    jakarta/jcs/trunk/src/java/org/apache/jcs/auxiliary/lateral/socket/tcp/discovery/UDPDiscoveryManager.java
    jakarta/jcs/trunk/src/java/org/apache/jcs/auxiliary/lateral/socket/tcp/discovery/UDPDiscoveryReceiver.java
    jakarta/jcs/trunk/src/java/org/apache/jcs/auxiliary/lateral/socket/tcp/discovery/UDPDiscoveryService.java
    jakarta/jcs/trunk/src/java/org/apache/jcs/auxiliary/remote/RemoteCacheFactory.java
    jakarta/jcs/trunk/src/java/org/apache/jcs/auxiliary/remote/RemoteCacheRestore.java
    jakarta/jcs/trunk/src/java/org/apache/jcs/engine/control/CompositeCache.java
    jakarta/jcs/trunk/src/java/org/apache/jcs/engine/control/CompositeCacheConfigurator.java
    jakarta/jcs/trunk/src/java/org/apache/jcs/engine/control/CompositeCacheManager.java
    jakarta/jcs/trunk/src/test/org/apache/jcs/auxiliary/lateral/socket/tcp/TestTCPLateral.java
    jakarta/jcs/trunk/src/test/org/apache/jcs/auxiliary/lateral/socket/tcp/discovery/TestUDPDiscovery.java

Modified: jakarta/jcs/trunk/project.xml
URL: http://svn.apache.org/viewcvs/jakarta/jcs/trunk/project.xml?rev=230748&r1=230747&r2=230748&view=diff
==============================================================================
--- jakarta/jcs/trunk/project.xml (original)
+++ jakarta/jcs/trunk/project.xml Sun Aug  7 21:21:01 2005
@@ -200,6 +200,7 @@
         <include>**/TestRemovalConcurrent.java</include>
         <include>**/TestRemovalSimple.java</include>
         <include>**/TestUDPDiscovery.java</include>
+        <include>**/TestSystemPropertyUsage.java</include>
       </includes>
       <resources>
         <includes>

Modified: jakarta/jcs/trunk/src/java/org/apache/jcs/auxiliary/AuxiliaryCacheAttributes.java
URL: http://svn.apache.org/viewcvs/jakarta/jcs/trunk/src/java/org/apache/jcs/auxiliary/AuxiliaryCacheAttributes.java?rev=230748&r1=230747&r2=230748&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 Sun Aug  7 21:21:01 2005
@@ -46,7 +46,7 @@
     public void setCacheName( String s );
 
     /**
-     * Gets the cacheName attribute of the IAuxiliaryCacheAttributes object
+     * Gets the cacheName attribute of the AuxiliaryCacheAttributes object
      * 
      * @return The cacheName value
      */
@@ -61,7 +61,7 @@
     public void setName( String s );
 
     /**
-     * Gets the name attribute of the IAuxiliaryCacheAttributes object
+     * Gets the name attribute of the AuxiliaryCacheAttributes object
      * 
      * @return The name value
      */

Modified: jakarta/jcs/trunk/src/java/org/apache/jcs/auxiliary/AuxiliaryCacheFactory.java
URL: http://svn.apache.org/viewcvs/jakarta/jcs/trunk/src/java/org/apache/jcs/auxiliary/AuxiliaryCacheFactory.java?rev=230748&r1=230747&r2=230748&view=diff
==============================================================================
--- jakarta/jcs/trunk/src/java/org/apache/jcs/auxiliary/AuxiliaryCacheFactory.java (original)
+++ jakarta/jcs/trunk/src/java/org/apache/jcs/auxiliary/AuxiliaryCacheFactory.java Sun Aug  7 21:21:01 2005
@@ -16,28 +16,32 @@
  * limitations under the License.
  */
 
-import org.apache.jcs.engine.control.CompositeCache;
+import org.apache.jcs.engine.behavior.ICompositeCache;
+import org.apache.jcs.engine.behavior.ICompositeCacheManager;
 
 /**
- * Description of the Interface
+ * All auxiliary caches must have a factory that the cache configurator can
+ * use to create instances.
  *  
  */
 public interface AuxiliaryCacheFactory
 {
 
     /**
+     * 
      * @param attr
-     *            Attributes the factory will use to create the AuxiliaryCache
-     *            instance.
-     * @param cache
-     *            The CompositeCache which will contain the AuxiliaryCache
-     *            instance being created. Allows auxiliaries to retain a
-     *            reference to their associated CompositeCache.
+     * 
+     * @param cacheMgr
+     * 				This allows auxiliaries to reference the manager
+     * 				without assuming that it is a singleton.  This will
+     * 				allow JCS to be a nonsingleton.  Also, it makes it easier to test.
+     * 
+     * @return AuxiliaryCache
      */
-    public AuxiliaryCache createCache( AuxiliaryCacheAttributes attr, CompositeCache cache );
-
+    public AuxiliaryCache createCache( AuxiliaryCacheAttributes attr, ICompositeCacheManager cacheMgr );
+    
     /**
-     * Sets the name attribute of the IAuxiliaryCacheFactory object
+     * Sets the name attribute of the AuxiliaryCacheFactory object
      * 
      * @param s
      *            The new name value
@@ -45,7 +49,7 @@
     public void setName( String s );
 
     /**
-     * Gets the name attribute of the IAuxiliaryCacheFactory object
+     * Gets the name attribute of the AuxiliaryCacheFactory object
      * 
      * @return The name value
      */

Modified: jakarta/jcs/trunk/src/java/org/apache/jcs/auxiliary/AuxiliaryCacheManager.java
URL: http://svn.apache.org/viewcvs/jakarta/jcs/trunk/src/java/org/apache/jcs/auxiliary/AuxiliaryCacheManager.java?rev=230748&r1=230747&r2=230748&view=diff
==============================================================================
--- jakarta/jcs/trunk/src/java/org/apache/jcs/auxiliary/AuxiliaryCacheManager.java (original)
+++ jakarta/jcs/trunk/src/java/org/apache/jcs/auxiliary/AuxiliaryCacheManager.java Sun Aug  7 21:21:01 2005
@@ -17,6 +17,7 @@
  */
 
 import org.apache.jcs.engine.behavior.ICacheType;
+import org.apache.jcs.engine.behavior.ICompositeCacheManager;
 
 /**
  * AuxiliaryCacheManager
@@ -27,5 +28,24 @@
 public interface AuxiliaryCacheManager
     extends ICacheType
 {
+    
+    /**
+     * Return the approriate auxiliary cache for this region.
+     * 
+     * @param cacheName
+     * @return AuxiliaryCache
+     */
     public AuxiliaryCache getCache( String cacheName );
+
+
+    /**
+     * This allows the cache manager to be plugged into the auxiliary caches, 
+     * rather then ahving them get it themselves.  Cache maangers can be mocked
+     * out and the auxiliaries will be easier to test.
+     * 
+     * @param cacheName
+     * @param cacheManager
+     * @return AuxiliaryCache
+     */
+    //public AuxiliaryCache getCache( String cacheName, ICompositeCacheManager cacheManager );
 }

Modified: jakarta/jcs/trunk/src/java/org/apache/jcs/auxiliary/disk/hsql/HSQLCacheFactory.java
URL: http://svn.apache.org/viewcvs/jakarta/jcs/trunk/src/java/org/apache/jcs/auxiliary/disk/hsql/HSQLCacheFactory.java?rev=230748&r1=230747&r2=230748&view=diff
==============================================================================
--- jakarta/jcs/trunk/src/java/org/apache/jcs/auxiliary/disk/hsql/HSQLCacheFactory.java (original)
+++ jakarta/jcs/trunk/src/java/org/apache/jcs/auxiliary/disk/hsql/HSQLCacheFactory.java Sun Aug  7 21:21:01 2005
@@ -19,7 +19,7 @@
 import org.apache.jcs.auxiliary.AuxiliaryCache;
 import org.apache.jcs.auxiliary.AuxiliaryCacheAttributes;
 import org.apache.jcs.auxiliary.AuxiliaryCacheFactory;
-import org.apache.jcs.engine.control.CompositeCache;
+import org.apache.jcs.engine.behavior.ICompositeCacheManager;
 
 /**
  * @version 1.0
@@ -30,8 +30,13 @@
 {
     private String name;
 
-    /** Description of the Method */
-    public AuxiliaryCache createCache( AuxiliaryCacheAttributes iaca, CompositeCache cache )
+    /*
+     * (non-Javadoc)
+     * 
+     * @see org.apache.jcs.auxiliary.AuxiliaryCacheFactory#createCache(org.apache.jcs.auxiliary.AuxiliaryCacheAttributes,
+     *      org.apache.jcs.engine.behavior.ICompositeCacheManager)
+     */
+    public AuxiliaryCache createCache( AuxiliaryCacheAttributes iaca, ICompositeCacheManager cacheMgr )
     {
         HSQLCacheAttributes idca = (HSQLCacheAttributes) iaca;
         HSQLCacheManager dcm = HSQLCacheManager.getInstance( idca );

Modified: jakarta/jcs/trunk/src/java/org/apache/jcs/auxiliary/disk/hsql/behavior/IHSQLCacheAttributes.java
URL: http://svn.apache.org/viewcvs/jakarta/jcs/trunk/src/java/org/apache/jcs/auxiliary/disk/hsql/behavior/IHSQLCacheAttributes.java?rev=230748&r1=230747&r2=230748&view=diff
==============================================================================
--- jakarta/jcs/trunk/src/java/org/apache/jcs/auxiliary/disk/hsql/behavior/IHSQLCacheAttributes.java (original)
+++ jakarta/jcs/trunk/src/java/org/apache/jcs/auxiliary/disk/hsql/behavior/IHSQLCacheAttributes.java Sun Aug  7 21:21:01 2005
@@ -16,7 +16,7 @@
  * limitations under the License.
  */
 
-import org.apache.jcs.auxiliary.behavior.IAuxiliaryCacheAttributes;
+import org.apache.jcs.auxiliary.AuxiliaryCacheAttributes;
 
 /**
  * Title: Description:
@@ -25,7 +25,7 @@
  */
 
 public interface IHSQLCacheAttributes
-    extends IAuxiliaryCacheAttributes
+    extends AuxiliaryCacheAttributes
 {
 
     /**

Modified: jakarta/jcs/trunk/src/java/org/apache/jcs/auxiliary/disk/indexed/IndexedDiskCacheFactory.java
URL: http://svn.apache.org/viewcvs/jakarta/jcs/trunk/src/java/org/apache/jcs/auxiliary/disk/indexed/IndexedDiskCacheFactory.java?rev=230748&r1=230747&r2=230748&view=diff
==============================================================================
--- jakarta/jcs/trunk/src/java/org/apache/jcs/auxiliary/disk/indexed/IndexedDiskCacheFactory.java (original)
+++ jakarta/jcs/trunk/src/java/org/apache/jcs/auxiliary/disk/indexed/IndexedDiskCacheFactory.java Sun Aug  7 21:21:01 2005
@@ -18,11 +18,10 @@
 
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
-
 import org.apache.jcs.auxiliary.AuxiliaryCache;
 import org.apache.jcs.auxiliary.AuxiliaryCacheAttributes;
 import org.apache.jcs.auxiliary.AuxiliaryCacheFactory;
-import org.apache.jcs.engine.control.CompositeCache;
+import org.apache.jcs.engine.behavior.ICompositeCacheManager;
 
 /**
  * @version 1.0
@@ -42,13 +41,14 @@
      * <p>
      * One disk cache is returned per region fromt he maanger.
      * 
-     * @param iaca
-     *            The auxiliary attributes.
-     * @param cache
-     *            The CacheHub
+     * @param cacheMgr
+     *            This allows auxiliaries to reference the manager without
+     *            assuming that it is a singleton. This will allow JCS to be a
+     *            nonsingleton. Also, it makes it easier to test.
+     * 
      * @return AuxiliaryCache
      */
-    public AuxiliaryCache createCache( AuxiliaryCacheAttributes iaca, CompositeCache cache )
+    public AuxiliaryCache createCache( AuxiliaryCacheAttributes iaca, ICompositeCacheManager cacheMgr )
     {
         IndexedDiskCacheAttributes idca = (IndexedDiskCacheAttributes) iaca;
         if ( log.isDebugEnabled() )

Modified: jakarta/jcs/trunk/src/java/org/apache/jcs/auxiliary/disk/jisp/JISPCacheFactory.java
URL: http://svn.apache.org/viewcvs/jakarta/jcs/trunk/src/java/org/apache/jcs/auxiliary/disk/jisp/JISPCacheFactory.java?rev=230748&r1=230747&r2=230748&view=diff
==============================================================================
--- jakarta/jcs/trunk/src/java/org/apache/jcs/auxiliary/disk/jisp/JISPCacheFactory.java (original)
+++ jakarta/jcs/trunk/src/java/org/apache/jcs/auxiliary/disk/jisp/JISPCacheFactory.java Sun Aug  7 21:21:01 2005
@@ -21,7 +21,7 @@
 import org.apache.jcs.auxiliary.AuxiliaryCache;
 import org.apache.jcs.auxiliary.AuxiliaryCacheAttributes;
 import org.apache.jcs.auxiliary.AuxiliaryCacheFactory;
-import org.apache.jcs.engine.control.CompositeCache;
+import org.apache.jcs.engine.behavior.ICompositeCacheManager;
 
 /**
  * @version 1.0
@@ -34,8 +34,13 @@
 
     private String name;
 
-    /** Description of the Method */
-    public AuxiliaryCache createCache( AuxiliaryCacheAttributes iaca, CompositeCache cache )
+    /*
+     * (non-Javadoc)
+     * 
+     * @see org.apache.jcs.auxiliary.AuxiliaryCacheFactory#createCache(org.apache.jcs.auxiliary.AuxiliaryCacheAttributes,
+     *      org.apache.jcs.engine.behavior.ICompositeCacheManager)
+     */
+    public AuxiliaryCache createCache( AuxiliaryCacheAttributes iaca, ICompositeCacheManager cacheMgr )
     {
         JISPCacheAttributes idca = (JISPCacheAttributes) iaca;
         JISPCacheManager dcm = JISPCacheManager.getInstance( idca );

Modified: jakarta/jcs/trunk/src/java/org/apache/jcs/auxiliary/disk/jisp/behavior/IJISPCacheAttributes.java
URL: http://svn.apache.org/viewcvs/jakarta/jcs/trunk/src/java/org/apache/jcs/auxiliary/disk/jisp/behavior/IJISPCacheAttributes.java?rev=230748&r1=230747&r2=230748&view=diff
==============================================================================
--- jakarta/jcs/trunk/src/java/org/apache/jcs/auxiliary/disk/jisp/behavior/IJISPCacheAttributes.java (original)
+++ jakarta/jcs/trunk/src/java/org/apache/jcs/auxiliary/disk/jisp/behavior/IJISPCacheAttributes.java Sun Aug  7 21:21:01 2005
@@ -16,14 +16,14 @@
  * limitations under the License.
  */
 
-import org.apache.jcs.auxiliary.behavior.IAuxiliaryCacheAttributes;
+import org.apache.jcs.auxiliary.AuxiliaryCacheAttributes;
 
 /**
  * Description of the Interface
  *  
  */
 public interface IJISPCacheAttributes
-    extends IAuxiliaryCacheAttributes
+    extends AuxiliaryCacheAttributes
 {
 
     /**

Modified: jakarta/jcs/trunk/src/java/org/apache/jcs/auxiliary/javagroups/JavaGroupsCache.java
URL: http://svn.apache.org/viewcvs/jakarta/jcs/trunk/src/java/org/apache/jcs/auxiliary/javagroups/JavaGroupsCache.java?rev=230748&r1=230747&r2=230748&view=diff
==============================================================================
--- jakarta/jcs/trunk/src/java/org/apache/jcs/auxiliary/javagroups/JavaGroupsCache.java (original)
+++ jakarta/jcs/trunk/src/java/org/apache/jcs/auxiliary/javagroups/JavaGroupsCache.java Sun Aug  7 21:21:01 2005
@@ -23,6 +23,8 @@
 import org.apache.jcs.engine.CacheElement;
 import org.apache.jcs.engine.behavior.ICacheElement;
 import org.apache.jcs.engine.behavior.ICacheType;
+import org.apache.jcs.engine.behavior.ICompositeCache;
+import org.apache.jcs.engine.behavior.ICompositeCacheManager;
 import org.apache.jcs.engine.control.CompositeCache;
 import org.apache.jcs.engine.stats.StatElement;
 import org.apache.jcs.engine.stats.Stats;
@@ -79,18 +81,18 @@
 
     private boolean getFromPeers;
 
-    private CompositeCache cache;
+    private ICompositeCacheManager cacheMgr;
 
     private Channel channel;
 
     private MessageDispatcher dispatcher;
 
-    public JavaGroupsCache( CompositeCache cache, Channel channel, boolean getFromPeers )
+    public JavaGroupsCache( ICompositeCacheManager cache, String cacheName, Channel channel, boolean getFromPeers )
         throws Exception
     {
-        this.cache = cache;
+        this.cacheMgr = cacheMgr;
 
-        this.cacheName = cache.getCacheName();
+        this.cacheName = cacheName;
         this.channel = channel;
 
         this.getFromPeers = getFromPeers;
@@ -321,22 +323,22 @@
             {
                 case Request.GET:
 
-                    return cache.localGet( request.getCacheElement().getKey() );
+                    return getCompositeCache().localGet( request.getCacheElement().getKey() );
                 // break;
 
                 case Request.UPDATE:
 
-                    cache.localUpdate( request.getCacheElement() );
+                    getCompositeCache().localUpdate( request.getCacheElement() );
                     break;
 
                 case Request.REMOVE:
 
-                    cache.localRemove( request.getCacheElement().getKey() );
+                    getCompositeCache().localRemove( request.getCacheElement().getKey() );
                     break;
 
                 case Request.REMOVE_ALL:
 
-                    cache.localRemoveAll();
+                    getCompositeCache().localRemoveAll();
                     break;
 
                 default:
@@ -352,6 +354,16 @@
         return null;
     }
 
+    /**
+     * TODO speed this up. We don't want to ahve to go through the manager everytime.
+     * 
+     * @return ICompositeCache
+     */
+    private ICompositeCache getCompositeCache()
+    {
+        return cacheMgr.getCache( this.cacheName );
+    }
+    
     // ------------------------------------------- interface MembershipListener
 
     public void viewAccepted( View view )

Modified: jakarta/jcs/trunk/src/java/org/apache/jcs/auxiliary/javagroups/JavaGroupsCacheFactory.java
URL: http://svn.apache.org/viewcvs/jakarta/jcs/trunk/src/java/org/apache/jcs/auxiliary/javagroups/JavaGroupsCacheFactory.java?rev=230748&r1=230747&r2=230748&view=diff
==============================================================================
--- jakarta/jcs/trunk/src/java/org/apache/jcs/auxiliary/javagroups/JavaGroupsCacheFactory.java (original)
+++ jakarta/jcs/trunk/src/java/org/apache/jcs/auxiliary/javagroups/JavaGroupsCacheFactory.java Sun Aug  7 21:21:01 2005
@@ -21,6 +21,7 @@
 import org.apache.jcs.auxiliary.AuxiliaryCache;
 import org.apache.jcs.auxiliary.AuxiliaryCacheAttributes;
 import org.apache.jcs.auxiliary.AuxiliaryCacheFactory;
+import org.apache.jcs.engine.behavior.ICompositeCacheManager;
 import org.apache.jcs.engine.control.CompositeCache;
 import org.jgroups.Channel;
 import org.jgroups.ChannelFactory;
@@ -39,8 +40,16 @@
 
     private String name;
 
-    public AuxiliaryCache createCache( AuxiliaryCacheAttributes iaca, CompositeCache cache )
+    /*
+     * (non-Javadoc)
+     * 
+     * @see org.apache.jcs.auxiliary.AuxiliaryCacheFactory#createCache(org.apache.jcs.auxiliary.AuxiliaryCacheAttributes,
+     *      org.apache.jcs.engine.behavior.ICompositeCacheManager)
+     */
+    public AuxiliaryCache createCache( AuxiliaryCacheAttributes iaca, ICompositeCacheManager cacheMgr )
     {
+        // ignore the maanger
+
         try
         {
             // Cast provided attributes to JavaGroupsCacheAttributes
@@ -59,7 +68,7 @@
 
             // Return a new JavaGroupsCache for the new channel.
 
-            return new JavaGroupsCache( cache, channel, attributes.isGetFromPeers() );
+            return new JavaGroupsCache( cacheMgr, attributes.getCacheName(), channel, attributes.isGetFromPeers() );
         }
         catch ( Exception e )
         {

Modified: jakarta/jcs/trunk/src/java/org/apache/jcs/auxiliary/lateral/LateralCacheFactory.java
URL: http://svn.apache.org/viewcvs/jakarta/jcs/trunk/src/java/org/apache/jcs/auxiliary/lateral/LateralCacheFactory.java?rev=230748&r1=230747&r2=230748&view=diff
==============================================================================
--- jakarta/jcs/trunk/src/java/org/apache/jcs/auxiliary/lateral/LateralCacheFactory.java (original)
+++ jakarta/jcs/trunk/src/java/org/apache/jcs/auxiliary/lateral/LateralCacheFactory.java Sun Aug  7 21:21:01 2005
@@ -30,7 +30,7 @@
 import org.apache.jcs.auxiliary.lateral.socket.tcp.discovery.UDPDiscoveryManager;
 import org.apache.jcs.auxiliary.lateral.socket.tcp.discovery.UDPDiscoveryService;
 import org.apache.jcs.engine.behavior.ICache;
-import org.apache.jcs.engine.control.CompositeCache;
+import org.apache.jcs.engine.behavior.ICompositeCacheManager;
 
 /**
  * Constructs a LateralCacheNoWaitFacade for the given configuration. Each
@@ -47,22 +47,21 @@
 
     private String name;
 
-    /**
-     * Interface method. Allows classforname construction, making caches
-     * pluggable.
+    /*
+     * (non-Javadoc)
      * 
-     * @return AuxiliaryCache
-     * @param iaca
-     * @param cache
+     * @see org.apache.jcs.auxiliary.AuxiliaryCacheFactory#createCache(org.apache.jcs.auxiliary.AuxiliaryCacheAttributes,
+     *      org.apache.jcs.engine.behavior.ICompositeCacheManager)
      */
-    public AuxiliaryCache createCache( AuxiliaryCacheAttributes iaca, CompositeCache cache )
+    public AuxiliaryCache createCache( AuxiliaryCacheAttributes iaca, ICompositeCacheManager cacheMgr )
     {
+
         LateralCacheAttributes lac = (LateralCacheAttributes) iaca;
         ArrayList noWaits = new ArrayList();
 
         if ( lac.getTransmissionType() == LateralCacheAttributes.UDP )
         {
-            LateralCacheManager lcm = LateralCacheManager.getInstance( lac );
+            LateralCacheManager lcm = LateralCacheManager.getInstance( lac, cacheMgr );
             ICache ic = lcm.getCache( lac.getCacheName() );
             if ( ic != null )
             {
@@ -71,7 +70,7 @@
         }
         else if ( lac.getTransmissionType() == LateralCacheAttributes.JAVAGROUPS )
         {
-            LateralCacheManager lcm = LateralCacheManager.getInstance( lac );
+            LateralCacheManager lcm = LateralCacheManager.getInstance( lac, cacheMgr );
             ICache ic = lcm.getCache( lac.getCacheName() );
             if ( ic != null )
             {
@@ -100,7 +99,7 @@
                 }
                 LateralCacheAttributes lacC = (LateralCacheAttributes) lac.copy();
                 lacC.setTcpServer( server );
-                LateralCacheManager lcm = LateralCacheManager.getInstance( lacC );
+                LateralCacheManager lcm = LateralCacheManager.getInstance( lacC, cacheMgr );
                 ICache ic = lcm.getCache( lacC.getCacheName() );
                 if ( ic != null )
                 {
@@ -127,7 +126,7 @@
                 String server = (String) it.nextElement();
                 //p( "tcp server = " + server );
                 lac.setHttpServer( server );
-                LateralCacheManager lcm = LateralCacheManager.getInstance( lac );
+                LateralCacheManager lcm = LateralCacheManager.getInstance( lac, cacheMgr );
                 ICache ic = lcm.getCache( lac.getCacheName() );
                 if ( ic != null )
                 {
@@ -147,7 +146,7 @@
             {
                 String server = (String) it.nextElement();
                 lac.setHttpServer( server );
-                LateralCacheManager lcm = LateralCacheManager.getInstance( lac );
+                LateralCacheManager lcm = LateralCacheManager.getInstance( lac, cacheMgr );
                 ICache ic = lcm.getCache( lac.getCacheName() );
                 if ( ic != null )
                 {
@@ -156,13 +155,13 @@
             }
         }
 
-        createListener( lac );
+        createListener( lac, cacheMgr );
 
         // create the no wait facade.
         LateralCacheNoWaitFacade lcnwf = new LateralCacheNoWaitFacade( (LateralCacheNoWait[]) noWaits
             .toArray( new LateralCacheNoWait[0] ), iaca.getCacheName() );
 
-        createDiscoveryService( lac, lcnwf );
+        createDiscoveryService( lac, lcnwf, cacheMgr );
 
         return lcnwf;
     }
@@ -173,7 +172,7 @@
      * 
      * @param lac
      */
-    private void createListener( LateralCacheAttributes lac )
+    private void createListener( LateralCacheAttributes lac, ICompositeCacheManager cacheMgr )
     {
         // don't create a listener if we are not receiving.
         if ( lac.isReceive() )
@@ -183,7 +182,7 @@
                 if ( lac.getTransmissionType() == ILateralCacheAttributes.TCP )
                 {
                     // make a listener. if one doesn't exist
-                    LateralTCPListener.getInstance( lac );
+                    LateralTCPListener.getInstance( lac, cacheMgr );
                 }
                 else if ( lac.getTransmissionType() == ILateralCacheAttributes.JAVAGROUPS )
                 {
@@ -213,7 +212,8 @@
      * @param lcnwf
      * @return null if none is created.
      */
-    private UDPDiscoveryService createDiscoveryService( LateralCacheAttributes lac, LateralCacheNoWaitFacade lcnwf )
+    private UDPDiscoveryService createDiscoveryService( LateralCacheAttributes lac, LateralCacheNoWaitFacade lcnwf,
+                                                       ICompositeCacheManager cacheMgr )
     {
         UDPDiscoveryService discovery = null;
 
@@ -228,7 +228,7 @@
 
             // need a factory for this so it doesn't
             // get dereferenced, also we don't want one for every region.
-            discovery = UDPDiscoveryManager.getInstance().getService( lac );
+            discovery = UDPDiscoveryManager.getInstance().getService( lac, cacheMgr );
 
             discovery.addNoWaitFacade( lcnwf, lac.getCacheName() );
 

Modified: jakarta/jcs/trunk/src/java/org/apache/jcs/auxiliary/lateral/LateralCacheManager.java
URL: http://svn.apache.org/viewcvs/jakarta/jcs/trunk/src/java/org/apache/jcs/auxiliary/lateral/LateralCacheManager.java?rev=230748&r1=230747&r2=230748&view=diff
==============================================================================
--- jakarta/jcs/trunk/src/java/org/apache/jcs/auxiliary/lateral/LateralCacheManager.java (original)
+++ jakarta/jcs/trunk/src/java/org/apache/jcs/auxiliary/lateral/LateralCacheManager.java Sun Aug  7 21:21:01 2005
@@ -33,6 +33,7 @@
 import org.apache.jcs.auxiliary.lateral.socket.tcp.LateralTCPListener;
 import org.apache.jcs.auxiliary.lateral.javagroups.LateralJGService;
 import org.apache.jcs.auxiliary.lateral.javagroups.LateralCacheJGListener;
+import org.apache.jcs.engine.behavior.ICompositeCacheManager;
 
 /**
  * Creates lateral caches. Lateral caches are primarily used for removing non
@@ -78,13 +79,16 @@
      */
     private LateralCacheWatchRepairable lateralWatch;
 
+    private ICompositeCacheManager cacheMgr;
+    
     /**
-     * Gets the instance attribute of the LateralCacheManager class
+     * Returns an instance of the LateralCacheManager.
      * 
-     * @return The instance value
      * @param lca
+     * @param cacheMgr  this allows the auxiliary to be passed a cache manager.
+     * @return
      */
-    public static LateralCacheManager getInstance( ILateralCacheAttributes lca )
+    public static LateralCacheManager getInstance( ILateralCacheAttributes lca, ICompositeCacheManager cacheMgr )
     {
         LateralCacheManager ins = (LateralCacheManager) instances.get( lca.toString() );
         synchronized ( instances )
@@ -96,7 +100,7 @@
                 ins = (LateralCacheManager) instances.get( lca.toString() );
                 if ( ins == null )
                 {
-                    ins = new LateralCacheManager( lca );
+                    ins = new LateralCacheManager( lca, cacheMgr );
                     instances.put( lca.toString(), ins );
                 }
             }
@@ -123,10 +127,12 @@
      * 
      * @param lcaA
      */
-    private LateralCacheManager( ILateralCacheAttributes lcaA )
+    private LateralCacheManager( ILateralCacheAttributes lcaA, ICompositeCacheManager cacheMgr )
     {
         this.lca = lcaA;
 
+        this.cacheMgr = cacheMgr;
+        
         if ( log.isDebugEnabled() )
         {
             log.debug( "Creating lateral cache service, lca = " + this.lca );
@@ -247,7 +253,7 @@
             {
                 if ( this.lca.getTransmissionType() == ILateralCacheAttributes.TCP )
                 {
-                    addLateralCacheListener( cacheName, LateralTCPListener.getInstance( this.lca ) );
+                    addLateralCacheListener( cacheName, LateralTCPListener.getInstance( this.lca, cacheMgr ) );
                 }
                 else if ( this.lca.getTransmissionType() == ILateralCacheAttributes.JAVAGROUPS )
                 {
@@ -289,7 +295,7 @@
     /**
      * Gets the stats attribute of the LateralCacheManager object
      * 
-     * @return The {3} value
+     * @return String
      */
     public String getStats()
     {

Modified: jakarta/jcs/trunk/src/java/org/apache/jcs/auxiliary/lateral/socket/tcp/LateralTCPListener.java
URL: http://svn.apache.org/viewcvs/jakarta/jcs/trunk/src/java/org/apache/jcs/auxiliary/lateral/socket/tcp/LateralTCPListener.java?rev=230748&r1=230747&r2=230748&view=diff
==============================================================================
--- jakarta/jcs/trunk/src/java/org/apache/jcs/auxiliary/lateral/socket/tcp/LateralTCPListener.java (original)
+++ jakarta/jcs/trunk/src/java/org/apache/jcs/auxiliary/lateral/socket/tcp/LateralTCPListener.java Sun Aug  7 21:21:01 2005
@@ -33,6 +33,7 @@
 import org.apache.jcs.auxiliary.lateral.behavior.ILateralCacheAttributes;
 import org.apache.jcs.auxiliary.lateral.behavior.ILateralCacheListener;
 import org.apache.jcs.engine.behavior.ICacheElement;
+import org.apache.jcs.engine.behavior.ICompositeCacheManager;
 import org.apache.jcs.engine.control.CompositeCache;
 import org.apache.jcs.engine.control.CompositeCacheManager;
 
@@ -78,7 +79,7 @@
      * @param ilca
      * @return The instance value
      */
-    public synchronized static ILateralCacheListener getInstance( ILateralCacheAttributes ilca )
+    public synchronized static ILateralCacheListener getInstance( ILateralCacheAttributes ilca, ICompositeCacheManager cacheMgr )
     {
         ILateralCacheListener ins = (ILateralCacheListener) instances.get( String.valueOf( ilca.getTcpListenerPort() ) );
 

Modified: jakarta/jcs/trunk/src/java/org/apache/jcs/auxiliary/lateral/socket/tcp/discovery/UDPDiscoveryManager.java
URL: http://svn.apache.org/viewcvs/jakarta/jcs/trunk/src/java/org/apache/jcs/auxiliary/lateral/socket/tcp/discovery/UDPDiscoveryManager.java?rev=230748&r1=230747&r2=230748&view=diff
==============================================================================
--- jakarta/jcs/trunk/src/java/org/apache/jcs/auxiliary/lateral/socket/tcp/discovery/UDPDiscoveryManager.java (original)
+++ jakarta/jcs/trunk/src/java/org/apache/jcs/auxiliary/lateral/socket/tcp/discovery/UDPDiscoveryManager.java Sun Aug  7 21:21:01 2005
@@ -6,6 +6,7 @@
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 import org.apache.jcs.auxiliary.lateral.LateralCacheAttributes;
+import org.apache.jcs.engine.behavior.ICompositeCacheManager;
 
 /**
  * This manages UDPDiscovery Services. We should end up with one service per
@@ -44,7 +45,7 @@
      * @param lca
      * @return
      */
-    public synchronized UDPDiscoveryService getService( LateralCacheAttributes lca )
+    public synchronized UDPDiscoveryService getService( LateralCacheAttributes lca, ICompositeCacheManager cacheMgr )
     {
         String key = lca.getTcpServer() + ":" + lca.getTcpListenerPort();
 
@@ -56,7 +57,7 @@
                 log.debug( "Creating service for " + key );
             }
 
-            service = new UDPDiscoveryService( lca );
+            service = new UDPDiscoveryService( lca, cacheMgr );
             services.put( key, service );
         }
 

Modified: jakarta/jcs/trunk/src/java/org/apache/jcs/auxiliary/lateral/socket/tcp/discovery/UDPDiscoveryReceiver.java
URL: http://svn.apache.org/viewcvs/jakarta/jcs/trunk/src/java/org/apache/jcs/auxiliary/lateral/socket/tcp/discovery/UDPDiscoveryReceiver.java?rev=230748&r1=230747&r2=230748&view=diff
==============================================================================
--- jakarta/jcs/trunk/src/java/org/apache/jcs/auxiliary/lateral/socket/tcp/discovery/UDPDiscoveryReceiver.java (original)
+++ jakarta/jcs/trunk/src/java/org/apache/jcs/auxiliary/lateral/socket/tcp/discovery/UDPDiscoveryReceiver.java Sun Aug  7 21:21:01 2005
@@ -32,6 +32,7 @@
 import org.apache.jcs.auxiliary.lateral.LateralCacheManager;
 import org.apache.jcs.auxiliary.lateral.LateralCacheNoWait;
 import org.apache.jcs.engine.behavior.ICache;
+import org.apache.jcs.engine.behavior.ICompositeCacheManager;
 
 import EDU.oswego.cs.dl.util.concurrent.BoundedBuffer;
 import EDU.oswego.cs.dl.util.concurrent.PooledExecutor;
@@ -68,6 +69,8 @@
 
     private int multicastPort = 0;
 
+    private ICompositeCacheManager cacheMgr; 
+    
     /**
      * Constructor for the LateralUDPReceiver object.
      * <p>
@@ -76,15 +79,18 @@
      * @param service
      * @param multicastAddressString
      * @param multicastPort
+     * @param cacheMgr
      * @exception IOException
      */
-    public UDPDiscoveryReceiver( UDPDiscoveryService service, String multicastAddressString, int multicastPort )
+    public UDPDiscoveryReceiver( UDPDiscoveryService service, String multicastAddressString, int multicastPort,
+                                ICompositeCacheManager cacheMgr )
         throws IOException
     {
         this.service = service;
         this.multicastAddressString = multicastAddressString;
         this.multicastPort = multicastPort;
-
+        this.cacheMgr = cacheMgr;
+        
         // create a small thread pool to handle a barage
         pooledExecutor = new PooledExecutor( new BoundedBuffer( 100 ), maxPoolSize );
         pooledExecutor.discardOldestWhenBlocked();
@@ -298,7 +304,7 @@
                     }
                     lca.setTransmissionType( LateralCacheAttributes.TCP );
                     lca.setTcpServer( message.getHost() + ":" + message.getPort() );
-                    LateralCacheManager lcm = LateralCacheManager.getInstance( lca );
+                    LateralCacheManager lcm = LateralCacheManager.getInstance( lca, cacheMgr );
 
                     ArrayList regions = message.getCacheNames();
                     if ( regions != null )
@@ -372,6 +378,6 @@
             return t;
         }
 
-    }    
+    }
 }
 // end class

Modified: jakarta/jcs/trunk/src/java/org/apache/jcs/auxiliary/lateral/socket/tcp/discovery/UDPDiscoveryService.java
URL: http://svn.apache.org/viewcvs/jakarta/jcs/trunk/src/java/org/apache/jcs/auxiliary/lateral/socket/tcp/discovery/UDPDiscoveryService.java?rev=230748&r1=230747&r2=230748&view=diff
==============================================================================
--- jakarta/jcs/trunk/src/java/org/apache/jcs/auxiliary/lateral/socket/tcp/discovery/UDPDiscoveryService.java (original)
+++ jakarta/jcs/trunk/src/java/org/apache/jcs/auxiliary/lateral/socket/tcp/discovery/UDPDiscoveryService.java Sun Aug  7 21:21:01 2005
@@ -13,6 +13,7 @@
 import org.apache.jcs.auxiliary.lateral.LateralCacheAttributes;
 import org.apache.jcs.auxiliary.lateral.LateralCacheNoWait;
 import org.apache.jcs.auxiliary.lateral.LateralCacheNoWaitFacade;
+import org.apache.jcs.engine.behavior.ICompositeCacheManager;
 
 import EDU.oswego.cs.dl.util.concurrent.ClockDaemon;
 import EDU.oswego.cs.dl.util.concurrent.ThreadFactory;
@@ -40,6 +41,8 @@
      */
     private static ClockDaemon daemon;
 
+    private Thread udpReceiverThread;
+    
     private UDPDiscoveryReceiver receiver;
 
     private Map facades = new HashMap();
@@ -54,9 +57,10 @@
      * 
      * @param facade
      * @param lca
+     * @param cacheMgr
      * @param receivingPort
      */
-    public UDPDiscoveryService( LateralCacheAttributes lca )
+    public UDPDiscoveryService( LateralCacheAttributes lca, ICompositeCacheManager cacheMgr )
     {
         //LateralCacheNoWaitFacade facade,
         //this.facade = facade;
@@ -82,11 +86,11 @@
             // todo need some kind of recovery here.
             //receiver = new UDPDiscoveryReceiver( facade,
             // lca.getUdpDiscoveryAddr(), lca.getUdpDiscoveryPort() );
-            receiver = new UDPDiscoveryReceiver( this, lca.getUdpDiscoveryAddr(), lca.getUdpDiscoveryPort() );
-            Thread t = new Thread(receiver);
-            t.setDaemon(true);
-            //t.setName( t.getName() + "--UDPReceiver" );
-            t.start();
+            receiver = new UDPDiscoveryReceiver( this, lca.getUdpDiscoveryAddr(), lca.getUdpDiscoveryPort(), cacheMgr );
+            udpReceiverThread = new Thread(receiver);
+            udpReceiverThread.setDaemon(true);
+            //udpReceiverThread.setName( t.getName() + "--UDPReceiver" );
+            udpReceiverThread.start();
         }
         catch ( Exception e )
         {

Modified: jakarta/jcs/trunk/src/java/org/apache/jcs/auxiliary/remote/RemoteCacheFactory.java
URL: http://svn.apache.org/viewcvs/jakarta/jcs/trunk/src/java/org/apache/jcs/auxiliary/remote/RemoteCacheFactory.java?rev=230748&r1=230747&r2=230748&view=diff
==============================================================================
--- jakarta/jcs/trunk/src/java/org/apache/jcs/auxiliary/remote/RemoteCacheFactory.java (original)
+++ jakarta/jcs/trunk/src/java/org/apache/jcs/auxiliary/remote/RemoteCacheFactory.java Sun Aug  7 21:21:01 2005
@@ -20,15 +20,13 @@
 import java.util.HashMap;
 import java.util.StringTokenizer;
 
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.jcs.auxiliary.AuxiliaryCache;
 import org.apache.jcs.auxiliary.AuxiliaryCacheAttributes;
 import org.apache.jcs.auxiliary.AuxiliaryCacheFactory;
-import org.apache.jcs.auxiliary.AuxiliaryCache;
-
 import org.apache.jcs.engine.behavior.ICache;
-import org.apache.jcs.engine.control.CompositeCache;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
+import org.apache.jcs.engine.behavior.ICompositeCacheManager;
 
 /**
  * The RemoteCacheFactory creates remote caches for the cache hub. It returns a
@@ -47,15 +45,13 @@
     /** store reference of facades to initiate failover */
     private final static HashMap facades = new HashMap();
 
-    /**
-     * Interface method. Allows classforname construction, making caches
-     * pluggable. Should be able to make this work for clusters and local caches
+    /*
+     * (non-Javadoc)
      * 
-     * @param iaca
-     * @param cache
-     * @return An AuxiliaryCache implementation
+     * @see org.apache.jcs.auxiliary.AuxiliaryCacheFactory#createCache(org.apache.jcs.auxiliary.AuxiliaryCacheAttributes,
+     *      org.apache.jcs.engine.behavior.ICompositeCacheManager)
      */
-    public AuxiliaryCache createCache( AuxiliaryCacheAttributes iaca, CompositeCache cache )
+    public AuxiliaryCache createCache( AuxiliaryCacheAttributes iaca, ICompositeCacheManager cacheMgr )
     {
 
         RemoteCacheAttributes rca = (RemoteCacheAttributes) iaca;

Modified: jakarta/jcs/trunk/src/java/org/apache/jcs/auxiliary/remote/RemoteCacheRestore.java
URL: http://svn.apache.org/viewcvs/jakarta/jcs/trunk/src/java/org/apache/jcs/auxiliary/remote/RemoteCacheRestore.java?rev=230748&r1=230747&r2=230748&view=diff
==============================================================================
--- jakarta/jcs/trunk/src/java/org/apache/jcs/auxiliary/remote/RemoteCacheRestore.java (original)
+++ jakarta/jcs/trunk/src/java/org/apache/jcs/auxiliary/remote/RemoteCacheRestore.java Sun Aug  7 21:21:01 2005
@@ -43,7 +43,7 @@
 
     private final RemoteCacheManager rcm;
 
-    //private final IAuxiliaryCacheManager rcm;
+    //private final AuxiliaryCacheManager rcm;
     private boolean canFix = true;
 
     private Object remoteObj;
@@ -55,7 +55,7 @@
      */
     public RemoteCacheRestore( RemoteCacheManager rcm )
     {
-        //public RemoteCacheRestore(IAuxiliaryCacheManager rcm) {
+        //public RemoteCacheRestore(AuxiliaryCacheManager rcm) {
         this.rcm = rcm;
     }
 

Modified: jakarta/jcs/trunk/src/java/org/apache/jcs/engine/control/CompositeCache.java
URL: http://svn.apache.org/viewcvs/jakarta/jcs/trunk/src/java/org/apache/jcs/engine/control/CompositeCache.java?rev=230748&r1=230747&r2=230748&view=diff
==============================================================================
--- jakarta/jcs/trunk/src/java/org/apache/jcs/engine/control/CompositeCache.java (original)
+++ jakarta/jcs/trunk/src/java/org/apache/jcs/engine/control/CompositeCache.java Sun Aug  7 21:21:01 2005
@@ -34,6 +34,7 @@
 import org.apache.jcs.engine.behavior.ICache;
 import org.apache.jcs.engine.behavior.ICacheElement;
 import org.apache.jcs.engine.behavior.ICacheType;
+import org.apache.jcs.engine.behavior.ICompositeCache;
 import org.apache.jcs.engine.behavior.ICompositeCacheAttributes;
 import org.apache.jcs.engine.behavior.IElementAttributes;
 
@@ -63,7 +64,7 @@
  * @version $Id$
  */
 public class CompositeCache
-    implements ICache, Serializable
+    implements ICache, Serializable, ICompositeCache
 {
     private final static Log log = LogFactory.getLog( CompositeCache.class );
 

Modified: jakarta/jcs/trunk/src/java/org/apache/jcs/engine/control/CompositeCacheConfigurator.java
URL: http://svn.apache.org/viewcvs/jakarta/jcs/trunk/src/java/org/apache/jcs/engine/control/CompositeCacheConfigurator.java?rev=230748&r1=230747&r2=230748&view=diff
==============================================================================
--- jakarta/jcs/trunk/src/java/org/apache/jcs/engine/control/CompositeCacheConfigurator.java (original)
+++ jakarta/jcs/trunk/src/java/org/apache/jcs/engine/control/CompositeCacheConfigurator.java Sun Aug  7 21:21:01 2005
@@ -36,6 +36,9 @@
 import org.apache.jcs.engine.behavior.IElementAttributes;
 
 /**
+ * This class configures JCS based on a properties object.
+ * <p>
+ * 
  * This class is based on the log4j class org.apache.log4j.PropertyConfigurator
  * which was made by: "Luke Blanshard" <Luke@quiq.com>"Mark DONSZELMANN"
  * <Mark.Donszelmann@cern.ch>"Anders Kristensen" <akristensen@dynamicsoft.com>
@@ -59,7 +62,7 @@
 
     final static String ELEMENT_ATTRIBUTE_PREFIX = ".elementattributes";
 
-    private CompositeCacheManager ccMgr;
+    private CompositeCacheManager compositeCacheManager;
 
     /**
      * Constructor for the CompositeCacheConfigurator object
@@ -68,11 +71,18 @@
      */
     public CompositeCacheConfigurator( CompositeCacheManager ccMgr )
     {
-        this.ccMgr = ccMgr;
+        this.compositeCacheManager = ccMgr;
     }
 
-    /** Configure cached for file name. */
-    public void doConfigure( String configFileName )
+    /**
+     * Configure cached for file name.
+     * <p>
+     * This is only used for testing. The manager handles the translation of a
+     * file into a properties object.
+     * 
+     * @param configFileName
+     */
+    protected void doConfigure( String configFileName )
     {
         Properties props = new Properties();
         try
@@ -91,12 +101,26 @@
         doConfigure( props );
     }
 
-    /** Configure cache for properties object */
+    /** 
+     * Configure cache for properties object.
+     * <p>
+     * This method proceeds in several steps:
+     * <ul>
+     * <li> Store props for use by non configured caches.
+     * <li> Set default value list
+     * <li> Set default cache attr
+     * <li> Set default element attr
+     * <li> Setup system caches to be used
+     * <li> Setup preconfigured caches
+     * </ul>
+     * 
+     * @param properties
+     */
     public void doConfigure( Properties properties )
     {
 
         // store props for use by non configured caches
-        ccMgr.props = properties;
+        compositeCacheManager.props = properties;
         // set default value list
         setDefaultAuxValues( properties );
         // set default cache attr
@@ -113,30 +137,42 @@
 
     }
 
-    /** Set the default aux list for new caches. */
+    /** 
+     * Set the default aux list for new caches.
+     * 
+     * @param props
+     */
     protected void setDefaultAuxValues( Properties props )
     {
         String value = OptionConverter.findAndSubst( DEFAULT_REGION, props );
-        ccMgr.defaultAuxValues = value;
+        compositeCacheManager.defaultAuxValues = value;
 
         log.info( "setting defaults to " + value );
     }
 
-    /** Set the default CompositeCacheAttributes for new caches. */
+    /**
+     * Set the default CompositeCacheAttributes for new caches.
+     * 
+     * @param props
+     */
     protected void setDefaultCompositeCacheAttributes( Properties props )
     {
         ICompositeCacheAttributes icca = parseCompositeCacheAttributes( props, "",
                                                                         CompositeCacheConfigurator.DEFAULT_REGION );
-        ccMgr.setDefaultCacheAttributes( icca );
+        compositeCacheManager.setDefaultCacheAttributes( icca );
 
         log.info( "setting defaultCompositeCacheAttributes to " + icca );
     }
 
-    /** Set the default ElementAttributes for new caches. */
+    /** 
+     * Set the default ElementAttributes for new caches.
+     * 
+     * @param props
+     */
     protected void setDefaultElementAttributes( Properties props )
     {
         IElementAttributes iea = parseElementAttributes( props, "", CompositeCacheConfigurator.DEFAULT_REGION );
-        ccMgr.setDefaultElementAttributes( iea );
+        compositeCacheManager.setDefaultElementAttributes( iea );
 
         log.info( "setting defaultElementAttributes to " + iea );
     }
@@ -144,6 +180,8 @@
     /**
      * Create caches used internally. System status gives them creation
      * priority.
+     * 
+     * @param props
      */
     protected void parseSystemRegions( Properties props )
     {
@@ -160,10 +198,10 @@
                 {
                     cache = parseRegion( props, regionName, value, null, SYSTEM_REGION_PREFIX );
                 }
-                ccMgr.systemCaches.put( regionName, cache );
+                compositeCacheManager.systemCaches.put( regionName, cache );
                 // to be availiable for remote reference they need to be here as
                 // well
-                ccMgr.caches.put( regionName, cache );
+                compositeCacheManager.caches.put( regionName, cache );
             }
         }
     }
@@ -184,7 +222,7 @@
                 {
                     cache = parseRegion( props, regionName, value );
                 }
-                ccMgr.caches.put( regionName, cache );
+                compositeCacheManager.caches.put( regionName, cache );
             }
         }
     }
@@ -195,13 +233,32 @@
         return parseRegion( props, regName, value, null, REGION_PREFIX );
     }
 
-    /** */
+    /**
+     * Get all the properties for a region and configure its cache.
+     * <p>
+     * This method tells the otehr parse method the name of the region prefix.
+     * 
+     * @param props
+     * @param regName
+     * @param value
+     * @param cca
+     * @return CompositeCache
+     */
     protected CompositeCache parseRegion( Properties props, String regName, String value, ICompositeCacheAttributes cca )
     {
         return parseRegion( props, regName, value, cca, REGION_PREFIX );
     }
 
-    /** */
+    /**
+     * Get all the properties for a region and configure its cache.
+     * 
+     * @param props
+     * @param regName
+     * @param value
+     * @param cca
+     * @param regionPrefix
+     * @return CompositeCache
+     */
     protected CompositeCache parseRegion( Properties props, String regName, String value,
                                          ICompositeCacheAttributes cca, String regionPrefix )
     {
@@ -272,7 +329,14 @@
         return parseCompositeCacheAttributes( props, regName, REGION_PREFIX );
     }
 
-    /** */
+    /**
+     * Get the main attributes for a region.
+     * 
+     * @param props
+     * @param regName
+     * @param regionPrefix
+     * @return ICompositeCacheAttributes
+     */
     protected ICompositeCacheAttributes parseCompositeCacheAttributes( Properties props, String regName,
                                                                       String regionPrefix )
     {
@@ -284,27 +348,42 @@
         //String prefix = regionPrefix + regName + ATTRIBUTE_PREFIX;
         ccAttr = (ICompositeCacheAttributes) OptionConverter
             .instantiateByKey( props, attrName, org.apache.jcs.engine.behavior.ICompositeCacheAttributes.class, null );
+
         if ( ccAttr == null )
         {
             log.warn( "Could not instantiate ccAttr named '" + attrName + "', using defaults." );
 
-            ICompositeCacheAttributes ccAttr2 = ccMgr.getDefaultCacheAttributes();
+            ICompositeCacheAttributes ccAttr2 = compositeCacheManager.getDefaultCacheAttributes();
             ccAttr = ccAttr2.copy();
         }
 
-        log.debug( "Parsing options for '" + attrName + "'" );
+        if ( log.isDebugEnabled() )
+        {
+            log.debug( "Parsing options for '" + attrName + "'" );
+        }
 
         PropertySetter.setProperties( ccAttr, props, attrName + "." );
         ccAttr.setCacheName( regName );
 
-        log.debug( "End of parsing for \"" + attrName + "\"." );
+        if ( log.isDebugEnabled() )
+        {
+            log.debug( "End of parsing for \"" + attrName + "\"." );
+        }
 
         // GET CACHE FROM FACTORY WITH ATTRIBUTES
         ccAttr.setCacheName( regName );
         return ccAttr;
     }
 
-    /** */
+    /**
+     * Create the element attributes from the properties object for a cache
+     * region.
+     * 
+     * @param props
+     * @param regName
+     * @param regionPrefix
+     * @return IElementAttributes
+     */
     protected IElementAttributes parseElementAttributes( Properties props, String regName, String regionPrefix )
     {
         IElementAttributes eAttr;
@@ -319,7 +398,7 @@
         {
             log.warn( "Could not instantiate eAttr named '" + attrName + "', using defaults." );
 
-            IElementAttributes eAttr2 = ccMgr.getDefaultElementAttributes();
+            IElementAttributes eAttr2 = compositeCacheManager.getDefaultElementAttributes();
             eAttr = eAttr2.copy();
         }
 
@@ -335,13 +414,21 @@
         return eAttr;
     }
 
-    /** Get an aux cache for the listed aux for a region. */
+    /**
+     * Get an aux cache for the listed aux for a region.
+     * 
+     * @param cache
+     * @param props
+     * @param auxName
+     * @param regName
+     * @return AuxiliaryCache
+     */
     protected AuxiliaryCache parseAuxiliary( CompositeCache cache, Properties props, String auxName, String regName )
     {
         AuxiliaryCache auxCache;
 
         // GET FACTORY
-        AuxiliaryCacheFactory auxFac = ccMgr.registryFacGet( auxName );
+        AuxiliaryCacheFactory auxFac = compositeCacheManager.registryFacGet( auxName );
         if ( auxFac == null )
         {
             // auxFactory was not previously initialized.
@@ -356,11 +443,11 @@
 
             auxFac.setName( auxName );
 
-            ccMgr.registryFacPut( auxFac );
+            compositeCacheManager.registryFacPut( auxFac );
         }
 
         // GET ATTRIBUTES
-        AuxiliaryCacheAttributes auxAttr = ccMgr.registryAttrGet( auxName );
+        AuxiliaryCacheAttributes auxAttr = compositeCacheManager.registryAttrGet( auxName );
         String attrName = AUXILIARY_PREFIX + auxName + ATTRIBUTE_PREFIX;
         if ( auxAttr == null )
         {
@@ -374,20 +461,31 @@
                 return null;
             }
             auxAttr.setName( auxName );
-            ccMgr.registryAttrPut( auxAttr );
+            compositeCacheManager.registryAttrPut( auxAttr );
         }
 
         auxAttr = auxAttr.copy();
 
-        log.debug( "Parsing options for '" + attrName + "'" );
+        if ( log.isDebugEnabled() )
+        {
+            log.debug( "Parsing options for '" + attrName + "'" );
+        }
+
         PropertySetter.setProperties( auxAttr, props, attrName + "." );
         auxAttr.setCacheName( regName );
 
-        log.debug( "End of parsing for '" + attrName + "'" );
+        if ( log.isDebugEnabled() )
+        {
+            log.debug( "End of parsing for '" + attrName + "'" );
+        }
 
         // GET CACHE FROM FACTORY WITH ATTRIBUTES
         auxAttr.setCacheName( regName );
-        auxCache = auxFac.createCache( auxAttr, cache );
+        // Consider putting the compositeCache back in the factory interface
+        // since the manager may not know about it at this point.
+        // need to make sure the maanger already has the cache
+        // before the auxiliary is created.
+        auxCache = auxFac.createCache( auxAttr, compositeCacheManager );
         return auxCache;
     }
 }

Modified: jakarta/jcs/trunk/src/java/org/apache/jcs/engine/control/CompositeCacheManager.java
URL: http://svn.apache.org/viewcvs/jakarta/jcs/trunk/src/java/org/apache/jcs/engine/control/CompositeCacheManager.java?rev=230748&r1=230747&r2=230748&view=diff
==============================================================================
--- jakarta/jcs/trunk/src/java/org/apache/jcs/engine/control/CompositeCacheManager.java (original)
+++ jakarta/jcs/trunk/src/java/org/apache/jcs/engine/control/CompositeCacheManager.java Sun Aug  7 21:21:01 2005
@@ -24,6 +24,7 @@
 import java.util.Hashtable;
 import java.util.Iterator;
 import java.util.Properties;
+import java.util.Set;
 
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
@@ -35,6 +36,7 @@
 import org.apache.jcs.engine.ElementAttributes;
 import org.apache.jcs.engine.behavior.ICacheType;
 import org.apache.jcs.engine.behavior.ICompositeCacheAttributes;
+import org.apache.jcs.engine.behavior.ICompositeCacheManager;
 import org.apache.jcs.engine.behavior.IElementAttributes;
 import org.apache.jcs.engine.stats.CacheStats;
 import org.apache.jcs.engine.stats.behavior.ICacheStats;
@@ -42,7 +44,7 @@
 
 /** Manages a composite cache. */
 public class CompositeCacheManager
-    implements IRemoteCacheConstants, Serializable
+    implements IRemoteCacheConstants, Serializable, ICompositeCacheManager
 {
     private final static Log log = LogFactory.getLog( CompositeCacheManager.class );
 
@@ -76,6 +78,10 @@
     /** The Singleton Instance */
     protected static CompositeCacheManager instance;
 
+    private static final String SYSTEM_PROPERTY_KEY_PREFIX = "jcs";
+
+    private static final boolean DEFAULT_USE_SYSTEM_PROPERTIES = true;
+
     /**
      * Gets the CacheHub instance. For backward compatibility, if this creates
      * the instance it will attempt to configure it with the default
@@ -150,7 +156,7 @@
     }
 
     /**
-     * Configure from specific properties file
+     * Configure from specific properties file.
      * 
      * @param propFile
      *            Path <u>within classpath </u> to load configuration from
@@ -190,26 +196,71 @@
                     // Ignored
                 }
             }
-            
+
         }
         else
         {
             log.error( "Failed to load properties for name [" + propFile + "]" );
-            throw new IllegalStateException( "Failed to load properties for name [" + propFile + "]" );            
+            throw new IllegalStateException( "Failed to load properties for name [" + propFile + "]" );
         }
 
         configure( props );
     }
 
     /**
-     * Configure from properties object
+     * Configure from properties object.
+     * <p>
+     * This method will call confiure, instructing it to use ssytem properties
+     * as a default.
      * 
      * @param props
      */
     public void configure( Properties props )
     {
+        configure( props, DEFAULT_USE_SYSTEM_PROPERTIES );
+    }
+
+    /**
+     * Configure from properties object, overriding with values from the system
+     * properteis if instructed.
+     * <p>
+     * You can override a specif value by passing in a ssytem property:
+     * <p>
+     * For example, you could override this value in the cache.ccf file by
+     * starting up your program with the argument:
+     * -Djcs.auxiliary.LTCP.attributes.TcpListenerPort=1111
+     * 
+     * 
+     * @param props
+     * @param useSystemProperties --
+     *            if true, values starting with jcs will be put into the props
+     *            file prior to configuring the cache.
+     */
+    public void configure( Properties props, boolean useSystemProperties )
+    {
         if ( props != null )
         {
+
+            if ( useSystemProperties )
+            {
+                // override any setting with values from the system properties.
+                Properties sysProps = System.getProperties();
+                Set keys = sysProps.keySet();
+                Iterator keyIt = keys.iterator();
+                while ( keyIt.hasNext() )
+                {
+                    String key = (String) keyIt.next();
+                    if ( key.startsWith( SYSTEM_PROPERTY_KEY_PREFIX ) )
+                    {
+                        if ( log.isInfoEnabled() )
+                        {
+                            log.info( "Using system property [[" + key + "] [" + sysProps.getProperty( key ) + "]]" );
+                        }
+                        props.put( key, sysProps.getProperty( key ) );
+                    }
+                }
+            }
+
             // set the props value and then configure the ThreadPoolManager
             ThreadPoolManager.setProps( props );
             ThreadPoolManager poolMgr = ThreadPoolManager.getInstance();

Modified: jakarta/jcs/trunk/src/test/org/apache/jcs/auxiliary/lateral/socket/tcp/TestTCPLateral.java
URL: http://svn.apache.org/viewcvs/jakarta/jcs/trunk/src/test/org/apache/jcs/auxiliary/lateral/socket/tcp/TestTCPLateral.java?rev=230748&r1=230747&r2=230748&view=diff
==============================================================================
--- jakarta/jcs/trunk/src/test/org/apache/jcs/auxiliary/lateral/socket/tcp/TestTCPLateral.java (original)
+++ jakarta/jcs/trunk/src/test/org/apache/jcs/auxiliary/lateral/socket/tcp/TestTCPLateral.java Sun Aug  7 21:21:01 2005
@@ -4,6 +4,8 @@
 import org.apache.jcs.auxiliary.lateral.LateralCacheAttributes;
 import org.apache.jcs.auxiliary.lateral.LateralElementDescriptor;
 import org.apache.jcs.engine.CacheElement;
+import org.apache.jcs.engine.behavior.ICompositeCacheManager;
+import org.apache.jcs.engine.control.CompositeCacheManager;
 
 import junit.framework.TestCase;
 
@@ -32,7 +34,7 @@
      * 
      * @throws Exception
      */
-    public void testSimpleSend()
+    public void SkiptestSimpleSend()
         throws Exception
     {
 
@@ -43,8 +45,10 @@
         lac.setTcpServer( "localhost" + ":" + 8111 );
         lac.setTcpListenerPort( 8111 );
 
+        ICompositeCacheManager cacheMgr = CompositeCacheManager.getInstance();
+
         // start the listener
-        LateralTCPListener listener = (LateralTCPListener) LateralTCPListener.getInstance( lac );
+        LateralTCPListener listener = (LateralTCPListener) LateralTCPListener.getInstance( lac, cacheMgr );
 
         // send to the listener
         LateralTCPSender lur = new LateralTCPSender( lac );

Modified: jakarta/jcs/trunk/src/test/org/apache/jcs/auxiliary/lateral/socket/tcp/discovery/TestUDPDiscovery.java
URL: http://svn.apache.org/viewcvs/jakarta/jcs/trunk/src/test/org/apache/jcs/auxiliary/lateral/socket/tcp/discovery/TestUDPDiscovery.java?rev=230748&r1=230747&r2=230748&view=diff
==============================================================================
--- jakarta/jcs/trunk/src/test/org/apache/jcs/auxiliary/lateral/socket/tcp/discovery/TestUDPDiscovery.java (original)
+++ jakarta/jcs/trunk/src/test/org/apache/jcs/auxiliary/lateral/socket/tcp/discovery/TestUDPDiscovery.java Sun Aug  7 21:21:01 2005
@@ -9,6 +9,8 @@
 import org.apache.jcs.auxiliary.lateral.LateralCacheAttributes;
 import org.apache.jcs.auxiliary.lateral.LateralCacheNoWait;
 import org.apache.jcs.auxiliary.lateral.LateralCacheNoWaitFacade;
+import org.apache.jcs.engine.behavior.ICompositeCacheManager;
+import org.apache.jcs.engine.control.CompositeCacheManager;
 
 /**
  * 
@@ -59,8 +61,10 @@
         lac.setTransmissionType( LateralCacheAttributes.TCP );
         lac.setTcpServer( "localhost" + ":" + 1111 );
 
+        ICompositeCacheManager cacheMgr = CompositeCacheManager.getInstance();
+        
         // create the service
-        UDPDiscoveryService service = new UDPDiscoveryService( lac );
+        UDPDiscoveryService service = new UDPDiscoveryService( lac, cacheMgr );
 
         // create a no wait facade for the service
         ArrayList noWaits = new ArrayList();
@@ -71,7 +75,7 @@
         service.addNoWaitFacade( lcnwf, "testCache1" );
 
         // create a receiver with the service
-        UDPDiscoveryReceiver receiver = new UDPDiscoveryReceiver( service, "228.5.6.7", 6789 );
+        UDPDiscoveryReceiver receiver = new UDPDiscoveryReceiver( service, "228.5.6.7", 6789, cacheMgr );
         Thread t = new Thread( receiver );
         t.start();
 



---------------------------------------------------------------------
To unsubscribe, e-mail: jcs-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: jcs-dev-help@jakarta.apache.org


Mime
View raw message