diff options
author | antelder <antelder@13f79535-47bb-0310-9956-ffa450edef68> | 2010-01-28 18:40:43 +0000 |
---|---|---|
committer | antelder <antelder@13f79535-47bb-0310-9956-ffa450edef68> | 2010-01-28 18:40:43 +0000 |
commit | 98802478a84a42af4a4bf7c28a815ade993eab6a (patch) | |
tree | 9acec14c9042bb53f0c2e1a16f485bfb2dbc474e /sca-java-2.x/trunk/modules/sca-client-rmi/src/main/java/org/apache/tuscany/sca/client | |
parent | 492f58500ba6d94838b8785860574e7665effa4d (diff) |
Change the tuscanyClient scheme to pbe all lower case so it works with the toLowerCase in the DefaultEndpointRegistryFactory, and move all the remote code in the scaclient to happen at invocation time. This now works for multiple local and remote nodes in one or separate JVMs
git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@904206 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to '')
2 files changed, 38 insertions, 15 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 cde91739c0..f949763e9b 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 @@ -56,10 +56,32 @@ public class SCAClientFactoryImpl extends SCAClientFactory { if (extensionsRegistry != null) {
UtilityExtensionPoint utilities = extensionsRegistry.getExtensionPoint(UtilityExtensionPoint.class);
DomainRegistryFactory domainRegistryFactory = utilities.getUtility(DomainRegistryFactory.class);
- this.endpointRegistry = domainRegistryFactory.getEndpointRegistry("tuscanyClient:", getDomainURI().toString()); // TODO: shouldnt use null for reg uri
+ this.endpointRegistry = domainRegistryFactory.getEndpointRegistry(getRegistryURI(), getDomainName());
}
}
+ private String getRegistryURI() {
+ String uri = getDomainURI().toString();
+ if (uri.startsWith("tuscany:")) {
+ uri = uri.replace("tuscany:", "tuscanyclient:");
+ }
+ return uri;
+ }
+
+ private String getDomainName() {
+ if (getDomainURI().getHost() != null) {
+ return getDomainURI().getHost();
+ }
+ String uri = getDomainURI().toString();
+ if (!uri.startsWith("tuscany://")) {
+ if (uri.startsWith("tuscany:")) {
+ uri = uri.replace("tuscany:", "tuscany://");
+ return URI.create(uri).getHost();
+ }
+ }
+ return uri;
+ }
+
@Override
public <T> T getService(Class<T> serviceInterface, String serviceName) throws NoSuchServiceException, NoSuchDomainException {
@@ -78,7 +100,7 @@ public class SCAClientFactoryImpl extends SCAClientFactory { String uri = getDomainURI().toString();
if (uri.startsWith("tuscany:")) {
- uri = uri.replace("tuscany:", "tuscanyClient:");
+ uri = uri.replace("tuscany:", "tuscanyclient://");
}
InvocationHandler handler = new SCAClientProxyHandler(nodeFactory, uri, 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 6d182c61a7..b65f311da2 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 @@ -55,25 +55,26 @@ public class SCAClientProxyHandler implements InvocationHandler { this.nodeFactory = nodeFactory;
this.domainURI = domainURI;
this.serviceName = serviceName;
- this.extensionsRegistry = nodeFactory.getExtensionPoints();
- RMIHostExtensionPoint rmiHosts = extensionsRegistry.getExtensionPoint(RMIHostExtensionPoint.class);
- this.rmiHost = new ExtensibleRMIHost(rmiHosts);
-
- FactoryExtensionPoint factories = extensionsRegistry.getExtensionPoint(FactoryExtensionPoint.class);
- AssemblyFactory assemblyFactory = factories.getFactory(AssemblyFactory.class);
-
- this.endpointReference = assemblyFactory.createEndpointReference();
- endpointReference.setReference(assemblyFactory.createComponentReference());
- Endpoint targetEndpoint = assemblyFactory.createEndpoint();
- targetEndpoint.setURI(serviceName);
- endpointReference.setTargetEndpoint(targetEndpoint);
}
public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
Node node = null;
try {
- node = NodeFactory.newInstance().createNode(URI.create(domainURI)).start();
+ nodeFactory = (NodeFactoryImpl)NodeFactory.newInstance();
+ node = nodeFactory.createNode(URI.create(domainURI)).start();
+ this.extensionsRegistry = nodeFactory.getExtensionPoints();
+ RMIHostExtensionPoint rmiHosts = extensionsRegistry.getExtensionPoint(RMIHostExtensionPoint.class);
+ this.rmiHost = new ExtensibleRMIHost(rmiHosts);
+
+ FactoryExtensionPoint factories = extensionsRegistry.getExtensionPoint(FactoryExtensionPoint.class);
+ AssemblyFactory assemblyFactory = factories.getFactory(AssemblyFactory.class);
+
+ this.endpointReference = assemblyFactory.createEndpointReference();
+ endpointReference.setReference(assemblyFactory.createComponentReference());
+ Endpoint targetEndpoint = assemblyFactory.createEndpoint();
+ targetEndpoint.setURI(serviceName);
+ endpointReference.setTargetEndpoint(targetEndpoint);
UtilityExtensionPoint utilities = extensionsRegistry.getExtensionPoint(UtilityExtensionPoint.class);
DomainRegistryFactory domainRegistryFactory = utilities.getUtility(DomainRegistryFactory.class);
this.endpointRegistry = domainRegistryFactory.getEndpointRegistry(null, domainURI);
|