diff options
Diffstat (limited to 'sca-java-2.x/trunk/modules/node-api/src')
2 files changed, 34 insertions, 0 deletions
diff --git a/sca-java-2.x/trunk/modules/node-api/src/main/java/org/apache/tuscany/sca/node/Node.java b/sca-java-2.x/trunk/modules/node-api/src/main/java/org/apache/tuscany/sca/node/Node.java index c45415f153..0c1633b9d9 100644 --- a/sca-java-2.x/trunk/modules/node-api/src/main/java/org/apache/tuscany/sca/node/Node.java +++ b/sca-java-2.x/trunk/modules/node-api/src/main/java/org/apache/tuscany/sca/node/Node.java @@ -19,6 +19,8 @@ package org.apache.tuscany.sca.node; +import java.util.List; + import org.apache.tuscany.sca.node.configuration.NodeConfiguration; @@ -49,4 +51,5 @@ public interface Node extends Client { */ void destroy(); + public List<String> getServiceNames(); } 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 a351b7b074..f650268c73 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 @@ -150,6 +150,15 @@ public abstract class NodeFactory extends DefaultNodeConfigurationFactory { } } + public List<String> getServiceNames() { + try { + return (List<String>)node.getClass().getMethod("getServiceNames").invoke(node); + } catch (Throwable e) { + handleException(e); + return null; + } + } + } /** @@ -297,6 +306,28 @@ public abstract class NodeFactory extends DefaultNodeConfigurationFactory { return createNode(configuration); } + public final Node createNode(URI configURI, String... locations) { + Contribution[] contributions = getContributions(Arrays.asList(locations)); + NodeConfiguration configuration = createConfiguration(contributions); + configuration.setDomainRegistryURI(configURI.toString()); + configuration.setDomainURI(getDomainName(configURI)); + return createNode(configuration); + } + + public static String getDomainName(URI configURI) { + // no idea if this is needed, do it anyway for now till the Node refactor is done + String s = configURI.getHost(); + if (s == null) { + s = configURI.getSchemeSpecificPart(); + if (s != null) { + if (s.indexOf(':') > -1) { + s = s.substring(s.indexOf(':')+1); + } + } + } + return s; + } + /** * The following methods are used by the node launcher */ |