diff options
author | bdaniel <bdaniel@13f79535-47bb-0310-9956-ffa450edef68> | 2010-10-29 22:01:46 +0000 |
---|---|---|
committer | bdaniel <bdaniel@13f79535-47bb-0310-9956-ffa450edef68> | 2010-10-29 22:01:46 +0000 |
commit | 1f5ee3c646bebeb1af1327d18a9eb7f77e96cb08 (patch) | |
tree | 8ae0144fffb4929a8adc40d971202795bb92acbd /sca-java-2.x/branches/2.0-Beta1/modules | |
parent | 507b7bcb79834f9227f247ceed3ede9d3587a881 (diff) |
TUSCANY-3720 merge changes to 2.0-Beta1
git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@1028923 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'sca-java-2.x/branches/2.0-Beta1/modules')
2 files changed, 43 insertions, 3 deletions
diff --git a/sca-java-2.x/branches/2.0-Beta1/modules/sca-client-impl/src/main/java/org/apache/tuscany/sca/client/impl/SCAClientFactoryImpl2.java b/sca-java-2.x/branches/2.0-Beta1/modules/sca-client-impl/src/main/java/org/apache/tuscany/sca/client/impl/SCAClientFactoryImpl2.java index 95e23816b3..1cdfa2b347 100644 --- a/sca-java-2.x/branches/2.0-Beta1/modules/sca-client-impl/src/main/java/org/apache/tuscany/sca/client/impl/SCAClientFactoryImpl2.java +++ b/sca-java-2.x/branches/2.0-Beta1/modules/sca-client-impl/src/main/java/org/apache/tuscany/sca/client/impl/SCAClientFactoryImpl2.java @@ -46,13 +46,17 @@ public class SCAClientFactoryImpl2 extends SCAClientFactory { } private void checkDomainURI(URI domainURI) throws NoSuchDomainException { - for ( NodeFactory nodeFactory : NodeFactory.getNodeFactories()) { - String domainName = getDomainName(); + // Check for local node + String domainName = getDomainName(); + for ( NodeFactory nodeFactory : NodeFactory.getNodeFactories()) { List<Node> nodes = ((NodeFactoryImpl)nodeFactory).getNodesInDomain(domainName); if ( !nodes.isEmpty() ) return; } - throw new NoSuchDomainException(getDomainName()); + + // Check for remote node + SCAClientHandler handler = new SCAClientHandler(domainName, null, null); + handler.checkDomain(); } @SuppressWarnings("unchecked") diff --git a/sca-java-2.x/branches/2.0-Beta1/modules/sca-client-impl/src/main/java/org/apache/tuscany/sca/client/impl/SCAClientHandler.java b/sca-java-2.x/branches/2.0-Beta1/modules/sca-client-impl/src/main/java/org/apache/tuscany/sca/client/impl/SCAClientHandler.java index b8cb5732fc..59d90bb3cd 100644 --- a/sca-java-2.x/branches/2.0-Beta1/modules/sca-client-impl/src/main/java/org/apache/tuscany/sca/client/impl/SCAClientHandler.java +++ b/sca-java-2.x/branches/2.0-Beta1/modules/sca-client-impl/src/main/java/org/apache/tuscany/sca/client/impl/SCAClientHandler.java @@ -71,6 +71,42 @@ public class SCAClientHandler implements InvocationHandler { this.serviceInterface = serviceInterface; } + public void checkDomain() throws NoSuchDomainException { + NodeFactoryImpl nodeFactory = (NodeFactoryImpl)NodeFactory.newInstance(domainURI); + try { + nodeFactory.init(); + + ExtensionPointRegistry extensionsRegistry = nodeFactory.getExtensionPointRegistry(); + Properties props = extensionsRegistry.getExtensionPoint(UtilityExtensionPoint.class).getUtility(RuntimeProperties.class).getProperties(); + props.setProperty("client", "true"); + DomainRegistryFactory domainRegistryFactory = ExtensibleDomainRegistryFactory.getInstance(extensionsRegistry); + + String registryURI = domainURI; + + // TODO: theres better ways to do this but this gets things working for now + 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); + } + + + try { + domainRegistryFactory.getEndpointRegistry(registryURI, domainURI); + } catch (Exception e) { + throw new NoSuchDomainException(domainURI, e); + } + } finally { + nodeFactory.destroy(); + } + } + + + public Object invoke(Object proxy, Method method, Object[] args) throws Throwable { NodeFactoryImpl nodeFactory = (NodeFactoryImpl)NodeFactory.newInstance(domainURI); try { |