You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tuscany.apache.org by an...@apache.org on 2010/04/15 15:48:37 UTC

svn commit: r934403 - /tuscany/sca-java-2.x/trunk/modules/node-api/src/main/java/org/apache/tuscany/sca/node/NodeFactory.java

Author: antelder
Date: Thu Apr 15 13:48:37 2010
New Revision: 934403

URL: http://svn.apache.org/viewvc?rev=934403&view=rev
Log:
Fix properties file url reading

Modified:
    tuscany/sca-java-2.x/trunk/modules/node-api/src/main/java/org/apache/tuscany/sca/node/NodeFactory.java

Modified: tuscany/sca-java-2.x/trunk/modules/node-api/src/main/java/org/apache/tuscany/sca/node/NodeFactory.java
URL: http://svn.apache.org/viewvc/tuscany/sca-java-2.x/trunk/modules/node-api/src/main/java/org/apache/tuscany/sca/node/NodeFactory.java?rev=934403&r1=934402&r2=934403&view=diff
==============================================================================
--- tuscany/sca-java-2.x/trunk/modules/node-api/src/main/java/org/apache/tuscany/sca/node/NodeFactory.java (original)
+++ tuscany/sca-java-2.x/trunk/modules/node-api/src/main/java/org/apache/tuscany/sca/node/NodeFactory.java Thu Apr 15 13:48:37 2010
@@ -34,6 +34,7 @@ import java.net.URL;
 import java.net.URLConnection;
 import java.util.ArrayList;
 import java.util.Arrays;
+import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
 import java.util.Properties;
@@ -204,6 +205,7 @@ public abstract class NodeFactory extend
             Class<?> factoryClass = getFactoryImplClass();
             nodeFactory = (NodeFactory)factoryClass.newInstance();
             nodeFactory.properties = properties;
+            nodeFactory.configure(new HashMap<String, Map<String,String>>());
         } catch (Exception e) {
             throw new ServiceRuntimeException(e);
         }
@@ -216,7 +218,7 @@ public abstract class NodeFactory extend
             properties = new Properties();
         } else if (configURI.startsWith("properties:")) {
             try {
-                properties = loadProperties(configURI);
+                properties = loadProperties(configURI.substring("properties:".length()));
             } catch (IOException e) {
                 throw new ServiceRuntimeException(e);
             }
@@ -244,11 +246,10 @@ public abstract class NodeFactory extend
      * load the properties from external URL or a relative file
      * properties:<url to properties file>
      */
-    private static Properties loadProperties(String configURI) throws IOException {
+    private static Properties loadProperties(String propsURL) throws IOException {
 
-        String remaining = URI.create(configURI).getSchemeSpecificPart();
         Properties properties = new Properties();
-        File file = new File(remaining);
+        File file = new File(propsURL);
 
         InputStream inputStream = null;
         if (file.exists()) {
@@ -256,11 +257,11 @@ public abstract class NodeFactory extend
         } else {
             URL url = null;
             try {
-                url = new URL(remaining);
+                url = new URL(propsURL);
             } catch (MalformedURLException e) {
-                inputStream = Thread.currentThread().getContextClassLoader().getResourceAsStream(remaining);
+                inputStream = Thread.currentThread().getContextClassLoader().getResourceAsStream(propsURL);
                 if (inputStream == null) {
-                    throw new IOException("File does not exist: " + remaining + ", could not be found on the classpath and is not a valid URL: " + e);
+                    throw new IOException("File does not exist: " + propsURL + ", could not be found on the classpath and is not a valid URL: " + e);
                 }
             }
             if (inputStream == null && url != null) {