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