From 159f98728e0a26dccac9e5ccbc4adf4966b20b1b Mon Sep 17 00:00:00 2001 From: Costin Leau Date: Thu, 29 Apr 2010 14:42:24 +0000 Subject: [PATCH] SPR-7137 + fixed incorrect message when unregistering services from passed in registries --- .../remoting/rmi/RmiServiceExporter.java | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/org.springframework.context/src/main/java/org/springframework/remoting/rmi/RmiServiceExporter.java b/org.springframework.context/src/main/java/org/springframework/remoting/rmi/RmiServiceExporter.java index f276352aea4..299f577a5e4 100644 --- a/org.springframework.context/src/main/java/org/springframework/remoting/rmi/RmiServiceExporter.java +++ b/org.springframework.context/src/main/java/org/springframework/remoting/rmi/RmiServiceExporter.java @@ -92,6 +92,8 @@ public class RmiServiceExporter extends RmiBasedExporter implements Initializing private Remote exportedObject; + private boolean createdRegistry = false; + /** * Set the name of the exported RMI service, @@ -258,10 +260,13 @@ public class RmiServiceExporter extends RmiBasedExporter implements Initializing "RMIServerSocketFactory without RMIClientSocketFactory for registry not supported"); } + this.createdRegistry = false; + // Determine RMI registry to use. if (this.registry == null) { this.registry = getRegistry(this.registryHost, this.registryPort, this.registryClientSocketFactory, this.registryServerSocketFactory); + this.createdRegistry = true; } // Initialize and cache exported object. @@ -318,7 +323,7 @@ public class RmiServiceExporter extends RmiBasedExporter implements Initializing throws RemoteException { if (registryHost != null) { - // Host explictly specified: only lookup possible. + // Host explicitly specified: only lookup possible. if (logger.isInfoEnabled()) { logger.info("Looking for RMI registry at port '" + registryPort + "' of host [" + registryHost + "]"); } @@ -422,15 +427,15 @@ public class RmiServiceExporter extends RmiBasedExporter implements Initializing public void destroy() throws RemoteException { if (logger.isInfoEnabled()) { logger.info("Unbinding RMI service '" + this.serviceName + - "' from registry at port '" + this.registryPort + "'"); + "' from registry" + (this.createdRegistry ? (" at port '" + this.registryPort + "'") : "")); } try { this.registry.unbind(this.serviceName); } catch (NotBoundException ex) { if (logger.isWarnEnabled()) { - logger.warn("RMI service '" + this.serviceName + "' is not bound to registry at port '" + - this.registryPort + "' anymore", ex); + logger.warn("RMI service '" + this.serviceName + "' is not bound to registry" + + (this.createdRegistry ? (" at port '" + this.registryPort + "' anymore") : ""), ex); } } finally { @@ -451,5 +456,4 @@ public class RmiServiceExporter extends RmiBasedExporter implements Initializing } } } - -} +} \ No newline at end of file