You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ofbiz.apache.org by ad...@apache.org on 2015/01/06 21:21:29 UTC

svn commit: r1649934 - /ofbiz/trunk/framework/base/src/org/ofbiz/base/location/FlexibleLocation.java

Author: adrianc
Date: Tue Jan  6 20:21:28 2015
New Revision: 1649934

URL: http://svn.apache.org/r1649934
Log:
Fixed a bug in FlexibleLocation.java where the optional locationresolvers.properties file was not being loaded due to static initializer recursion.

Modified:
    ofbiz/trunk/framework/base/src/org/ofbiz/base/location/FlexibleLocation.java

Modified: ofbiz/trunk/framework/base/src/org/ofbiz/base/location/FlexibleLocation.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/base/src/org/ofbiz/base/location/FlexibleLocation.java?rev=1649934&r1=1649933&r2=1649934&view=diff
==============================================================================
--- ofbiz/trunk/framework/base/src/org/ofbiz/base/location/FlexibleLocation.java (original)
+++ ofbiz/trunk/framework/base/src/org/ofbiz/base/location/FlexibleLocation.java Tue Jan  6 20:21:28 2015
@@ -23,10 +23,9 @@ import java.net.URL;
 import java.util.Collections;
 import java.util.HashMap;
 import java.util.Map;
-import java.util.Properties;
 import java.util.Map.Entry;
+import java.util.Properties;
 
-import org.ofbiz.base.util.Debug;
 import org.ofbiz.base.util.UtilProperties;
 import org.ofbiz.base.util.UtilValidate;
 
@@ -34,10 +33,8 @@ import org.ofbiz.base.util.UtilValidate;
  * A special location resolver that uses Strings like URLs, but with more options.
  *
  */
-
 public final class FlexibleLocation {
 
-    public static final String module = FlexibleLocation.class.getName();
     private static final Map<String, LocationResolver> locationResolvers;
 
     static {
@@ -52,7 +49,11 @@ public final class FlexibleLocation {
         resolverMap.put("ofbizhome", new OFBizHomeLocationResolver());
         resolverMap.put("component", new ComponentLocationResolver());
         try {
-            Properties properties = UtilProperties.getProperties("locationresolvers.properties");
+            /* Note that the file must be placed in framework/base/config -
+             * because this class may be initialized before all components
+             * are loaded.
+             */
+            Properties properties = UtilProperties.createProperties("locationresolvers.properties");
             if (properties != null) {
                 ClassLoader classLoader = Thread.currentThread().getContextClassLoader();
                 for (Entry<Object, Object> entry : properties.entrySet()) {
@@ -63,7 +64,7 @@ public final class FlexibleLocation {
                 }
             }
         } catch (Throwable e) {
-            Debug.logWarning(e, "Error while loading resolvers from locationresolvers.properties: ", module);
+            System.out.println("Exception thrown while loading locationresolvers.properties: " + e);
         }
         locationResolvers = Collections.unmodifiableMap(resolverMap);
     }