summaryrefslogtreecommitdiffstats
path: root/sca-java-2.x/trunk/modules/sca-client-impl/src/main/java
diff options
context:
space:
mode:
authorbdaniel <bdaniel@13f79535-47bb-0310-9956-ffa450edef68>2010-10-29 21:52:01 +0000
committerbdaniel <bdaniel@13f79535-47bb-0310-9956-ffa450edef68>2010-10-29 21:52:01 +0000
commit507b7bcb79834f9227f247ceed3ede9d3587a881 (patch)
tree472881dc85d1ec3d9a57a336c146a04220d5321d /sca-java-2.x/trunk/modules/sca-client-impl/src/main/java
parenta33360f9c6a8e5e6c76b8808f5f9ea92cde6c7fd (diff)
TUSCANY-3720 Check for a valid domain on remote nodes
git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@1028921 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'sca-java-2.x/trunk/modules/sca-client-impl/src/main/java')
-rw-r--r--sca-java-2.x/trunk/modules/sca-client-impl/src/main/java/org/apache/tuscany/sca/client/impl/SCAClientFactoryImpl2.java10
-rw-r--r--sca-java-2.x/trunk/modules/sca-client-impl/src/main/java/org/apache/tuscany/sca/client/impl/SCAClientHandler.java36
2 files changed, 43 insertions, 3 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 95e23816b3..1cdfa2b347 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
@@ -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/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 b8cb5732fc..59d90bb3cd 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
@@ -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 {