You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ofbiz.apache.org by do...@apache.org on 2010/04/01 06:44:58 UTC

svn commit: r929835 - /ofbiz/trunk/framework/base/src/org/ofbiz/base/util/cache/UtilCache.java

Author: doogie
Date: Thu Apr  1 04:44:57 2010
New Revision: 929835

URL: http://svn.apache.org/viewvc?rev=929835&view=rev
Log:
Refactored getPropertyParam, so it is responsible for logging exception
warnings.

Modified:
    ofbiz/trunk/framework/base/src/org/ofbiz/base/util/cache/UtilCache.java

Modified: ofbiz/trunk/framework/base/src/org/ofbiz/base/util/cache/UtilCache.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/base/src/org/ofbiz/base/util/cache/UtilCache.java?rev=929835&r1=929834&r2=929835&view=diff
==============================================================================
--- ofbiz/trunk/framework/base/src/org/ofbiz/base/util/cache/UtilCache.java (original)
+++ ofbiz/trunk/framework/base/src/org/ofbiz/base/util/cache/UtilCache.java Thu Apr  1 04:44:57 2010
@@ -135,17 +135,20 @@ public class UtilCache<K, V> implements 
     }
 
     public static String getPropertyParam(ResourceBundle res, String[] propNames, String parameter) {
-        String value = null;
-        for (String propName: propNames) {
-            try {
-                value = res.getString(propName + '.' + parameter);
-            } catch (MissingResourceException e) {}
+        try {
+            for (String propName: propNames) {
+                try {
+                    return res.getString(propName + '.' + parameter);
+                } catch (MissingResourceException e) {}
+            }
+            // don't need this, just return null
+            //if (value == null) {
+            //    throw new MissingResourceException("Can't find resource for bundle", res.getClass().getName(), Arrays.asList(propNames) + "." + parameter);
+            //}
+        } catch (Exception e) {
+            Debug.logWarning(e, "Error getting " + parameter + " value from cache.properties file for propNames: " + propNames, module);
         }
-        // don't need this, just return null
-        //if (value == null) {
-        //    throw new MissingResourceException("Can't find resource for bundle", res.getClass().getName(), Arrays.asList(propNames) + "." + parameter);
-        //}
-        return value;
+        return null;
     }
 
     protected void setPropertiesParams(String cacheName) {
@@ -156,48 +159,28 @@ public class UtilCache<K, V> implements 
         ResourceBundle res = ResourceBundle.getBundle("cache");
 
         if (res != null) {
-            try {
-                String value = getPropertyParam(res, propNames, "maxSize");
-                if (UtilValidate.isNotEmpty(value)) {
-                    this.sizeLimit = Integer.parseInt(value);
-                }
-            } catch (Exception e) {
-                Debug.logWarning(e, "Error getting maxSize value from cache.properties file for propNames: " + propNames, module);
-            }
-            try {
-                String value = getPropertyParam(res, propNames, "maxInMemory");
-                if (UtilValidate.isNotEmpty(value)) {
-                    this.maxInMemory = Integer.parseInt(value);
-                }
-            } catch (Exception e) {
-                Debug.logWarning(e, "Error getting maxInMemory value from cache.properties file for propNames: " + propNames, module);
-            }
-            try {
-                String value = getPropertyParam(res, propNames, "expireTime");
-                if (UtilValidate.isNotEmpty(value)) {
-                    this.expireTime = Long.parseLong(value);
-                }
-            } catch (Exception e) {
-                Debug.logWarning(e, "Error getting expireTime value from cache.properties file for propNames: " + propNames, module);
-            }
-            try {
-                String value = getPropertyParam(res, propNames, "useSoftReference");
-                if (value != null) {
-                    useSoftReference = "true".equals(value);
-                }
-            } catch (Exception e) {
-                Debug.logWarning(e, "Error getting useSoftReference value from cache.properties file for propNames: " + propNames, module);
-            }
-            try {
-                String value = getPropertyParam(res, propNames, "useFileSystemStore");
-                if (value != null) {
-                    useFileSystemStore = "true".equals(value);
-                }
-            } catch (Exception e) {
-                Debug.logWarning(e, "Error getting useFileSystemStore value from cache.properties file for propNames: " + propNames, module);
+            String value = getPropertyParam(res, propNames, "maxSize");
+            if (UtilValidate.isNotEmpty(value)) {
+                this.sizeLimit = Integer.parseInt(value);
+            }
+            value = getPropertyParam(res, propNames, "maxInMemory");
+            if (UtilValidate.isNotEmpty(value)) {
+                this.maxInMemory = Integer.parseInt(value);
+            }
+            value = getPropertyParam(res, propNames, "expireTime");
+            if (UtilValidate.isNotEmpty(value)) {
+                this.expireTime = Long.parseLong(value);
+            }
+            value = getPropertyParam(res, propNames, "useSoftReference");
+            if (value != null) {
+                useSoftReference = "true".equals(value);
+            }
+            value = getPropertyParam(res, propNames, "useFileSystemStore");
+            if (value != null) {
+                useFileSystemStore = "true".equals(value);
             }
             try {
-                String value = res.getString("cache.file.store");
+                value = res.getString("cache.file.store");
                 if (value != null) {
                     fileStore = value;
                 }