Fixes AMQ-3651 : If the broker binds RMI registry port when it starts up, the broker should release RMI registry port when it shuts down

git-svn-id: https://svn.apache.org/repos/asf/activemq/trunk@1227186 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Hiram R. Chirino 2012-01-04 15:20:55 +00:00
parent 1753a699e0
commit 71d5fef019
1 changed files with 12 additions and 3 deletions

View File

@ -64,6 +64,7 @@ public class ManagementContext implements Service {
private JMXConnectorServer connectorServer;
private ObjectName namingServiceObjectName;
private Registry registry;
private ServerSocket registrySocket;
private final List<ObjectName> registeredMBeanNames = new CopyOnWriteArrayList<ObjectName>();
private boolean allowRemoteAddressInMBeanNames = true;
@ -146,6 +147,13 @@ public class ManagementContext implements Service {
}
}
beanServer = null;
if(registrySocket!=null) {
try {
registrySocket.close();
} catch (IOException e) {
}
registrySocket = null;
}
}
}
@ -419,12 +427,13 @@ public class ManagementContext implements Service {
registry = LocateRegistry.createRegistry(connectorPort, null, new RMIServerSocketFactory() {
public ServerSocket createServerSocket(int port)
throws IOException {
ServerSocket result = new ServerSocket(port);
result.setReuseAddress(true);
return result;
registrySocket = new ServerSocket(port);
registrySocket.setReuseAddress(true);
return registrySocket;
}});
}
namingServiceObjectName = ObjectName.getInstance("naming:type=rmiregistry");
// Do not use the createMBean as the mx4j jar may not be in the
// same class loader than the server
Class cl = Class.forName("mx4j.tools.naming.NamingService");