git-svn-id: https://svn.apache.org/repos/asf/activemq/trunk@833395 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Bosanac Dejan 2009-11-06 13:56:28 +00:00
parent f1fa8f911d
commit b3873fb3e4
3 changed files with 27 additions and 6 deletions

View File

@ -440,6 +440,9 @@ public class BrokerService implements Service {
}); });
} }
processHelperProperties(); processHelperProperties();
if (isUseJmx()) {
startManagementContext();
}
getPersistenceAdapter().setUsageManager(getProducerSystemUsage()); getPersistenceAdapter().setUsageManager(getProducerSystemUsage());
getPersistenceAdapter().setBrokerName(getBrokerName()); getPersistenceAdapter().setBrokerName(getBrokerName());
LOG.info("Using Persistence Adapter: " + getPersistenceAdapter()); LOG.info("Using Persistence Adapter: " + getPersistenceAdapter());
@ -451,12 +454,15 @@ public class BrokerService implements Service {
addShutdownHook(); addShutdownHook();
getBroker().start(); getBroker().start();
if (isUseJmx()) { if (isUseJmx()) {
getManagementContext().start(); if (!getManagementContext().isConnectorStarted()) {
// try to restart management context
// typical for slaves that use the same ports as master
managementContext.stop();
startManagementContext();
}
ManagedRegionBroker managedBroker = (ManagedRegionBroker) regionBroker; ManagedRegionBroker managedBroker = (ManagedRegionBroker) regionBroker;
managedBroker.setContextBroker(broker); managedBroker.setContextBroker(broker);
adminView = new BrokerView(this, managedBroker); adminView.setBroker(managedBroker);
ObjectName objectName = getBrokerObjectName();
AnnotatedMBean.registerMBean(getManagementContext(), adminView, objectName);
} }
BrokerRegistry.getInstance().bind(getBrokerName(), this); BrokerRegistry.getInstance().bind(getBrokerName(), this);
// see if there is a MasterBroker service and if so, configure // see if there is a MasterBroker service and if so, configure
@ -1896,6 +1902,13 @@ public class BrokerService implements Service {
slaveStartSignal.countDown(); slaveStartSignal.countDown();
} }
protected void startManagementContext() throws Exception {
getManagementContext().start();
adminView = new BrokerView(this, null);
ObjectName objectName = getBrokerObjectName();
AnnotatedMBean.registerMBean(getManagementContext(), adminView, objectName);
}
/** /**
* Start all transport and network connections, proxies and bridges * Start all transport and network connections, proxies and bridges
* *

View File

@ -43,7 +43,7 @@ import org.apache.activemq.network.NetworkConnector;
*/ */
public class BrokerView implements BrokerViewMBean { public class BrokerView implements BrokerViewMBean {
final ManagedRegionBroker broker; ManagedRegionBroker broker;
private final BrokerService brokerService; private final BrokerService brokerService;
private final AtomicInteger sessionIdCounter = new AtomicInteger(0); private final AtomicInteger sessionIdCounter = new AtomicInteger(0);
@ -56,6 +56,10 @@ public class BrokerView implements BrokerViewMBean {
return broker; return broker;
} }
public void setBroker(ManagedRegionBroker broker) {
this.broker = broker;
}
public String getBrokerId() { public String getBrokerId() {
return broker.getBrokerId().toString(); return broker.getBrokerId().toString();
} }

View File

@ -217,6 +217,10 @@ public class ManagementContext implements Service {
return findTigerMbeanServer; return findTigerMbeanServer;
} }
public boolean isConnectorStarted() {
return connectorServer.isActive();
}
/** /**
* Enables/disables the searching for the Java 5 platform MBeanServer * Enables/disables the searching for the Java 5 platform MBeanServer
*/ */