summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorantelder <antelder@13f79535-47bb-0310-9956-ffa450edef68>2009-11-03 11:30:07 +0000
committerantelder <antelder@13f79535-47bb-0310-9956-ffa450edef68>2009-11-03 11:30:07 +0000
commit0c3ea5ba84f14d0be05fdfcef0b8b0aa340e4602 (patch)
treeba8238169e1b3f3c5fdb8c87852a389f28f481d4
parent95d8fbabf48b6cf93a8450dbca4b11809874f8d4 (diff)
Correctly set the uri in the RMI based sca binding services and references (again copied from the Axis2 SCA binding, it looks like it may be worth at some point trying to refactor a lot of the remote sca binding code into something shared
git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@832397 13f79535-47bb-0310-9956-ffa450edef68
-rw-r--r--java/sca/modules/binding-sca-runtime-rmi/src/main/java/org/apache/tuscany/sca/binding/sca/rmi/RMISCAReferenceBindingProvider.java5
-rw-r--r--java/sca/modules/binding-sca-runtime-rmi/src/main/java/org/apache/tuscany/sca/binding/sca/rmi/RMISCAServiceBindingProvider.java51
2 files changed, 31 insertions, 25 deletions
diff --git a/java/sca/modules/binding-sca-runtime-rmi/src/main/java/org/apache/tuscany/sca/binding/sca/rmi/RMISCAReferenceBindingProvider.java b/java/sca/modules/binding-sca-runtime-rmi/src/main/java/org/apache/tuscany/sca/binding/sca/rmi/RMISCAReferenceBindingProvider.java
index 979282ffbd..6773b3b1d2 100644
--- a/java/sca/modules/binding-sca-runtime-rmi/src/main/java/org/apache/tuscany/sca/binding/sca/rmi/RMISCAReferenceBindingProvider.java
+++ b/java/sca/modules/binding-sca-runtime-rmi/src/main/java/org/apache/tuscany/sca/binding/sca/rmi/RMISCAReferenceBindingProvider.java
@@ -56,8 +56,9 @@ public class RMISCAReferenceBindingProvider implements ReferenceBindingProvider
this.binding = ((DistributedSCABinding)endpointReference.getBinding()).getSCABinding();
rmiBinding = modelFactories.getFactory(RMIBindingFactory.class).createRMIBinding();
- rmiBinding.setName(this.binding.getName());
-
+ rmiBinding.setName(this.binding.getName());
+ rmiBinding.setURI(this.binding.getURI());
+
// create a copy of the endpoint reference but with the RMI binding in
EndpointReference epr = null;
try {
diff --git a/java/sca/modules/binding-sca-runtime-rmi/src/main/java/org/apache/tuscany/sca/binding/sca/rmi/RMISCAServiceBindingProvider.java b/java/sca/modules/binding-sca-runtime-rmi/src/main/java/org/apache/tuscany/sca/binding/sca/rmi/RMISCAServiceBindingProvider.java
index f225ab3c95..f3e60be83d 100644
--- a/java/sca/modules/binding-sca-runtime-rmi/src/main/java/org/apache/tuscany/sca/binding/sca/rmi/RMISCAServiceBindingProvider.java
+++ b/java/sca/modules/binding-sca-runtime-rmi/src/main/java/org/apache/tuscany/sca/binding/sca/rmi/RMISCAServiceBindingProvider.java
@@ -19,6 +19,11 @@
package org.apache.tuscany.sca.binding.sca.rmi;
+import java.io.IOException;
+import java.net.InetAddress;
+import java.net.ServerSocket;
+import java.net.URI;
+import java.net.UnknownHostException;
import java.util.logging.Logger;
import org.apache.tuscany.sca.assembly.DistributedSCABinding;
@@ -56,29 +61,29 @@ public class RMISCAServiceBindingProvider implements ServiceBindingProvider {
rmiBinding = modelFactories.getFactory(RMIBindingFactory.class).createRMIBinding();
rmiBinding.setName(this.binding.getName());
-// URI uri = URI.create(binding.getURI());
-// if (!uri.isAbsolute()) {
-// int port = 8085;
-// String host;
-// try {
-// host = InetAddress.getLocalHost().getHostAddress();
-// } catch (UnknownHostException e) {
-// host = "localhost";
-// logger.warning("unable to determine host address, using localhost");
-// }
-// ServerSocket socket;
-// try {
-// socket = new ServerSocket(0);
-// port = socket.getLocalPort();
-// // host = socket.getInetAddress().getHostAddress();
-// socket.close();
-// } catch (IOException e) {
-// }
-// String bindURI = "http://" + host + ":" + port + binding.getURI();
-//
-// // FIXME: We need to pass the full URI to the endpoint registry
-// binding.setURI(bindURI);
-// }
+ URI uri = URI.create(binding.getURI());
+ if (!uri.isAbsolute()) {
+ int port = 8085;
+ String host;
+ try {
+ host = InetAddress.getLocalHost().getHostAddress();
+ } catch (UnknownHostException e) {
+ host = "localhost";
+ logger.warning("unable to determine host address, using localhost");
+ }
+ ServerSocket socket;
+ try {
+ socket = new ServerSocket(0);
+ port = socket.getLocalPort();
+ // host = socket.getInetAddress().getHostAddress();
+ socket.close();
+ } catch (IOException e) {
+ }
+ String bindURI = "http://" + host + ":" + port + binding.getURI();
+
+ // FIXME: We need to pass the full URI to the endpoint registry
+ binding.setURI(bindURI);
+ }
rmiBinding.setURI(this.binding.getURI());