diff options
author | antelder <antelder@13f79535-47bb-0310-9956-ffa450edef68> | 2010-05-13 13:55:18 +0000 |
---|---|---|
committer | antelder <antelder@13f79535-47bb-0310-9956-ffa450edef68> | 2010-05-13 13:55:18 +0000 |
commit | a5bb8381e1a977f6fc1bb47194394c0953de5d0e (patch) | |
tree | b95c31257e79d8b81f1c462258154d0f354d5228 /sca-java-2.x/trunk/modules/sca-client-impl/src/main/java/org | |
parent | 98e3f5879517a0f7974b7a3387c8088e6b57d444 (diff) |
Update to throw NoSuchDomainException/NoSuchServiceException as appropriate instead of other exceptions
git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@943885 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'sca-java-2.x/trunk/modules/sca-client-impl/src/main/java/org')
2 files changed, 24 insertions, 9 deletions
diff --git a/sca-java-2.x/trunk/modules/sca-client-impl/src/main/java/org/apache/tuscany/sca/client/impl/SCAClientFactoryImpl2.java b/sca-java-2.x/trunk/modules/sca-client-impl/src/main/java/org/apache/tuscany/sca/client/impl/SCAClientFactoryImpl2.java index 89f0d1aef5..56c643be7d 100644 --- a/sca-java-2.x/trunk/modules/sca-client-impl/src/main/java/org/apache/tuscany/sca/client/impl/SCAClientFactoryImpl2.java +++ b/sca-java-2.x/trunk/modules/sca-client-impl/src/main/java/org/apache/tuscany/sca/client/impl/SCAClientFactoryImpl2.java @@ -47,19 +47,29 @@ public class SCAClientFactoryImpl2 extends SCAClientFactory { @Override
public <T> T getService(Class<T> serviceInterface, String serviceName) throws NoSuchServiceException, NoSuchDomainException {
+ boolean foundDomain = false;
for (NodeFactory nodeFactory : NodeFactory.getNodeFactories()) {
for (Node node : ((NodeFactoryImpl)nodeFactory).getNodes().values()) {
NodeImpl nodeImpl = (NodeImpl) node;
- for (Endpoint ep : nodeImpl.getServiceEndpoints()) {
- if (ep.matches(serviceName)) {
- return node.getService(serviceInterface, serviceName);
+ String nodeDomain = nodeImpl.getConfiguration().getDomainURI();
+ if (nodeDomain.equals(getDomainURI().toString())) {
+ foundDomain = true;
+ for (Endpoint ep : nodeImpl.getServiceEndpoints()) {
+ if (ep.matches(serviceName)) {
+ return node.getService(serviceInterface, serviceName);
+ }
}
}
}
}
+ // assume that if a local node with the looked for domain name is found then that will
+ // know about all services in the domain so if the service isn't found then it doesn't exist
+ if (foundDomain) {
+ throw new NoSuchServiceException(serviceName);
+ }
+
InvocationHandler handler = new SCAClientHandler(getDomainURI().toString(), serviceName, serviceInterface);
return (T)Proxy.newProxyInstance(serviceInterface.getClassLoader(), new Class[]{serviceInterface}, handler);
}
-
}
diff --git a/sca-java-2.x/trunk/modules/sca-client-impl/src/main/java/org/apache/tuscany/sca/client/impl/SCAClientHandler.java b/sca-java-2.x/trunk/modules/sca-client-impl/src/main/java/org/apache/tuscany/sca/client/impl/SCAClientHandler.java index f1dd14f129..4fb38e4ca6 100644 --- a/sca-java-2.x/trunk/modules/sca-client-impl/src/main/java/org/apache/tuscany/sca/client/impl/SCAClientHandler.java +++ b/sca-java-2.x/trunk/modules/sca-client-impl/src/main/java/org/apache/tuscany/sca/client/impl/SCAClientHandler.java @@ -22,10 +22,6 @@ package org.apache.tuscany.sca.client.impl; import java.lang.reflect.InvocationHandler;
import java.lang.reflect.Method;
import java.lang.reflect.Proxy;
-import java.net.InetAddress;
-import java.net.NetworkInterface;
-import java.net.ServerSocket;
-import java.util.Enumeration;
import java.util.List;
import java.util.Properties;
import java.util.UUID;
@@ -59,6 +55,7 @@ import org.apache.tuscany.sca.runtime.RuntimeComponent; import org.apache.tuscany.sca.runtime.RuntimeComponentReference;
import org.apache.tuscany.sca.runtime.RuntimeEndpointReference;
import org.apache.tuscany.sca.runtime.RuntimeProperties;
+import org.oasisopen.sca.NoSuchDomainException;
import org.oasisopen.sca.NoSuchServiceException;
import org.oasisopen.sca.ServiceRuntimeException;
@@ -90,11 +87,19 @@ public class SCAClientHandler implements InvocationHandler { if (registryURI.indexOf(":") == -1) {
registryURI = "tuscanyclient:" + registryURI;
}
+ if (registryURI.startsWith("uri:")) {
+ registryURI = "tuscanyclient:" + registryURI.substring(4);
+ }
if (registryURI.startsWith("tuscany:")) {
registryURI = "tuscanyclient:" + registryURI.substring(8);
}
- EndpointRegistry endpointRegistry = domainRegistryFactory.getEndpointRegistry(registryURI, domainURI);
+ EndpointRegistry endpointRegistry;
+ try {
+ endpointRegistry = domainRegistryFactory.getEndpointRegistry(registryURI, domainURI);
+ } catch (Exception e) {
+ throw new NoSuchDomainException(domainURI, e);
+ }
FactoryExtensionPoint factories = extensionsRegistry.getExtensionPoint(FactoryExtensionPoint.class);
AssemblyFactory assemblyFactory = factories.getFactory(AssemblyFactory.class);
|