From fa395e012a4870133bb37ce0d412ed7116f92fc7 Mon Sep 17 00:00:00 2001 From: antelder Date: Fri, 29 Jan 2010 12:00:28 +0000 Subject: 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 --- .../tuscany/sca/client/rmi/SCAClientFactoryImpl.java | 2 +- .../sca/client/rmi/SCAClientProxyHandler.java | 20 ++++++++++++++------ 2 files changed, 15 insertions(+), 7 deletions(-) (limited to 'sca-java-2.x/trunk/modules/sca-client-rmi/src/main') 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 endpoints = endpointRegistry.findEndpoint(endpointReference); if (endpoints.size() <1 ) { -- cgit v1.2.3