You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by tv...@apache.org on 2011/10/30 19:34:09 UTC

svn commit: r1195208 - in /commons/proper/jcs/trunk/src/java/org/apache/jcs: JCS.java engine/control/CompositeCacheManager.java

Author: tv
Date: Sun Oct 30 18:34:09 2011
New Revision: 1195208

URL: http://svn.apache.org/viewvc?rev=1195208&view=rev
Log:
Add method for programmatic configuration to JCS. Fixes JCS-11

Modified:
    commons/proper/jcs/trunk/src/java/org/apache/jcs/JCS.java
    commons/proper/jcs/trunk/src/java/org/apache/jcs/engine/control/CompositeCacheManager.java

Modified: commons/proper/jcs/trunk/src/java/org/apache/jcs/JCS.java
URL: http://svn.apache.org/viewvc/commons/proper/jcs/trunk/src/java/org/apache/jcs/JCS.java?rev=1195208&r1=1195207&r2=1195208&view=diff
==============================================================================
--- commons/proper/jcs/trunk/src/java/org/apache/jcs/JCS.java (original)
+++ commons/proper/jcs/trunk/src/java/org/apache/jcs/JCS.java Sun Oct 30 18:34:09 2011
@@ -19,6 +19,8 @@ package org.apache.jcs;
  * under the License.
  */
 
+import java.util.Properties;
+
 import org.apache.jcs.access.GroupCacheAccess;
 import org.apache.jcs.access.exception.CacheException;
 import org.apache.jcs.engine.behavior.ICompositeCacheAttributes;
@@ -38,6 +40,9 @@ public class JCS
     /** cache.ccf alternative. */
     private static String configFilename = null;
 
+    /** alternative configuration properties */
+    private static Properties configProps = null;
+
     /** The manager returns cache instances. */
     private static CompositeCacheManager cacheMgr;
 
@@ -91,16 +96,20 @@ public class JCS
     {
         if ( cacheMgr == null )
         {
-            if ( configFilename == null )
+            if ( configProps != null )
             {
-                cacheMgr = CompositeCacheManager.getInstance();
+                cacheMgr = CompositeCacheManager.getUnconfiguredInstance();
+                cacheMgr.configure( configProps );
             }
-            else
+            else if ( configFilename != null )
             {
                 cacheMgr = CompositeCacheManager.getUnconfiguredInstance();
-
                 cacheMgr.configure( configFilename );
             }
+            else
+            {
+                cacheMgr = CompositeCacheManager.getInstance();
+            }
         }
     }
 
@@ -114,4 +123,15 @@ public class JCS
     {
         JCS.configFilename = configFilename;
     }
+
+    /**
+     * Set the properties that the cache manager will be initialized with. Only
+     * matters before the instance is initialized.
+     *
+     * @param configProps
+     */
+    public static void setConfigProperties( Properties configProps )
+    {
+        JCS.configProps = configProps;
+    }
 }

Modified: commons/proper/jcs/trunk/src/java/org/apache/jcs/engine/control/CompositeCacheManager.java
URL: http://svn.apache.org/viewvc/commons/proper/jcs/trunk/src/java/org/apache/jcs/engine/control/CompositeCacheManager.java?rev=1195208&r1=1195207&r2=1195208&view=diff
==============================================================================
--- commons/proper/jcs/trunk/src/java/org/apache/jcs/engine/control/CompositeCacheManager.java (original)
+++ commons/proper/jcs/trunk/src/java/org/apache/jcs/engine/control/CompositeCacheManager.java Sun Oct 30 18:34:09 2011
@@ -302,10 +302,10 @@ public class CompositeCacheManager
     }
 
     /**
-     * Configure from properties object, overriding with values from the system properteis if
+     * Configure from properties object, overriding with values from the system properties if
      * instructed.
      * <p>
-     * You can override a specific value by passing in a ssytem property:
+     * You can override a specific value by passing in a system 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