diff options
Diffstat (limited to 'sca-java-2.x/trunk/modules/sca-client-impl/src/main/java/org/apache/tuscany')
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);
|