summaryrefslogtreecommitdiffstats
path: root/sca-java-2.x/trunk/modules/sca-client-rmi
diff options
context:
space:
mode:
authorantelder <antelder@13f79535-47bb-0310-9956-ffa450edef68>2010-01-29 12:00:28 +0000
committerantelder <antelder@13f79535-47bb-0310-9956-ffa450edef68>2010-01-29 12:00:28 +0000
commitfa395e012a4870133bb37ce0d412ed7116f92fc7 (patch)
tree31bc188844158bd249a55110405d48ca662c4ab6 /sca-java-2.x/trunk/modules/sca-client-rmi
parent59f53a731aeb36de2bac7777cc26f24f6997afb0 (diff)
Update after registry factory refactor so it doesn't create two client connections on a service invocation
git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@904475 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'sca-java-2.x/trunk/modules/sca-client-rmi')
-rw-r--r--sca-java-2.x/trunk/modules/sca-client-rmi/src/main/java/org/apache/tuscany/sca/client/rmi/SCAClientFactoryImpl.java2
-rw-r--r--sca-java-2.x/trunk/modules/sca-client-rmi/src/main/java/org/apache/tuscany/sca/client/rmi/SCAClientProxyHandler.java20
2 files changed, 15 insertions, 7 deletions
diff --git a/sca-java-2.x/trunk/modules/sca-client-rmi/src/main/java/org/apache/tuscany/sca/client/rmi/SCAClientFactoryImpl.java b/sca-java-2.x/trunk/modules/sca-client-rmi/src/main/java/org/apache/tuscany/sca/client/rmi/SCAClientFactoryImpl.java
index 7b83e49f0c..b77f75a514 100644
--- a/sca-java-2.x/trunk/modules/sca-client-rmi/src/main/java/org/apache/tuscany/sca/client/rmi/SCAClientFactoryImpl.java
+++ b/sca-java-2.x/trunk/modules/sca-client-rmi/src/main/java/org/apache/tuscany/sca/client/rmi/SCAClientFactoryImpl.java
@@ -102,7 +102,7 @@ public class SCAClientFactoryImpl extends SCAClientFactory {
if (uri.startsWith("tuscany:")) {
uri = uri.replace("tuscany:", "tuscanyclient://");
}
- InvocationHandler handler = new SCAClientProxyHandler(nodeFactory, uri, serviceName);
+ InvocationHandler handler = new SCAClientProxyHandler(nodeFactory, uri, getDomainName(), serviceName);
return (T)Proxy.newProxyInstance(serviceInterface.getClassLoader(), new Class[] {serviceInterface}, handler);
}
diff --git a/sca-java-2.x/trunk/modules/sca-client-rmi/src/main/java/org/apache/tuscany/sca/client/rmi/SCAClientProxyHandler.java b/sca-java-2.x/trunk/modules/sca-client-rmi/src/main/java/org/apache/tuscany/sca/client/rmi/SCAClientProxyHandler.java
index 4648d7cdbe..1e5727bec3 100644
--- a/sca-java-2.x/trunk/modules/sca-client-rmi/src/main/java/org/apache/tuscany/sca/client/rmi/SCAClientProxyHandler.java
+++ b/sca-java-2.x/trunk/modules/sca-client-rmi/src/main/java/org/apache/tuscany/sca/client/rmi/SCAClientProxyHandler.java
@@ -37,8 +37,8 @@ import org.apache.tuscany.sca.node.Node;
import org.apache.tuscany.sca.node.NodeFactory;
import org.apache.tuscany.sca.node.impl.NodeFactoryImpl;
import org.apache.tuscany.sca.runtime.DomainRegistryFactory;
+import org.apache.tuscany.sca.runtime.DomainRegistryFactoryExtensionPoint;
import org.apache.tuscany.sca.runtime.EndpointRegistry;
-import org.apache.tuscany.sca.runtime.ExtensibleDomainRegistry;
import org.oasisopen.sca.NoSuchServiceException;
public class SCAClientProxyHandler implements InvocationHandler {
@@ -47,12 +47,14 @@ public class SCAClientProxyHandler implements InvocationHandler {
protected ExtensionPointRegistry extensionsRegistry;
protected EndpointRegistry endpointRegistry;
protected EndpointReference endpointReference;
+ protected String registryURI;
+ protected String domainURI;
protected String serviceName;
protected RMIHost rmiHost;
- private String domainURI;
- public SCAClientProxyHandler(NodeFactoryImpl nodeFactory, String domainURI, String serviceName) {
+ public SCAClientProxyHandler(NodeFactoryImpl nodeFactory, String registryURI, String domainURI, String serviceName) {
this.nodeFactory = nodeFactory;
+ this.registryURI = registryURI;
this.domainURI = domainURI;
this.serviceName = serviceName;
}
@@ -62,7 +64,7 @@ public class SCAClientProxyHandler implements InvocationHandler {
try {
nodeFactory = (NodeFactoryImpl)NodeFactory.newInstance();
- node = nodeFactory.createNode(URI.create(domainURI)).start();
+ node = nodeFactory.createNode(URI.create(registryURI)).start();
this.extensionsRegistry = nodeFactory.getExtensionPoints();
RMIHostExtensionPoint rmiHosts = extensionsRegistry.getExtensionPoint(RMIHostExtensionPoint.class);
this.rmiHost = new ExtensibleRMIHost(rmiHosts);
@@ -75,8 +77,14 @@ public class SCAClientProxyHandler implements InvocationHandler {
Endpoint targetEndpoint = assemblyFactory.createEndpoint();
targetEndpoint.setURI(serviceName);
endpointReference.setTargetEndpoint(targetEndpoint);
- DomainRegistryFactory domainRegistryFactory = new ExtensibleDomainRegistry(extensionsRegistry);
- this.endpointRegistry = domainRegistryFactory.getEndpointRegistry(null, domainURI);
+ DomainRegistryFactoryExtensionPoint factoriesx = extensionsRegistry.getExtensionPoint(DomainRegistryFactoryExtensionPoint.class);
+ for (DomainRegistryFactory factory : factoriesx.getDomainRegistryFactories()) {
+ for (EndpointRegistry endpointRegistry : factory.getEndpointRegistries()) {
+ if (endpointRegistry.getDomainName().equals(domainURI)) {
+ this.endpointRegistry = endpointRegistry;
+ }
+ }
+ }
List<Endpoint> endpoints = endpointRegistry.findEndpoint(endpointReference);
if (endpoints.size() <1 ) {