git-svn-id: https://svn.apache.org/repos/asf/activemq/trunk@1382761 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Claus Ibsen 2012-09-10 11:28:18 +00:00
parent c70d97fddb
commit f272fc1df5
1 changed files with 22 additions and 3 deletions

View File

@ -83,12 +83,19 @@ public class ManagementContext implements Service {
public void start() throws IOException { public void start() throws IOException {
// lets force the MBeanServer to be created if needed // lets force the MBeanServer to be created if needed
if (started.compareAndSet(false, true)) { if (started.compareAndSet(false, true)) {
// force mbean server to be looked up, so we have it
getMBeanServer(); getMBeanServer();
if (connectorServer != null) { if (connectorServer != null) {
try { try {
if (getMBeanServer().isRegistered(namingServiceObjectName)) {
LOG.debug("Invoking start on mbean: {}", namingServiceObjectName);
getMBeanServer().invoke(namingServiceObjectName, "start", null, null); getMBeanServer().invoke(namingServiceObjectName, "start", null, null);
} catch (Throwable ignore) {
} }
} catch (Throwable ignore) {
LOG.debug("Error invoking start on mbean " + namingServiceObjectName + ". This exception is ignored.", ignore);
}
Thread t = new Thread("JMX connector") { Thread t = new Thread("JMX connector") {
@Override @Override
public void run() { public void run() {
@ -171,14 +178,27 @@ public class ManagementContext implements Service {
// check to see if the factory knows about this server // check to see if the factory knows about this server
List list = MBeanServerFactory.findMBeanServer(null); List list = MBeanServerFactory.findMBeanServer(null);
if (list != null && !list.isEmpty() && list.contains(beanServer)) { if (list != null && !list.isEmpty() && list.contains(beanServer)) {
LOG.debug("Releasing MBeanServer {}", beanServer);
MBeanServerFactory.releaseMBeanServer(beanServer); MBeanServerFactory.releaseMBeanServer(beanServer);
} }
} }
beanServer = null; beanServer = null;
if (registrySocket!=null) { if (registrySocket!=null) {
try { try {
if (LOG.isDebugEnabled()) {
LOG.debug("Closing registry socket {}, is closed: {}, is bound: {}",
new Object[]{registrySocket, registrySocket.isClosed(), registrySocket.isBound()});
}
registrySocket.close(); registrySocket.close();
if (LOG.isDebugEnabled()) {
LOG.debug("Closed registry socket {}, is closed: {}, is bound: {}",
new Object[]{registrySocket, registrySocket.isClosed(), registrySocket.isBound()});
}
} catch (IOException e) { } catch (IOException e) {
LOG.debug("Error closing registry socket " + registrySocket + ". This exception is ignored.", e);
} }
registrySocket = null; registrySocket = null;
} }
@ -471,10 +491,9 @@ public class ManagementContext implements Service {
/** /**
* @param mbeanServer * @param mbeanServer
* @throws MalformedObjectNameException * @throws MalformedObjectNameException
* @throws MalformedURLException
* @throws IOException * @throws IOException
*/ */
private void createConnector(MBeanServer mbeanServer) throws MalformedObjectNameException, MalformedURLException, IOException { private void createConnector(MBeanServer mbeanServer) throws MalformedObjectNameException, IOException {
// Create the NamingService, needed by JSR 160 // Create the NamingService, needed by JSR 160
try { try {
if (registry == null) { if (registry == null) {