You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tuscany.apache.org by an...@apache.org on 2010/05/13 15:55:18 UTC
svn commit: r943885 - in
/tuscany/sca-java-2.x/trunk/modules/sca-client-impl/src/main/java/org/apache/tuscany/sca/client/impl:
SCAClientFactoryImpl2.java SCAClientHandler.java
Author: antelder
Date: Thu May 13 13:55:18 2010
New Revision: 943885
URL: http://svn.apache.org/viewvc?rev=943885&view=rev
Log:
Update to throw NoSuchDomainException/NoSuchServiceException as appropriate instead of other exceptions
Modified:
tuscany/sca-java-2.x/trunk/modules/sca-client-impl/src/main/java/org/apache/tuscany/sca/client/impl/SCAClientFactoryImpl2.java
tuscany/sca-java-2.x/trunk/modules/sca-client-impl/src/main/java/org/apache/tuscany/sca/client/impl/SCAClientHandler.java
Modified: tuscany/sca-java-2.x/trunk/modules/sca-client-impl/src/main/java/org/apache/tuscany/sca/client/impl/SCAClientFactoryImpl2.java
URL: http://svn.apache.org/viewvc/tuscany/sca-java-2.x/trunk/modules/sca-client-impl/src/main/java/org/apache/tuscany/sca/client/impl/SCAClientFactoryImpl2.java?rev=943885&r1=943884&r2=943885&view=diff
==============================================================================
--- tuscany/sca-java-2.x/trunk/modules/sca-client-impl/src/main/java/org/apache/tuscany/sca/client/impl/SCAClientFactoryImpl2.java (original)
+++ tuscany/sca-java-2.x/trunk/modules/sca-client-impl/src/main/java/org/apache/tuscany/sca/client/impl/SCAClientFactoryImpl2.java Thu May 13 13:55:18 2010
@@ -47,19 +47,29 @@ public class SCAClientFactoryImpl2 exten
@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);
}
-
}
Modified: tuscany/sca-java-2.x/trunk/modules/sca-client-impl/src/main/java/org/apache/tuscany/sca/client/impl/SCAClientHandler.java
URL: http://svn.apache.org/viewvc/tuscany/sca-java-2.x/trunk/modules/sca-client-impl/src/main/java/org/apache/tuscany/sca/client/impl/SCAClientHandler.java?rev=943885&r1=943884&r2=943885&view=diff
==============================================================================
--- tuscany/sca-java-2.x/trunk/modules/sca-client-impl/src/main/java/org/apache/tuscany/sca/client/impl/SCAClientHandler.java (original)
+++ tuscany/sca-java-2.x/trunk/modules/sca-client-impl/src/main/java/org/apache/tuscany/sca/client/impl/SCAClientHandler.java Thu May 13 13:55:18 2010
@@ -22,10 +22,6 @@ package org.apache.tuscany.sca.client.im
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.Ru
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
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);