diff options
author | antelder <antelder@13f79535-47bb-0310-9956-ffa450edef68> | 2010-04-15 13:48:37 +0000 |
---|---|---|
committer | antelder <antelder@13f79535-47bb-0310-9956-ffa450edef68> | 2010-04-15 13:48:37 +0000 |
commit | 1ca1824973203d8ea3de05415a21fd999d794745 (patch) | |
tree | 5c7ea85865d351b8d79cb78637828a76805b273c /sca-java-2.x/trunk/modules/node-api/src/main/java/org/apache/tuscany/sca/node/NodeFactory.java | |
parent | aa31bdbc3f3ae361469a0f5b8321316d7169d91f (diff) |
Fix properties file url reading
git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@934403 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'sca-java-2.x/trunk/modules/node-api/src/main/java/org/apache/tuscany/sca/node/NodeFactory.java')
-rw-r--r-- | sca-java-2.x/trunk/modules/node-api/src/main/java/org/apache/tuscany/sca/node/NodeFactory.java | 15 |
1 files changed, 8 insertions, 7 deletions
diff --git a/sca-java-2.x/trunk/modules/node-api/src/main/java/org/apache/tuscany/sca/node/NodeFactory.java b/sca-java-2.x/trunk/modules/node-api/src/main/java/org/apache/tuscany/sca/node/NodeFactory.java index a44eecc52c..4588941f47 100644 --- a/sca-java-2.x/trunk/modules/node-api/src/main/java/org/apache/tuscany/sca/node/NodeFactory.java +++ b/sca-java-2.x/trunk/modules/node-api/src/main/java/org/apache/tuscany/sca/node/NodeFactory.java @@ -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 extends DefaultNodeConfigurationFactory { 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 extends DefaultNodeConfigurationFactory { 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 extends DefaultNodeConfigurationFactory { * 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 extends DefaultNodeConfigurationFactory { } 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) { |