summaryrefslogtreecommitdiffstats
path: root/sca-java-2.x/trunk
diff options
context:
space:
mode:
Diffstat (limited to 'sca-java-2.x/trunk')
-rw-r--r--sca-java-2.x/trunk/modules/node-api/src/main/java/org/apache/tuscany/sca/node/NodeFactory.java24
1 files changed, 24 insertions, 0 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 b8bfbee356..e4df78ffde 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
@@ -31,8 +31,10 @@ 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;
import org.apache.tuscany.sca.node.configuration.DefaultNodeConfigurationFactory;
import org.apache.tuscany.sca.node.configuration.NodeConfiguration;
@@ -192,6 +194,28 @@ public abstract class NodeFactory extends DefaultNodeConfigurationFactory {
return nodeFactory;
}
+ public static NodeFactory newInstance(Properties properties) {
+ Map<String, Map<String, String>> attributes = new HashMap<String, Map<String,String>>();
+ for (String key : properties.stringPropertyNames()) {
+ int i = key.lastIndexOf('.');
+ String mk, m2k;
+ if (i > -1) {
+ mk = key.substring(0, i);
+ m2k = key.substring(i+1);
+ } else {
+ mk = "system";
+ m2k = key;
+ }
+ Map<String,String> m2 = attributes.get(mk);
+ if (m2 == null) {
+ m2 = new HashMap<String, String>();
+ attributes.put(mk, m2);
+ }
+ m2.put(m2k, properties.getProperty(key));
+ }
+ return newInstance(attributes);
+ }
+
/**
* Configure the NodeFactory instance
* @param attributes