commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mt...@apache.org
Subject svn commit: r817083 - in /commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime: ./ platform/darwin/ platform/hpux/ platform/linux/ platform/solaris/ platform/windows/
Date Sun, 20 Sep 2009 19:28:56 GMT
Author: mturk
Date: Sun Sep 20 19:28:55 2009
New Revision: 817083

URL: http://svn.apache.org/viewvc?rev=817083&view=rev
Log:
Favor platform Default.properties over general Default.properties

Added:
    commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/Default.properties
      - copied unchanged from r816985, commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/DefaultProperties.properties
    commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/platform/darwin/Default.properties
      - copied unchanged from r817078, commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/platform/darwin/DefaultProperties.properties
    commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/platform/hpux/Default.properties
      - copied unchanged from r817078, commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/platform/hpux/DefaultProperties.properties
    commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/platform/linux/Default.properties
      - copied unchanged from r817078, commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/platform/linux/DefaultProperties.properties
    commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/platform/solaris/Default.properties
      - copied unchanged from r817078, commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/platform/solaris/DefaultProperties.properties
    commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/platform/windows/Default.properties
      - copied unchanged from r817078, commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/platform/windows/DefaultProperties.properties
Removed:
    commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/DefaultProperties.properties
    commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/platform/darwin/DefaultProperties.properties
    commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/platform/hpux/DefaultProperties.properties
    commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/platform/linux/DefaultProperties.properties
    commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/platform/solaris/DefaultProperties.properties
    commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/platform/windows/DefaultProperties.properties
Modified:
    commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/Properties.java

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=817083&r1=817082&r2=817083&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
Sun Sep 20 19:28:55 2009
@@ -21,23 +21,30 @@
 
 /** The Properties class is used to obtain the various
  * Apache Commons Runtime settings. Their default values are
- * specified inside {@code DefaultProperties.properties} file.
+ * specified inside {@code Default.properties} file.
  * @since Runtime 1.0
  *
  */
 public final class Properties
 {
-
     private Properties() {
         try {
-            String name = Properties.class.getPackage().getName() + ".DefaultProperties";
-            bundle = ResourceBundle.getBundle(name);
+            String name = Properties.class.getPackage().getName() + ".Default";
+            defres = ResourceBundle.getBundle(name);
+        } catch (MissingResourceException ex) {
+            // Ignore
+        }
+        try {
+            String name = Properties.class.getPackage().getName() + ".platform." +
+                                            SystemId.getSysname() + ".Default";
+            sysres = ResourceBundle.getBundle(name);
         } catch (MissingResourceException ex) {
             // Ignore
         }
     }
 
-    private ResourceBundle bundle;
+    private ResourceBundle defres;
+    private ResourceBundle sysres;
     private static Properties instance;
 
     static {
@@ -47,11 +54,6 @@
         }
     }
 
-    private ResourceBundle getBundle()
-    {
-        return bundle;
-    }
-
     /** Get resource property value.
      * @param key Resource name to get.
      * @param def Default value in case {@code key} was not found.
@@ -59,13 +61,26 @@
     public static String get(String key, String def)
     {
         String rv = def;
-        if (instance == null)
-            return rv;
-        if (instance.getBundle() != null) {
+        if (instance.sysres != null) {
             try {
-                rv = instance.getBundle().getString(key);
+                rv = instance.sysres.getString(key);
             } catch (MissingResourceException mx) {
-                // Ignore
+                if (instance.defres != null) {
+                    try {
+                        rv = instance.defres.getString(key);
+                    } catch (MissingResourceException ex) {
+                        // Ignore
+                    }
+                }
+            }
+        }
+        else {
+            if (instance.defres != null) {
+                try {
+                    rv = instance.defres.getString(key);
+                } catch (MissingResourceException ex) {
+                    // Ignore
+                }
             }
         }
         return rv;
@@ -82,19 +97,11 @@
 
     private static int getI(String key, int def)
     {
-        int rv = def;
-        if (instance == null)
-            return rv;
-        if (instance.getBundle() != null) {
-            try {
-                rv = Integer.parseInt(instance.getBundle().getString(key));
-            } catch (NumberFormatException ex) {
-                // Ignore
-            } catch (MissingResourceException mx) {
-                // Ignore
-            }
-        }
-        return rv;
+        String val = get(key);
+        if (val != null)
+            return Integer.parseInt(val);
+        else
+            return def;
     }
 
     private static int getI(String key)
@@ -109,19 +116,11 @@
 
     private static long getL(String key, long def)
     {
-        long rv = def;
-        if (instance == null)
-            return rv;
-        if (instance.getBundle() != null) {
-            try {
-                rv = Long.parseLong(instance.getBundle().getString(key));
-            } catch (NumberFormatException ex) {
-                // Ignore
-            } catch (MissingResourceException mx) {
-                // Ignore
-            }
-        }
-        return rv;
+        String val = get(key);
+        if (val != null)
+            return Long.parseLong(val);
+        else
+            return def;
     }
 
     private static long getL(String key)



Mime
View raw message