Author: mturk Date: Wed Apr 15 11:53:22 2009 New Revision: 765146 URL: http://svn.apache.org/viewvc?rev=765146&view=rev Log: Add more Properties. Not very much usefull for the moment, but allows to test the static/final property fields
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=765146&r1=765145&r2=765146&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 11:53:22 2009 @@ -24,4 +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 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=765146&r1=765145&r2=765146&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 11:53:22 2009 @@ -57,10 +57,13 @@ private static String getString(String key) { if (instance.getBundle() != null) { - return instance.getBundle().getString(key); + try { + return instance.getBundle().getString(key); + } catch (MissingResourceException mx) { + // Ignore + } } - else - return null; + return null; } private static int getInt(String key) @@ -71,6 +74,8 @@ rv = Integer.parseInt(instance.getBundle().getString(key)); } catch (NumberFormatException ex) { // Ignore + } catch (MissingResourceException mx) { + // Ignore } } return rv; @@ -84,6 +89,8 @@ rv = Long.parseLong(instance.getBundle().getString(key)); } catch (NumberFormatException ex) { // Ignore + } catch (MissingResourceException mx) { + // Ignore } } return rv; @@ -91,5 +98,9 @@ /** Interval in milliseconds for a Cpu data caching. */ - public static long CPU_CACHE_TTL; + public static long CPU_CACHE_TTL; + /** Maximum number of Cpu instances to cache. + */ + public static final int CPU_CACHE_SIZE = getInt("cpu.cache.size"); + } 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=765146&r1=765145&r2=765146&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 11:53:22 2009 @@ -49,9 +49,12 @@ 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); } }