From 58f1d25ca60915a00e4ae3522b0c928153c4491d Mon Sep 17 00:00:00 2001 From: rfeng Date: Tue, 6 Oct 2009 16:56:01 +0000 Subject: Create RMI Registry before checking its existence git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@822344 13f79535-47bb-0310-9956-ffa450edef68 --- .../java/org/apache/tuscany/sca/host/rmi/DefaultRMIHost.java | 10 +++------- .../tuscany/sca/host/rmi/DefaultRMIHostExtensionPoint.java | 6 ++++-- 2 files changed, 7 insertions(+), 9 deletions(-) (limited to 'java/sca') diff --git a/java/sca/modules/host-rmi/src/main/java/org/apache/tuscany/sca/host/rmi/DefaultRMIHost.java b/java/sca/modules/host-rmi/src/main/java/org/apache/tuscany/sca/host/rmi/DefaultRMIHost.java index f7d2184e24..cc819d194c 100644 --- a/java/sca/modules/host-rmi/src/main/java/org/apache/tuscany/sca/host/rmi/DefaultRMIHost.java +++ b/java/sca/modules/host-rmi/src/main/java/org/apache/tuscany/sca/host/rmi/DefaultRMIHost.java @@ -61,14 +61,10 @@ public class DefaultRMIHost implements RMIHost { registry = rmiRegistries.get(Integer.toString(rmiURI.port)); if (registry == null) { try { - registry = LocateRegistry.getRegistry(null, rmiURI.port, socketFactory); - // FIXME: It takes about 15 seconds to time out - registry.lookup(rmiURI.serviceName); - } catch (RemoteException e) { registry = LocateRegistry.createRegistry(rmiURI.port, socketFactory, socketFactory); - } catch (NotBoundException e) { - // Ignore - } + } catch (RemoteException e) { + registry = LocateRegistry.getRegistry(null, rmiURI.port, socketFactory); + } rmiRegistries.put(Integer.toString(rmiURI.port), registry); } registry.bind(rmiURI.serviceName, serviceObject); diff --git a/java/sca/modules/host-rmi/src/main/java/org/apache/tuscany/sca/host/rmi/DefaultRMIHostExtensionPoint.java b/java/sca/modules/host-rmi/src/main/java/org/apache/tuscany/sca/host/rmi/DefaultRMIHostExtensionPoint.java index b7435a1f84..541ee8ba06 100644 --- a/java/sca/modules/host-rmi/src/main/java/org/apache/tuscany/sca/host/rmi/DefaultRMIHostExtensionPoint.java +++ b/java/sca/modules/host-rmi/src/main/java/org/apache/tuscany/sca/host/rmi/DefaultRMIHostExtensionPoint.java @@ -34,7 +34,6 @@ public class DefaultRMIHostExtensionPoint implements RMIHostExtensionPoint, Life private List rmiHosts = new ArrayList(); public DefaultRMIHostExtensionPoint() { - addRMIHost(new DefaultRMIHost()); } public void addRMIHost(RMIHost rmiHost) { @@ -48,7 +47,10 @@ public class DefaultRMIHostExtensionPoint implements RMIHostExtensionPoint, Life rmiHosts.remove(rmiHost); } - public List getRMIHosts() { + public synchronized List getRMIHosts() { + if(rmiHosts.isEmpty()) { + addRMIHost(new DefaultRMIHost()); + } return rmiHosts; } -- cgit v1.2.3