summaryrefslogtreecommitdiffstats
path: root/java/sca/modules
diff options
context:
space:
mode:
authorantelder <antelder@13f79535-47bb-0310-9956-ffa450edef68>2009-06-12 09:55:38 +0000
committerantelder <antelder@13f79535-47bb-0310-9956-ffa450edef68>2009-06-12 09:55:38 +0000
commit5f5d20e96bdb6996871454bb3612dd90e04cfefd (patch)
tree00138a1f3acd36c47aca9518adda2276f1965a7c /java/sca/modules
parent5a356c409f46f24dec68f4465a1389ae905cff9b (diff)
Add back in the getServiceEndpoints method
git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@784056 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'java/sca/modules')
-rw-r--r--java/sca/modules/node-impl/src/main/java/org/apache/tuscany/sca/node/impl/NodeImpl.java29
-rw-r--r--java/sca/modules/node-impl/src/test/java/org/apache/tuscany/sca/node/impl/NodeImplTestCase.java14
2 files changed, 43 insertions, 0 deletions
diff --git a/java/sca/modules/node-impl/src/main/java/org/apache/tuscany/sca/node/impl/NodeImpl.java b/java/sca/modules/node-impl/src/main/java/org/apache/tuscany/sca/node/impl/NodeImpl.java
index fdf6f18e7b..6737a16d3a 100644
--- a/java/sca/modules/node-impl/src/main/java/org/apache/tuscany/sca/node/impl/NodeImpl.java
+++ b/java/sca/modules/node-impl/src/main/java/org/apache/tuscany/sca/node/impl/NodeImpl.java
@@ -19,6 +19,7 @@
package org.apache.tuscany.sca.node.impl;
+import java.util.ArrayList;
import java.util.List;
import java.util.logging.Level;
import java.util.logging.Logger;
@@ -27,6 +28,8 @@ import org.apache.tuscany.sca.assembly.Component;
import org.apache.tuscany.sca.assembly.ComponentService;
import org.apache.tuscany.sca.assembly.Composite;
import org.apache.tuscany.sca.assembly.CompositeService;
+import org.apache.tuscany.sca.assembly.Endpoint;
+import org.apache.tuscany.sca.assembly.Service;
import org.apache.tuscany.sca.core.ExtensionPointRegistry;
import org.apache.tuscany.sca.core.UtilityExtensionPoint;
import org.apache.tuscany.sca.core.assembly.ActivationException;
@@ -38,6 +41,7 @@ import org.apache.tuscany.sca.node.NodeFinder;
import org.apache.tuscany.sca.node.configuration.NodeConfiguration;
import org.apache.tuscany.sca.runtime.RuntimeComponent;
import org.apache.tuscany.sca.runtime.RuntimeComponentContext;
+import org.apache.tuscany.sca.runtime.RuntimeComponentService;
import org.oasisopen.sca.CallableReference;
import org.oasisopen.sca.ServiceReference;
import org.oasisopen.sca.ServiceRuntimeException;
@@ -204,4 +208,29 @@ public class NodeImpl implements Node, Client {
return manager.getExtensionPoints();
}
+ /**
+ * Get the service endpoints in this Node
+ * TODO: needs review, works for the very simple testcase but i expect there are
+ * other endpoints to be included
+ */
+ public List<Endpoint> getServiceEndpoints() {
+ List<Endpoint> endpoints = new ArrayList<Endpoint>();
+ if (compositeActivator != null) {
+ Composite domainComposite = compositeActivator.getDomainComposite();
+ if (domainComposite != null) {
+ for (Composite composite : domainComposite.getIncludes()) {
+ for (Component component : composite.getComponents()) {
+ for (Service service : component.getServices()) {
+ // MJE 28/05/2009 - changed to RuntimeComponentService from RuntimeComponentServiceImpl
+ // - no need to access the Impl directly here
+ if (service instanceof RuntimeComponentService) {
+ endpoints.addAll(((RuntimeComponentService)service).getEndpoints());
+ }
+ }
+ }
+ }
+ }
+ }
+ return endpoints;
+ }
}
diff --git a/java/sca/modules/node-impl/src/test/java/org/apache/tuscany/sca/node/impl/NodeImplTestCase.java b/java/sca/modules/node-impl/src/test/java/org/apache/tuscany/sca/node/impl/NodeImplTestCase.java
index dc4baeb390..aa7933630a 100644
--- a/java/sca/modules/node-impl/src/test/java/org/apache/tuscany/sca/node/impl/NodeImplTestCase.java
+++ b/java/sca/modules/node-impl/src/test/java/org/apache/tuscany/sca/node/impl/NodeImplTestCase.java
@@ -24,7 +24,9 @@ import hello.HelloWorld;
import java.io.File;
import java.io.StringReader;
import java.net.MalformedURLException;
+import java.util.List;
+import org.apache.tuscany.sca.assembly.Endpoint;
import org.apache.tuscany.sca.node.Contribution;
import org.apache.tuscany.sca.node.Node;
import org.apache.tuscany.sca.node.NodeFactory;
@@ -77,6 +79,18 @@ public class NodeImplTestCase {
testNode(new NodeFactoryImpl().createNode());
}
+ @Test
+ public void testGetServiceEndpoints() {
+ NodeFactory factory = new NodeFactoryImpl();
+ Contribution contribution = new Contribution("c1", new File("target/test-classes").toURI().toString());
+ NodeImpl node = (NodeImpl)factory.createNode(new StringReader(composite), contribution);
+ node.start();
+ List<Endpoint> es = node.getServiceEndpoints();
+ Assert.assertEquals(1, es.size());
+ Assert.assertEquals("HelloWorld2", es.get(0).getComponent().getName());
+ node.stop();
+ }
+
private void testNode(Node node) {
node.start();
HelloWorld hw = node.getService(HelloWorld.class, "HelloWorld");