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/Node.java3
-rw-r--r--sca-java-2.x/trunk/modules/node-api/src/main/java/org/apache/tuscany/sca/node/NodeFactory.java31
-rw-r--r--sca-java-2.x/trunk/modules/node-impl/src/main/java/org/apache/tuscany/sca/node/impl/NodeImpl.java21
-rw-r--r--sca-java-2.x/trunk/modules/node-impl/src/test/java/org/apache/tuscany/sca/node/impl/NodeUtilTestCase.java10
4 files changed, 65 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
*/
diff --git a/sca-java-2.x/trunk/modules/node-impl/src/main/java/org/apache/tuscany/sca/node/impl/NodeImpl.java b/sca-java-2.x/trunk/modules/node-impl/src/main/java/org/apache/tuscany/sca/node/impl/NodeImpl.java
index 62f18f08e0..51073acfd1 100644
--- a/sca-java-2.x/trunk/modules/node-impl/src/main/java/org/apache/tuscany/sca/node/impl/NodeImpl.java
+++ b/sca-java-2.x/trunk/modules/node-impl/src/main/java/org/apache/tuscany/sca/node/impl/NodeImpl.java
@@ -366,4 +366,25 @@ public class NodeImpl implements Node, Client {
return result;
}
+
+ public List<String> getServiceNames() {
+ List<String> serviceNames = new ArrayList<String>();
+ ExtensionPointRegistry extensionsRegistry = getExtensionPoints();
+ UtilityExtensionPoint utilities = extensionsRegistry.getExtensionPoint(UtilityExtensionPoint.class);
+ DomainRegistryFactory domainRegistryFactory = utilities.getUtility(DomainRegistryFactory.class);
+ EndpointRegistry endpointRegistry = domainRegistryFactory.getEndpointRegistry(configuration.getDomainRegistryURI(), configuration.getDomainName());
+ for (Endpoint endpoint : endpointRegistry.getEndpoints()) {
+ // Would be nice if Endpoint.getURI() returned this:
+ String name = endpoint.getComponent().getName() + "/" + endpoint.getService().getName();
+ if (endpoint.getBinding() != null) {
+ // TODO: shouldn't the binding name be null if its not explicitly specified?
+ // For now don't include it if the same as the default
+ if (!endpoint.getService().getName().equals(endpoint.getBinding().getName())) {
+ name += "/" + endpoint.getBinding().getName();
+ }
+ }
+ serviceNames.add(name);
+ }
+ return serviceNames;
+ }
}
diff --git a/sca-java-2.x/trunk/modules/node-impl/src/test/java/org/apache/tuscany/sca/node/impl/NodeUtilTestCase.java b/sca-java-2.x/trunk/modules/node-impl/src/test/java/org/apache/tuscany/sca/node/impl/NodeUtilTestCase.java
index 5a47465702..70ccf2ab19 100644
--- a/sca-java-2.x/trunk/modules/node-impl/src/test/java/org/apache/tuscany/sca/node/impl/NodeUtilTestCase.java
+++ b/sca-java-2.x/trunk/modules/node-impl/src/test/java/org/apache/tuscany/sca/node/impl/NodeUtilTestCase.java
@@ -19,6 +19,8 @@
package org.apache.tuscany.sca.node.impl;
+import java.net.URI;
+
import org.apache.tuscany.sca.common.java.io.IOHelper;
import org.junit.Assert;
import org.junit.Test;
@@ -36,4 +38,12 @@ public class NodeUtilTestCase {
Assert.assertEquals("file:/a%20b", IOHelper.createURI("file:/a b").toString());
Assert.assertEquals("file:/a%20b", IOHelper.createURI("file:/a%20b").toString());
}
+
+ @Test
+ public void testDomainURI() {
+ Assert.assertEquals("foo", NodeFactoryImpl.getDomainName(URI.create("tuscany:foo")));
+ Assert.assertEquals("foo", NodeFactoryImpl.getDomainName(URI.create("tuscany:vm:foo")));
+ Assert.assertEquals("foo", NodeFactoryImpl.getDomainName(URI.create("vm:foo")));
+ Assert.assertEquals("foo", NodeFactoryImpl.getDomainName(URI.create("bla://foo")));
+ }
}