r2026 - in trunk/nuiton-utils/src: main/java/org/nuiton/util/rmi test/java/org/nuiton/util/rmi
Author: athimel Date: 2011-01-20 16:24:43 +0100 (Thu, 20 Jan 2011) New Revision: 2026 Url: http://nuiton.org/repositories/revision/nuiton-utils/2026 Log: Evolution#1209 Try to solve Hudson build problem because of duplicate RMIRegistry Modified: trunk/nuiton-utils/src/main/java/org/nuiton/util/rmi/ServiceExporter.java trunk/nuiton-utils/src/test/java/org/nuiton/util/rmi/RmiExporterAndProxyTest.java Modified: trunk/nuiton-utils/src/main/java/org/nuiton/util/rmi/ServiceExporter.java =================================================================== --- trunk/nuiton-utils/src/main/java/org/nuiton/util/rmi/ServiceExporter.java 2011-01-20 10:15:07 UTC (rev 2025) +++ trunk/nuiton-utils/src/main/java/org/nuiton/util/rmi/ServiceExporter.java 2011-01-20 15:24:43 UTC (rev 2026) @@ -33,6 +33,7 @@ import java.rmi.RemoteException; import java.rmi.registry.LocateRegistry; import java.rmi.registry.Registry; +import java.rmi.server.ExportException; import java.rmi.server.UnicastRemoteObject; /** @@ -79,7 +80,13 @@ if (log.isWarnEnabled()) { log.warn("Registry not found, creating a new one"); } - result = LocateRegistry.createRegistry(PORT); + try { + result = LocateRegistry.createRegistry(PORT); + } catch (ExportException ee) { // This is the particular case when a registry is already running but not on the correct port. + + // Try the default port + result = LocateRegistry.getRegistry(); + } } return result; } @@ -127,7 +134,7 @@ * * @param serviceInterface the interface used to unbind the service. The RMI * name will be generated from this class name - * @throws RemoteException in case the registry is not reachable + * @throws RemoteException in case the registry is not reachable * @throws NotBoundException in case the given name is not bound */ public static void unregisterService(Class<?> serviceInterface) @@ -139,8 +146,8 @@ /** * Will unregister a service using the given RMI name. * - * @param rmiName the RMI name used to unbind the service in the registry - * @throws RemoteException in case the registry is not reachable + * @param rmiName the RMI name used to unbind the service in the registry + * @throws RemoteException in case the registry is not reachable * @throws NotBoundException in case the given name is not bound */ public static void unregisterService(String rmiName) Modified: trunk/nuiton-utils/src/test/java/org/nuiton/util/rmi/RmiExporterAndProxyTest.java =================================================================== --- trunk/nuiton-utils/src/test/java/org/nuiton/util/rmi/RmiExporterAndProxyTest.java 2011-01-20 10:15:07 UTC (rev 2025) +++ trunk/nuiton-utils/src/test/java/org/nuiton/util/rmi/RmiExporterAndProxyTest.java 2011-01-20 15:24:43 UTC (rev 2026) @@ -1,3 +1,27 @@ +/* + * #%L + * Nuiton Utils + * + * $Id$ + * $HeadURL$ + * %% + * Copyright (C) 2004 - 2010 CodeLutin + * %% + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Lesser Public License for more details. + * + * You should have received a copy of the GNU General Lesser Public + * License along with this program. If not, see + * <http://www.gnu.org/licenses/lgpl-3.0.html>. + * #L% + */ package org.nuiton.util.rmi; import org.apache.commons.logging.Log; Property changes on: trunk/nuiton-utils/src/test/java/org/nuiton/util/rmi/RmiExporterAndProxyTest.java ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL
participants (1)
-
athimelï¼ users.nuiton.org