diff options
Diffstat (limited to 'sca-java-2.x/trunk/modules/sca-client-rmi/src/main')
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);
|