commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mt...@apache.org
Subject svn commit: r765221 - in /commons/sandbox/runtime/trunk/src: main/java/org/apache/commons/runtime/DefaultProperties.properties main/java/org/apache/commons/runtime/Properties.java test/org/apache/commons/runtime/TestProperties.java
Date Wed, 15 Apr 2009 14:52:52 GMT
Author: mturk
Date: Wed Apr 15 14:52:51 2009
New Revision: 765221

URL: http://svn.apache.org/viewvc?rev=765221&view=rev
Log:
Add default value methods for Properties

Modified:
    commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/DefaultProperties.properties
    commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/Properties.java
    commons/sandbox/runtime/trunk/src/test/org/apache/commons/runtime/TestProperties.java

Modified: commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/DefaultProperties.properties
URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/DefaultProperties.properties?rev=765221&r1=765220&r2=765221&view=diff
==============================================================================
--- commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/DefaultProperties.properties
(original)
+++ commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/DefaultProperties.properties
Wed Apr 15 14:52:51 2009
@@ -24,5 +24,5 @@
 # Indicates the caching policy for lookups on cpu object.
 # The TTL is number of milliseconds between two counter lookups.
 cpu.cache.ttl = 100
-cpu.cache.size = 16
+cpu.cache.ttl.min = 1
 

Modified: commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/Properties.java
URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/Properties.java?rev=765221&r1=765220&r2=765221&view=diff
==============================================================================
--- commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/Properties.java
(original)
+++ commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/Properties.java
Wed Apr 15 14:52:51 2009
@@ -30,11 +30,8 @@
     private Properties() {
         try {
             String name = Properties.class.getPackage().getName() + ".DefaultProperties";
-            System.out.println("File is " + name);
             bundle = ResourceBundle.getBundle(name);
-
         } catch (MissingResourceException ex) {
-            System.out.println("Exception ");
             // Ignore
         }
     }
@@ -54,21 +51,31 @@
         return bundle;
     }
 
-    private static String getString(String key)
+    private static String getString(String key, String def)
     {
+        String rv = def;
+        if (instance == null)
+            return rv;
         if (instance.getBundle() != null) {
             try {
-                return instance.getBundle().getString(key);
+                rv = instance.getBundle().getString(key);
             } catch (MissingResourceException mx) {
                 // Ignore
             }
         }
-        return null;
+        return rv;
     }
 
-    private static int getInt(String key)
+    private static String getString(String key)
     {
-        int rv = 0;
+        return getString(key, null);
+    }
+
+    private static int getInt(String key, int def)
+    {
+        int rv = def;
+        if (instance == null)
+            return rv;
         if (instance.getBundle() != null) {
             try {
                 rv = Integer.parseInt(instance.getBundle().getString(key));
@@ -81,9 +88,16 @@
         return rv;
     }
 
-    private static long getLong(String key)
+    private static int getInt(String key)
+    {
+        return getInt(key, 0);
+    }
+
+    private static long getLong(String key, long def)
     {
-        long rv = 0;
+        long rv = def;
+        if (instance == null)
+            return rv;
         if (instance.getBundle() != null) {
             try {
                 rv = Long.parseLong(instance.getBundle().getString(key));
@@ -96,11 +110,16 @@
         return rv;
     }
 
+    private static long getLong(String key)
+    {
+        return getLong(key, 0L);
+    }
+
     /** Interval in milliseconds for a Cpu data caching.
      */
     public static long          CPU_CACHE_TTL;
-    /** Maximum number of Cpu instances to cache.
+    /** Minimum interval of Cpu data cache.
      */
-    public static final int     CPU_CACHE_SIZE      = getInt("cpu.cache.size");
+    public static final long    CPU_CACHE_TTL_MIN   = getLong("cpu.cache.ttl.min", 1L);
 
 }

Modified: commons/sandbox/runtime/trunk/src/test/org/apache/commons/runtime/TestProperties.java
URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/test/org/apache/commons/runtime/TestProperties.java?rev=765221&r1=765220&r2=765221&view=diff
==============================================================================
--- commons/sandbox/runtime/trunk/src/test/org/apache/commons/runtime/TestProperties.java
(original)
+++ commons/sandbox/runtime/trunk/src/test/org/apache/commons/runtime/TestProperties.java
Wed Apr 15 14:52:51 2009
@@ -49,12 +49,11 @@
         throws Exception
     {
         long l;
-        int i;
 
         l = org.apache.commons.runtime.Properties.CPU_CACHE_TTL;
         assertEquals("Value ", 100, l);
-        i = org.apache.commons.runtime.Properties.CPU_CACHE_SIZE;
-        assertEquals("Value ", 16, i);
+        l = org.apache.commons.runtime.Properties.CPU_CACHE_TTL_MIN;
+        assertEquals("Value ", 1, l);
 
     }
 }



Mime
View raw message