summaryrefslogtreecommitdiffstats
path: root/sca-java-2.x/trunk/modules/host-rmi/src/main
diff options
context:
space:
mode:
authorrfeng <rfeng@13f79535-47bb-0310-9956-ffa450edef68>2010-03-11 04:45:13 +0000
committerrfeng <rfeng@13f79535-47bb-0310-9956-ffa450edef68>2010-03-11 04:45:13 +0000
commit4c992115eb659a49506d19fbb8c116bc44f7421d (patch)
treea0be41d1afd7248406f0160024cc51e8ba72a3b2 /sca-java-2.x/trunk/modules/host-rmi/src/main
parent98e926ec59cca9e5696e5376ea59940ceb7cae3b (diff)
Allows RMIHost to return mapped uri
git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@921690 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'sca-java-2.x/trunk/modules/host-rmi/src/main')
-rw-r--r--sca-java-2.x/trunk/modules/host-rmi/src/main/java/org/apache/tuscany/sca/host/rmi/DefaultRMIHost.java13
-rw-r--r--sca-java-2.x/trunk/modules/host-rmi/src/main/java/org/apache/tuscany/sca/host/rmi/ExtensibleRMIHost.java8
-rw-r--r--sca-java-2.x/trunk/modules/host-rmi/src/main/java/org/apache/tuscany/sca/host/rmi/RMIHost.java3
3 files changed, 16 insertions, 8 deletions
diff --git a/sca-java-2.x/trunk/modules/host-rmi/src/main/java/org/apache/tuscany/sca/host/rmi/DefaultRMIHost.java b/sca-java-2.x/trunk/modules/host-rmi/src/main/java/org/apache/tuscany/sca/host/rmi/DefaultRMIHost.java
index cc819d194c..dade6ef7f3 100644
--- a/sca-java-2.x/trunk/modules/host-rmi/src/main/java/org/apache/tuscany/sca/host/rmi/DefaultRMIHost.java
+++ b/sca-java-2.x/trunk/modules/host-rmi/src/main/java/org/apache/tuscany/sca/host/rmi/DefaultRMIHost.java
@@ -19,7 +19,9 @@
package org.apache.tuscany.sca.host.rmi;
+import java.net.InetAddress;
import java.net.URI;
+import java.net.UnknownHostException;
import java.rmi.AlreadyBoundException;
import java.rmi.NoSuchObjectException;
import java.rmi.NotBoundException;
@@ -53,7 +55,7 @@ public class DefaultRMIHost implements RMIHost {
this.socketFactory = new RMISocketFactoryImpl(CONNECTION_TIMEOUT);
}
- public void registerService(String uri, Remote serviceObject) throws RMIHostException, RMIHostRuntimeException {
+ public String registerService(String uri, Remote serviceObject) throws RMIHostException, RMIHostRuntimeException {
RMIURI rmiURI = new RMIURI(uri);
Registry registry;
@@ -69,6 +71,7 @@ public class DefaultRMIHost implements RMIHost {
}
registry.bind(rmiURI.serviceName, serviceObject);
logger.info("RMI service registered: " + rmiURI);
+ return rmiURI.toString();
} catch (AlreadyBoundException e) {
throw new RMIHostException(e);
} catch (RemoteException e) {
@@ -134,11 +137,14 @@ public class DefaultRMIHost implements RMIHost {
private String serviceName;
private RMIURI(String uriStr) {
- this.uriStr = uriStr;
URI uri = URI.create(uriStr);
host = uri.getHost();
if (host == null) {
- host = "localhost";
+ try {
+ host = InetAddress.getLocalHost().getHostName();
+ } catch (UnknownHostException e) {
+ host = "localhost";
+ }
}
port = uri.getPort();
if (port <= 0) {
@@ -149,6 +155,7 @@ public class DefaultRMIHost implements RMIHost {
path = path.substring(1);
}
serviceName = path;
+ this.uriStr = "rmi://" + host + ":" + port + "/" + serviceName;
}
public String toString() {
diff --git a/sca-java-2.x/trunk/modules/host-rmi/src/main/java/org/apache/tuscany/sca/host/rmi/ExtensibleRMIHost.java b/sca-java-2.x/trunk/modules/host-rmi/src/main/java/org/apache/tuscany/sca/host/rmi/ExtensibleRMIHost.java
index 2f3e2311ed..d1936518ca 100644
--- a/sca-java-2.x/trunk/modules/host-rmi/src/main/java/org/apache/tuscany/sca/host/rmi/ExtensibleRMIHost.java
+++ b/sca-java-2.x/trunk/modules/host-rmi/src/main/java/org/apache/tuscany/sca/host/rmi/ExtensibleRMIHost.java
@@ -35,16 +35,16 @@ public class ExtensibleRMIHost implements RMIHost {
this.rmiHosts = rmiHosts;
}
- public void registerService(String uri, Remote serviceObject) throws RMIHostException, RMIHostRuntimeException {
+ public String registerService(String uri, Remote serviceObject) throws RMIHostException, RMIHostRuntimeException {
if (rmiHosts.getRMIHosts().isEmpty()) {
- throw new RMIHostException("No RMI host available");
+ throw new RMIHostException("No RMI host is available");
}
- getDefaultHost().registerService(uri, serviceObject);
+ return getDefaultHost().registerService(uri, serviceObject);
}
public void unregisterService(String uri) throws RMIHostException, RMIHostRuntimeException {
if (rmiHosts.getRMIHosts().isEmpty()) {
- throw new RMIHostException("No RMI host available");
+ throw new RMIHostException("No RMI host is available");
}
getDefaultHost().unregisterService(uri);
}
diff --git a/sca-java-2.x/trunk/modules/host-rmi/src/main/java/org/apache/tuscany/sca/host/rmi/RMIHost.java b/sca-java-2.x/trunk/modules/host-rmi/src/main/java/org/apache/tuscany/sca/host/rmi/RMIHost.java
index bf8659c254..df3f074168 100644
--- a/sca-java-2.x/trunk/modules/host-rmi/src/main/java/org/apache/tuscany/sca/host/rmi/RMIHost.java
+++ b/sca-java-2.x/trunk/modules/host-rmi/src/main/java/org/apache/tuscany/sca/host/rmi/RMIHost.java
@@ -34,10 +34,11 @@ public interface RMIHost {
*
* @param uri the URI against which the server is to be registered
* @param serviceObject the server object to be registered
+ * @return TODO
* @throws RMIHostException
* @throws RMIHostRuntimeException
*/
- void registerService(String uri, Remote serviceObject) throws RMIHostException, RMIHostRuntimeException;
+ String registerService(String uri, Remote serviceObject) throws RMIHostException, RMIHostRuntimeException;
/**
* Unregister a service registered under the given service name and port number