diff options
author | antelder <antelder@13f79535-47bb-0310-9956-ffa450edef68> | 2009-11-20 16:21:30 +0000 |
---|---|---|
committer | antelder <antelder@13f79535-47bb-0310-9956-ffa450edef68> | 2009-11-20 16:21:30 +0000 |
commit | 3a97fb918cd9f16552ae729d43e51523f21e2f1d (patch) | |
tree | 5a8f75d38479e237e9d04e4942d5b80b6eead2be | |
parent | 5d830efbe83d4e803d0095ec9c0a8b5d31374052 (diff) |
Add getDomainConfigURI and getServiceNames methods
git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@882630 13f79535-47bb-0310-9956-ffa450edef68
-rw-r--r-- | java/sca/modules/domain-node/src/main/java/org/apache/tuscany/sca/domain/node/DomainNode.java | 38 |
1 files changed, 36 insertions, 2 deletions
diff --git a/java/sca/modules/domain-node/src/main/java/org/apache/tuscany/sca/domain/node/DomainNode.java b/java/sca/modules/domain-node/src/main/java/org/apache/tuscany/sca/domain/node/DomainNode.java index c0ea3cc1f0..2c9e6dfb77 100644 --- a/java/sca/modules/domain-node/src/main/java/org/apache/tuscany/sca/domain/node/DomainNode.java +++ b/java/sca/modules/domain-node/src/main/java/org/apache/tuscany/sca/domain/node/DomainNode.java @@ -20,13 +20,21 @@ package org.apache.tuscany.sca.domain.node;
import java.net.URI;
+import java.util.ArrayList;
import java.util.HashMap;
+import java.util.List;
import java.util.Map;
+import org.apache.tuscany.sca.assembly.Endpoint;
+import org.apache.tuscany.sca.core.ExtensionPointRegistry;
+import org.apache.tuscany.sca.core.UtilityExtensionPoint;
import org.apache.tuscany.sca.management.ConfigAttributes;
import org.apache.tuscany.sca.node.Node;
import org.apache.tuscany.sca.node.NodeFactory;
import org.apache.tuscany.sca.node.configuration.NodeConfiguration;
+import org.apache.tuscany.sca.node.impl.NodeImpl;
+import org.apache.tuscany.sca.runtime.DomainRegistryFactory;
+import org.apache.tuscany.sca.runtime.EndpointRegistry;
import org.oasisopen.sca.NoSuchDomainException;
import org.oasisopen.sca.NoSuchServiceException;
import org.oasisopen.sca.client.SCAClient;
@@ -159,12 +167,38 @@ public class DomainNode { return uri;
}
+ public String getDomainConfigURI() {
+ return domainRegistryURI;
+ }
+
+ public List<String> getServiceNames() {
+ List<String> serviceNames = new ArrayList<String>();
+ if (nodes.size() > 0) {
+ ExtensionPointRegistry extensionsRegistry = ((NodeImpl)nodes.values().iterator().next()).getExtensionPoints();
+ UtilityExtensionPoint utilities = extensionsRegistry.getExtensionPoint(UtilityExtensionPoint.class);
+ DomainRegistryFactory domainRegistryFactory = utilities.getUtility(DomainRegistryFactory.class);
+ EndpointRegistry endpointRegistry = domainRegistryFactory.getEndpointRegistry(getDomainConfigURI(), 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;
+ }
+
public <T> T getService(Class<T> interfaze, String uri) throws NoSuchServiceException {
try {
- return SCAClient.getService(interfaze, configAttributes.getAttributes().get(DOMAIN_NAME_ATTR) + "/" + uri);
+ return SCAClient.getService(interfaze, getDomainName() + "/" + uri);
} catch (NoSuchDomainException e) {
throw new IllegalStateException(e);
}
}
-
}
|