mirror of https://github.com/apache/activemq.git
Refactored ManagementContext to improve encapsulation - so all registrations of MBeans happen in one place
git-svn-id: https://svn.apache.org/repos/asf/activemq/trunk@799706 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
9caa5c8d4d
commit
1ec71bdff1
File diff suppressed because it is too large
Load Diff
|
@ -16,16 +16,8 @@
|
|||
*/
|
||||
package org.apache.activemq.broker;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.net.URI;
|
||||
import java.net.URISyntaxException;
|
||||
import java.util.Iterator;
|
||||
import java.util.concurrent.CopyOnWriteArrayList;
|
||||
|
||||
import javax.management.MBeanServer;
|
||||
import javax.management.ObjectName;
|
||||
|
||||
import org.apache.activemq.broker.jmx.ManagedTransportConnector;
|
||||
import org.apache.activemq.broker.jmx.ManagementContext;
|
||||
import org.apache.activemq.broker.region.ConnectorStatistics;
|
||||
import org.apache.activemq.command.BrokerInfo;
|
||||
import org.apache.activemq.security.MessageAuthorizationPolicy;
|
||||
|
@ -40,6 +32,12 @@ import org.apache.activemq.util.ServiceStopper;
|
|||
import org.apache.activemq.util.ServiceSupport;
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
import java.io.IOException;
|
||||
import java.net.URI;
|
||||
import java.net.URISyntaxException;
|
||||
import java.util.Iterator;
|
||||
import java.util.concurrent.CopyOnWriteArrayList;
|
||||
import javax.management.ObjectName;
|
||||
|
||||
/**
|
||||
* @org.apache.xbean.XBean
|
||||
|
@ -94,8 +92,8 @@ public class TransportConnector implements Connector, BrokerServiceAware {
|
|||
* Factory method to create a JMX managed version of this transport
|
||||
* connector
|
||||
*/
|
||||
public ManagedTransportConnector asManagedConnector(MBeanServer mbeanServer, ObjectName connectorName) throws IOException, URISyntaxException {
|
||||
ManagedTransportConnector rc = new ManagedTransportConnector(mbeanServer, connectorName, getServer());
|
||||
public ManagedTransportConnector asManagedConnector(ManagementContext context, ObjectName connectorName) throws IOException, URISyntaxException {
|
||||
ManagedTransportConnector rc = new ManagedTransportConnector(context, connectorName, getServer());
|
||||
rc.setBrokerInfo(getBrokerInfo());
|
||||
rc.setConnectUri(getConnectUri());
|
||||
rc.setDisableAsyncDispatch(isDisableAsyncDispatch());
|
||||
|
|
|
@ -16,30 +16,6 @@
|
|||
*/
|
||||
package org.apache.activemq.broker.jmx;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.Hashtable;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.concurrent.CopyOnWriteArraySet;
|
||||
|
||||
import javax.management.InstanceNotFoundException;
|
||||
import javax.management.MBeanServer;
|
||||
import javax.management.MalformedObjectNameException;
|
||||
import javax.management.ObjectName;
|
||||
import javax.management.openmbean.CompositeData;
|
||||
import javax.management.openmbean.CompositeDataSupport;
|
||||
import javax.management.openmbean.CompositeType;
|
||||
import javax.management.openmbean.OpenDataException;
|
||||
import javax.management.openmbean.TabularData;
|
||||
import javax.management.openmbean.TabularDataSupport;
|
||||
import javax.management.openmbean.TabularType;
|
||||
|
||||
import org.apache.activemq.broker.Broker;
|
||||
import org.apache.activemq.broker.BrokerService;
|
||||
import org.apache.activemq.broker.ConnectionContext;
|
||||
|
@ -71,10 +47,31 @@ import org.apache.activemq.util.ServiceStopper;
|
|||
import org.apache.activemq.util.SubscriptionKey;
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.Hashtable;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.concurrent.CopyOnWriteArraySet;
|
||||
import javax.management.InstanceNotFoundException;
|
||||
import javax.management.MalformedObjectNameException;
|
||||
import javax.management.ObjectName;
|
||||
import javax.management.openmbean.CompositeData;
|
||||
import javax.management.openmbean.CompositeDataSupport;
|
||||
import javax.management.openmbean.CompositeType;
|
||||
import javax.management.openmbean.OpenDataException;
|
||||
import javax.management.openmbean.TabularData;
|
||||
import javax.management.openmbean.TabularDataSupport;
|
||||
import javax.management.openmbean.TabularType;
|
||||
|
||||
public class ManagedRegionBroker extends RegionBroker {
|
||||
private static final Log LOG = LogFactory.getLog(ManagedRegionBroker.class);
|
||||
private final MBeanServer mbeanServer;
|
||||
private final ManagementContext managementContext;
|
||||
private final ObjectName brokerObjectName;
|
||||
private final Map<ObjectName, DestinationView> topics = new ConcurrentHashMap<ObjectName, DestinationView>();
|
||||
private final Map<ObjectName, DestinationView> queues = new ConcurrentHashMap<ObjectName, DestinationView>();
|
||||
|
@ -92,10 +89,10 @@ public class ManagedRegionBroker extends RegionBroker {
|
|||
/* This is the first broker in the broker interceptor chain. */
|
||||
private Broker contextBroker;
|
||||
|
||||
public ManagedRegionBroker(BrokerService brokerService, MBeanServer mbeanServer, ObjectName brokerObjectName, TaskRunnerFactory taskRunnerFactory, SystemUsage memoryManager,
|
||||
public ManagedRegionBroker(BrokerService brokerService, ManagementContext context, ObjectName brokerObjectName, TaskRunnerFactory taskRunnerFactory, SystemUsage memoryManager,
|
||||
DestinationFactory destinationFactory, DestinationInterceptor destinationInterceptor) throws IOException {
|
||||
super(brokerService, taskRunnerFactory, memoryManager, destinationFactory, destinationInterceptor);
|
||||
this.mbeanServer = mbeanServer;
|
||||
this.managementContext = context;
|
||||
this.brokerObjectName = brokerObjectName;
|
||||
}
|
||||
|
||||
|
@ -111,7 +108,7 @@ public class ManagedRegionBroker extends RegionBroker {
|
|||
for (Iterator<ObjectName> iter = registeredMBeans.iterator(); iter.hasNext();) {
|
||||
ObjectName name = iter.next();
|
||||
try {
|
||||
mbeanServer.unregisterMBean(name);
|
||||
managementContext.unregisterMBean(name);
|
||||
} catch (InstanceNotFoundException e) {
|
||||
LOG.warn("The MBean: " + name + " is no longer registered with JMX");
|
||||
} catch (Exception e) {
|
||||
|
@ -245,7 +242,7 @@ public class ManagedRegionBroker extends RegionBroker {
|
|||
}
|
||||
}
|
||||
try {
|
||||
mbeanServer.registerMBean(view, key);
|
||||
managementContext.registerMBean(view, key);
|
||||
registeredMBeans.add(key);
|
||||
} catch (Throwable e) {
|
||||
LOG.warn("Failed to register MBean: " + key);
|
||||
|
@ -260,7 +257,7 @@ public class ManagedRegionBroker extends RegionBroker {
|
|||
temporaryTopics.remove(key);
|
||||
if (registeredMBeans.remove(key)) {
|
||||
try {
|
||||
mbeanServer.unregisterMBean(key);
|
||||
managementContext.unregisterMBean(key);
|
||||
} catch (Throwable e) {
|
||||
LOG.warn("Failed to unregister MBean: " + key);
|
||||
LOG.debug("Failure reason: " + e, e);
|
||||
|
@ -288,7 +285,7 @@ public class ManagedRegionBroker extends RegionBroker {
|
|||
if (inactiveName != null) {
|
||||
inactiveDurableTopicSubscribers.remove(inactiveName);
|
||||
registeredMBeans.remove(inactiveName);
|
||||
mbeanServer.unregisterMBean(inactiveName);
|
||||
managementContext.unregisterMBean(inactiveName);
|
||||
}
|
||||
} catch (Throwable e) {
|
||||
LOG.error("Unable to unregister inactive durable subscriber: " + subscriptionKey, e);
|
||||
|
@ -300,7 +297,7 @@ public class ManagedRegionBroker extends RegionBroker {
|
|||
}
|
||||
|
||||
try {
|
||||
mbeanServer.registerMBean(view, key);
|
||||
managementContext.registerMBean(view, key);
|
||||
registeredMBeans.add(key);
|
||||
} catch (Throwable e) {
|
||||
LOG.warn("Failed to register MBean: " + key);
|
||||
|
@ -317,7 +314,7 @@ public class ManagedRegionBroker extends RegionBroker {
|
|||
temporaryTopicSubscribers.remove(key);
|
||||
if (registeredMBeans.remove(key)) {
|
||||
try {
|
||||
mbeanServer.unregisterMBean(key);
|
||||
managementContext.unregisterMBean(key);
|
||||
} catch (Throwable e) {
|
||||
LOG.warn("Failed to unregister MBean: " + key);
|
||||
LOG.debug("Failure reason: " + e, e);
|
||||
|
@ -370,7 +367,7 @@ public class ManagedRegionBroker extends RegionBroker {
|
|||
SubscriptionView view = new InactiveDurableSubscriptionView(this, key.getClientId(), info);
|
||||
|
||||
try {
|
||||
mbeanServer.registerMBean(view, objectName);
|
||||
managementContext.registerMBean(view, objectName);
|
||||
registeredMBeans.add(objectName);
|
||||
} catch (Throwable e) {
|
||||
LOG.warn("Failed to register MBean: " + key);
|
||||
|
|
|
@ -16,12 +16,6 @@
|
|||
*/
|
||||
package org.apache.activemq.broker.jmx;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.Hashtable;
|
||||
|
||||
import javax.management.MBeanServer;
|
||||
import javax.management.ObjectName;
|
||||
|
||||
import org.apache.activemq.broker.Broker;
|
||||
import org.apache.activemq.broker.TransportConnection;
|
||||
import org.apache.activemq.broker.TransportConnector;
|
||||
|
@ -33,6 +27,9 @@ import org.apache.activemq.util.IOExceptionSupport;
|
|||
import org.apache.activemq.util.JMXSupport;
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
import java.io.IOException;
|
||||
import java.util.Hashtable;
|
||||
import javax.management.ObjectName;
|
||||
|
||||
/**
|
||||
* A managed transport connection
|
||||
|
@ -42,7 +39,7 @@ import org.apache.commons.logging.LogFactory;
|
|||
public class ManagedTransportConnection extends TransportConnection {
|
||||
private static final Log LOG = LogFactory.getLog(ManagedTransportConnection.class);
|
||||
|
||||
private final MBeanServer server;
|
||||
private final ManagementContext managementContext;
|
||||
private final ObjectName connectorName;
|
||||
private ConnectionViewMBean mbean;
|
||||
|
||||
|
@ -50,10 +47,10 @@ public class ManagedTransportConnection extends TransportConnection {
|
|||
private ObjectName byAddressName;
|
||||
|
||||
public ManagedTransportConnection(TransportConnector connector, Transport transport, Broker broker,
|
||||
TaskRunnerFactory factory, MBeanServer server, ObjectName connectorName)
|
||||
TaskRunnerFactory factory, ManagementContext context, ObjectName connectorName)
|
||||
throws IOException {
|
||||
super(connector, transport, broker, factory);
|
||||
this.server = server;
|
||||
this.managementContext = context;
|
||||
this.connectorName = connectorName;
|
||||
this.mbean = new ConnectionView(this);
|
||||
byAddressName = createByAddressObjectName("address", transport.getRemoteAddress());
|
||||
|
@ -99,7 +96,7 @@ public class ManagedTransportConnection extends TransportConnection {
|
|||
protected void registerMBean(ObjectName name) {
|
||||
if (name != null) {
|
||||
try {
|
||||
server.registerMBean(mbean, name);
|
||||
managementContext.registerMBean(mbean, name);
|
||||
} catch (Throwable e) {
|
||||
LOG.warn("Failed to register MBean: " + name);
|
||||
LOG.debug("Failure reason: " + e, e);
|
||||
|
@ -110,7 +107,7 @@ public class ManagedTransportConnection extends TransportConnection {
|
|||
protected void unregisterMBean(ObjectName name) {
|
||||
if (name != null) {
|
||||
try {
|
||||
server.unregisterMBean(name);
|
||||
managementContext.unregisterMBean(name);
|
||||
} catch (Throwable e) {
|
||||
LOG.warn("Failed to unregister mbean: " + name);
|
||||
LOG.debug("Failure reason: " + e, e);
|
||||
|
|
|
@ -16,17 +16,14 @@
|
|||
*/
|
||||
package org.apache.activemq.broker.jmx;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.net.URISyntaxException;
|
||||
|
||||
import javax.management.MBeanServer;
|
||||
import javax.management.ObjectName;
|
||||
|
||||
import org.apache.activemq.broker.Broker;
|
||||
import org.apache.activemq.broker.Connection;
|
||||
import org.apache.activemq.broker.TransportConnector;
|
||||
import org.apache.activemq.transport.Transport;
|
||||
import org.apache.activemq.transport.TransportServer;
|
||||
import java.io.IOException;
|
||||
import java.net.URISyntaxException;
|
||||
import javax.management.MBeanServer;
|
||||
import javax.management.ObjectName;
|
||||
|
||||
/**
|
||||
* A managed transport connector which can create multiple managed connections
|
||||
|
@ -38,12 +35,12 @@ public class ManagedTransportConnector extends TransportConnector {
|
|||
|
||||
static long nextConnectionId = 1;
|
||||
|
||||
private final MBeanServer mbeanServer;
|
||||
private final ManagementContext managementContext;
|
||||
private final ObjectName connectorName;
|
||||
|
||||
public ManagedTransportConnector(MBeanServer mbeanServer, ObjectName connectorName, TransportServer server) {
|
||||
public ManagedTransportConnector(ManagementContext context, ObjectName connectorName, TransportServer server) {
|
||||
super(server);
|
||||
this.mbeanServer = mbeanServer;
|
||||
this.managementContext = context;
|
||||
this.connectorName = connectorName;
|
||||
}
|
||||
|
||||
|
@ -52,7 +49,7 @@ public class ManagedTransportConnector extends TransportConnector {
|
|||
}
|
||||
|
||||
protected Connection createConnection(Transport transport) throws IOException {
|
||||
return new ManagedTransportConnection(this, transport, getBroker(), isDisableAsyncDispatch() ? null : getTaskRunnerFactory(), mbeanServer, connectorName);
|
||||
return new ManagedTransportConnection(this, transport, getBroker(), isDisableAsyncDispatch() ? null : getTaskRunnerFactory(), managementContext, connectorName);
|
||||
}
|
||||
|
||||
protected static synchronized long getNextConnectionId() {
|
||||
|
|
|
@ -21,14 +21,23 @@ import java.lang.reflect.Method;
|
|||
import java.net.MalformedURLException;
|
||||
import java.rmi.registry.LocateRegistry;
|
||||
import java.rmi.registry.Registry;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.CopyOnWriteArrayList;
|
||||
import java.util.concurrent.atomic.AtomicBoolean;
|
||||
|
||||
import javax.management.Attribute;
|
||||
import javax.management.InstanceAlreadyExistsException;
|
||||
import javax.management.InstanceNotFoundException;
|
||||
import javax.management.JMException;
|
||||
import javax.management.MBeanRegistrationException;
|
||||
import javax.management.MBeanServer;
|
||||
import javax.management.MBeanServerFactory;
|
||||
import javax.management.MBeanServerInvocationHandler;
|
||||
import javax.management.MalformedObjectNameException;
|
||||
import javax.management.NotCompliantMBeanException;
|
||||
import javax.management.ObjectInstance;
|
||||
import javax.management.ObjectName;
|
||||
import javax.management.remote.JMXConnectorServer;
|
||||
import javax.management.remote.JMXConnectorServerFactory;
|
||||
|
@ -37,6 +46,7 @@ import javax.management.remote.JMXServiceURL;
|
|||
import org.apache.activemq.Service;
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
import sun.security.action.GetBooleanAction;
|
||||
|
||||
/**
|
||||
* A Flow provides different dispatch policies within the NMR
|
||||
|
@ -64,6 +74,7 @@ public class ManagementContext implements Service {
|
|||
private JMXConnectorServer connectorServer;
|
||||
private ObjectName namingServiceObjectName;
|
||||
private Registry registry;
|
||||
private List<ObjectName> registeredMBeanNames = new CopyOnWriteArrayList<ObjectName>();
|
||||
|
||||
public ManagementContext() {
|
||||
this(null);
|
||||
|
@ -101,8 +112,18 @@ public class ManagementContext implements Service {
|
|||
}
|
||||
}
|
||||
|
||||
public void stop() throws IOException {
|
||||
public void stop() throws Exception {
|
||||
if (started.compareAndSet(true, false)) {
|
||||
MBeanServer mbeanServer = getMBeanServer();
|
||||
if (mbeanServer != null) {
|
||||
for (Iterator<ObjectName> iter = registeredMBeanNames.iterator(); iter.hasNext();) {
|
||||
ObjectName name = iter.next();
|
||||
|
||||
mbeanServer.unregisterMBean(name);
|
||||
|
||||
}
|
||||
}
|
||||
registeredMBeanNames.clear();
|
||||
JMXConnectorServer server = connectorServer;
|
||||
connectorServer = null;
|
||||
if (server != null) {
|
||||
|
@ -146,7 +167,7 @@ public class ManagementContext implements Service {
|
|||
*
|
||||
* @return the MBeanServer
|
||||
*/
|
||||
public MBeanServer getMBeanServer() {
|
||||
protected MBeanServer getMBeanServer() {
|
||||
if (this.beanServer == null) {
|
||||
this.beanServer = findMBeanServer();
|
||||
}
|
||||
|
@ -258,7 +279,24 @@ public class ManagementContext implements Service {
|
|||
}
|
||||
return containerName + "." + name;
|
||||
}
|
||||
|
||||
|
||||
public Object newProxyInstance( ObjectName objectName,
|
||||
Class interfaceClass,
|
||||
boolean notificationBroadcaster){
|
||||
return MBeanServerInvocationHandler.newProxyInstance(getMBeanServer(), objectName, interfaceClass, notificationBroadcaster);
|
||||
|
||||
}
|
||||
|
||||
public Object getAttribute(ObjectName name, String attribute) throws Exception{
|
||||
return getMBeanServer().getAttribute(name, attribute);
|
||||
}
|
||||
|
||||
public ObjectInstance registerMBean(Object bean, ObjectName name) throws Exception{
|
||||
ObjectInstance result = getMBeanServer().registerMBean(bean, name);
|
||||
this.registeredMBeanNames.add(name);
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Unregister an MBean
|
||||
*
|
||||
|
@ -266,7 +304,7 @@ public class ManagementContext implements Service {
|
|||
* @throws JMException
|
||||
*/
|
||||
public void unregisterMBean(ObjectName name) throws JMException {
|
||||
if (beanServer != null && beanServer.isRegistered(name)) {
|
||||
if (beanServer != null && beanServer.isRegistered(name) && this.registeredMBeanNames.remove(name)) {
|
||||
beanServer.unregisterMBean(name);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -520,9 +520,6 @@ public class RegionBroker extends EmptyBroker {
|
|||
|
||||
public BrokerId getBrokerId() {
|
||||
if (brokerId == null) {
|
||||
// TODO: this should persist the broker id so that subsequent
|
||||
// startup
|
||||
// uses the same broker id.
|
||||
brokerId = new BrokerId(BROKER_ID_GENERATOR.generateId());
|
||||
}
|
||||
return brokerId;
|
||||
|
|
|
@ -16,25 +16,10 @@
|
|||
*/
|
||||
package org.apache.activemq.broker.view;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.PrintWriter;
|
||||
import java.util.Collection;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.Iterator;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import javax.management.MBeanServer;
|
||||
import javax.management.MBeanServerInvocationHandler;
|
||||
import javax.management.MalformedObjectNameException;
|
||||
import javax.management.ObjectName;
|
||||
|
||||
import org.apache.activemq.broker.Broker;
|
||||
import org.apache.activemq.broker.ConnectionContext;
|
||||
import org.apache.activemq.broker.ProducerBrokerExchange;
|
||||
import org.apache.activemq.broker.jmx.BrokerViewMBean;
|
||||
import org.apache.activemq.broker.jmx.ManagementContext;
|
||||
import org.apache.activemq.broker.jmx.SubscriptionViewMBean;
|
||||
import org.apache.activemq.broker.region.Subscription;
|
||||
import org.apache.activemq.command.ActiveMQDestination;
|
||||
|
@ -43,6 +28,15 @@ import org.apache.activemq.command.Message;
|
|||
import org.apache.activemq.command.ProducerId;
|
||||
import org.apache.activemq.command.ProducerInfo;
|
||||
import org.apache.activemq.filter.DestinationMapNode;
|
||||
import java.io.IOException;
|
||||
import java.io.PrintWriter;
|
||||
import java.util.Collection;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.Iterator;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import javax.management.ObjectName;
|
||||
|
||||
/**
|
||||
* @version $Revision: $
|
||||
|
@ -55,7 +49,6 @@ public class ConnectionDotFileInterceptor extends DotFileInterceptorSupport {
|
|||
private boolean clearProducerCacheAfterRender;
|
||||
private String domain = "org.apache.activemq";
|
||||
private BrokerViewMBean brokerView;
|
||||
private MBeanServer mbeanServer;
|
||||
|
||||
// until we have some MBeans for producers, lets do it all ourselves
|
||||
private Map<ProducerId, ProducerInfo> producers = new HashMap<ProducerId, ProducerInfo>();
|
||||
|
@ -65,10 +58,7 @@ public class ConnectionDotFileInterceptor extends DotFileInterceptorSupport {
|
|||
public ConnectionDotFileInterceptor(Broker next, String file, boolean redrawOnRemove) throws IOException {
|
||||
super(next, file);
|
||||
this.redrawOnRemove = redrawOnRemove;
|
||||
|
||||
mbeanServer = new ManagementContext().getMBeanServer();
|
||||
ObjectName brokerName = next.getBrokerService().getBrokerObjectName();
|
||||
brokerView = (BrokerViewMBean)MBeanServerInvocationHandler.newProxyInstance(mbeanServer, brokerName, BrokerViewMBean.class, true);
|
||||
|
||||
}
|
||||
|
||||
public Subscription addConsumer(ConnectionContext context, ConsumerInfo info) throws Exception {
|
||||
|
@ -123,7 +113,7 @@ public class ConnectionDotFileInterceptor extends DotFileInterceptorSupport {
|
|||
|
||||
writer.println("digraph \"ActiveMQ Connections\" {");
|
||||
writer.println();
|
||||
writer.println("label=\"ActiveMQ Broker: " + brokerView.getBrokerId() + "\"];");
|
||||
writer.println("label=\"ActiveMQ Broker: " + getBrokerView().getBrokerId() + "\"];");
|
||||
writer.println();
|
||||
writer.println("node [style = \"rounded,filled\", fillcolor = yellow, fontname=\"Helvetica-Oblique\"];");
|
||||
writer.println();
|
||||
|
@ -132,10 +122,10 @@ public class ConnectionDotFileInterceptor extends DotFileInterceptorSupport {
|
|||
Map<String, String> queues = new HashMap<String, String>();
|
||||
Map<String, String> topics = new HashMap<String, String>();
|
||||
|
||||
printSubscribers(writer, clients, queues, "queue_", brokerView.getQueueSubscribers());
|
||||
printSubscribers(writer, clients, queues, "queue_", getBrokerView().getQueueSubscribers());
|
||||
writer.println();
|
||||
|
||||
printSubscribers(writer, clients, topics, "topic_", brokerView.getTopicSubscribers());
|
||||
printSubscribers(writer, clients, topics, "topic_", getBrokerView().getTopicSubscribers());
|
||||
writer.println();
|
||||
|
||||
printProducers(writer, clients, queues, topics);
|
||||
|
@ -210,7 +200,7 @@ public class ConnectionDotFileInterceptor extends DotFileInterceptorSupport {
|
|||
protected void printSubscribers(PrintWriter writer, Map<String, String> clients, Map<String, String> destinations, String type, ObjectName[] subscribers) {
|
||||
for (int i = 0; i < subscribers.length; i++) {
|
||||
ObjectName name = subscribers[i];
|
||||
SubscriptionViewMBean subscriber = (SubscriptionViewMBean)MBeanServerInvocationHandler.newProxyInstance(mbeanServer, name, SubscriptionViewMBean.class, true);
|
||||
SubscriptionViewMBean subscriber = (SubscriptionViewMBean)getBrokerService().getManagementContext().newProxyInstance(name, SubscriptionViewMBean.class, true);
|
||||
|
||||
String clientId = subscriber.getClientId();
|
||||
String safeClientId = asID(clientId);
|
||||
|
@ -332,4 +322,13 @@ public class ConnectionDotFileInterceptor extends DotFileInterceptorSupport {
|
|||
}
|
||||
return path;
|
||||
}
|
||||
|
||||
BrokerViewMBean getBrokerView() throws Exception {
|
||||
if (this.brokerView == null) {
|
||||
ObjectName brokerName = getBrokerService().getBrokerObjectName();
|
||||
this.brokerView = (BrokerViewMBean) getBrokerService().getManagementContext().newProxyInstance(brokerName,
|
||||
BrokerViewMBean.class, true);
|
||||
}
|
||||
return this.brokerView;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -16,22 +16,6 @@
|
|||
*/
|
||||
package org.apache.activemq.network;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.net.URI;
|
||||
import java.net.URISyntaxException;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.ConcurrentLinkedQueue;
|
||||
import java.util.concurrent.CopyOnWriteArrayList;
|
||||
|
||||
import javax.management.MBeanServer;
|
||||
import javax.management.MalformedObjectNameException;
|
||||
import javax.management.ObjectName;
|
||||
|
||||
import org.apache.activemq.Service;
|
||||
import org.apache.activemq.broker.BrokerService;
|
||||
import org.apache.activemq.broker.jmx.NetworkBridgeView;
|
||||
|
@ -45,6 +29,17 @@ import org.apache.activemq.util.ServiceStopper;
|
|||
import org.apache.activemq.util.ServiceSupport;
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
import java.net.URI;
|
||||
import java.net.URISyntaxException;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.ConcurrentLinkedQueue;
|
||||
import java.util.concurrent.CopyOnWriteArrayList;
|
||||
import javax.management.MalformedObjectNameException;
|
||||
import javax.management.ObjectName;
|
||||
|
||||
/**
|
||||
* @version $Revision$
|
||||
|
@ -238,16 +233,12 @@ public abstract class NetworkConnector extends NetworkBridgeConfiguration implem
|
|||
if (!getBrokerService().isUseJmx()) {
|
||||
return;
|
||||
}
|
||||
|
||||
MBeanServer mbeanServer = getBrokerService().getManagementContext().getMBeanServer();
|
||||
if (mbeanServer != null) {
|
||||
NetworkBridgeViewMBean view = new NetworkBridgeView(bridge);
|
||||
try {
|
||||
ObjectName objectName = createNetworkBridgeObjectName(bridge);
|
||||
mbeanServer.registerMBean(view, objectName);
|
||||
} catch (Throwable e) {
|
||||
LOG.debug("Network bridge could not be registered in JMX: " + e.getMessage(), e);
|
||||
}
|
||||
NetworkBridgeViewMBean view = new NetworkBridgeView(bridge);
|
||||
try {
|
||||
ObjectName objectName = createNetworkBridgeObjectName(bridge);
|
||||
getBrokerService().getManagementContext().registerMBean(view, objectName);
|
||||
} catch (Throwable e) {
|
||||
LOG.debug("Network bridge could not be registered in JMX: " + e.getMessage(), e);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -255,15 +246,11 @@ public abstract class NetworkConnector extends NetworkBridgeConfiguration implem
|
|||
if (!getBrokerService().isUseJmx()) {
|
||||
return;
|
||||
}
|
||||
|
||||
MBeanServer mbeanServer = getBrokerService().getManagementContext().getMBeanServer();
|
||||
if (mbeanServer != null) {
|
||||
try {
|
||||
ObjectName objectName = createNetworkBridgeObjectName(bridge);
|
||||
mbeanServer.unregisterMBean(objectName);
|
||||
} catch (Throwable e) {
|
||||
LOG.debug("Network bridge could not be unregistered in JMX: " + e.getMessage(), e);
|
||||
}
|
||||
try {
|
||||
ObjectName objectName = createNetworkBridgeObjectName(bridge);
|
||||
getBrokerService().getManagementContext().unregisterMBean(objectName);
|
||||
} catch (Throwable e) {
|
||||
LOG.debug("Network bridge could not be unregistered in JMX: " + e.getMessage(), e);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -16,15 +16,13 @@
|
|||
*/
|
||||
package org.apache.activemq.transport;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import javax.management.ObjectName;
|
||||
|
||||
import org.apache.activemq.broker.jmx.ManagementContext;
|
||||
import org.apache.activemq.util.IOExceptionSupport;
|
||||
import org.apache.activemq.util.LogWriterFinder;
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
import java.io.IOException;
|
||||
import javax.management.ObjectName;
|
||||
|
||||
/**
|
||||
* Singleton class to create TransportLogger objects.
|
||||
|
@ -201,7 +199,7 @@ public class TransportLoggerFactory {
|
|||
|
||||
try {
|
||||
this.objectName = new ObjectName(this.managementContext.getJmxDomainName()+":"+ "Type=TransportLoggerControl");
|
||||
this.managementContext.getMBeanServer().registerMBean(new TransportLoggerControl(this.managementContext),this.objectName);
|
||||
this.managementContext.registerMBean(new TransportLoggerControl(this.managementContext),this.objectName);
|
||||
|
||||
this.transportLoggerControlCreated = true;
|
||||
|
||||
|
|
|
@ -119,7 +119,7 @@ public class TransportLoggerView implements TransportLoggerViewMBean {
|
|||
*/
|
||||
private void register() {
|
||||
try {
|
||||
this.managementContext.getMBeanServer().registerMBean(this, this.name);
|
||||
this.managementContext.registerMBean(this, this.name);
|
||||
} catch (Exception e) {
|
||||
log.error("Could not register MBean for TransportLoggerView " + id + "with name " + this.name.toString() + ", reason: " + e, e);
|
||||
}
|
||||
|
@ -138,7 +138,7 @@ public class TransportLoggerView implements TransportLoggerViewMBean {
|
|||
TransportLoggerView.transportLoggerViews.remove(this);
|
||||
|
||||
try {
|
||||
this.managementContext.getMBeanServer().unregisterMBean(this.name);
|
||||
this.managementContext.unregisterMBean(this.name);
|
||||
} catch (Exception e) {
|
||||
log.error("Could not unregister MBean for TransportLoggerView " + id + "with name " + this.name.toString() + ", reason: " + e, e);
|
||||
}
|
||||
|
|
|
@ -910,7 +910,7 @@ public class JMSConsumerTest extends JmsTestSupport {
|
|||
}
|
||||
|
||||
protected DestinationViewMBean createView(ActiveMQDestination destination) throws Exception {
|
||||
MBeanServer mbeanServer = broker.getManagementContext().getMBeanServer();
|
||||
|
||||
String domain = "org.apache.activemq";
|
||||
ObjectName name;
|
||||
if (destination.isQueue()) {
|
||||
|
@ -918,7 +918,7 @@ public class JMSConsumerTest extends JmsTestSupport {
|
|||
} else {
|
||||
name = new ObjectName(domain + ":BrokerName=localhost,Type=Topic,Destination=test");
|
||||
}
|
||||
return (DestinationViewMBean)MBeanServerInvocationHandler.newProxyInstance(mbeanServer, name, DestinationViewMBean.class, true);
|
||||
return (DestinationViewMBean)broker.getManagementContext().newProxyInstance(name, DestinationViewMBean.class, true);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -74,9 +74,8 @@ public class QueuePurgeTest extends TestCase {
|
|||
ObjectName queueViewMBeanName = new ObjectName("org.apache.activemq"
|
||||
+ ":Type=Queue,Destination=" + queue.getQueueName()
|
||||
+ ",BrokerName=localhost");
|
||||
QueueViewMBean proxy = (QueueViewMBean) MBeanServerInvocationHandler
|
||||
.newProxyInstance(broker.getManagementContext()
|
||||
.getMBeanServer(), queueViewMBeanName,
|
||||
QueueViewMBean proxy = (QueueViewMBean) broker.getManagementContext()
|
||||
.newProxyInstance(queueViewMBeanName,
|
||||
QueueViewMBean.class, true);
|
||||
return proxy;
|
||||
}
|
||||
|
|
|
@ -236,9 +236,8 @@ public class NegativeQueueTest extends TestCase {
|
|||
|
||||
ObjectName queueViewMBeanName = new ObjectName("org.apache.activemq" + ":Type=Queue,Destination=" +
|
||||
queue.getQueueName() + ",BrokerName=localhost");
|
||||
QueueViewMBean proxy = (QueueViewMBean)MBeanServerInvocationHandler.newProxyInstance(
|
||||
broker.getManagementContext().getMBeanServer(),
|
||||
queueViewMBeanName, QueueViewMBean.class, true);
|
||||
QueueViewMBean proxy = (QueueViewMBean) broker.getManagementContext().newProxyInstance(queueViewMBeanName,
|
||||
QueueViewMBean.class, true);
|
||||
|
||||
return proxy;
|
||||
}
|
||||
|
|
|
@ -2,17 +2,6 @@ package org.apache.activemq.bugs;
|
|||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertFalse;
|
||||
|
||||
import javax.jms.ConnectionFactory;
|
||||
import javax.jms.MessageProducer;
|
||||
import javax.jms.Queue;
|
||||
import javax.jms.QueueBrowser;
|
||||
import javax.jms.Session;
|
||||
import javax.jms.TextMessage;
|
||||
import javax.management.MBeanServer;
|
||||
import javax.management.MBeanServerInvocationHandler;
|
||||
import javax.management.ObjectName;
|
||||
|
||||
import org.apache.activemq.ActiveMQConnection;
|
||||
import org.apache.activemq.ActiveMQConnectionFactory;
|
||||
import org.apache.activemq.broker.BrokerService;
|
||||
|
@ -23,6 +12,13 @@ import org.apache.activemq.command.ActiveMQDestination;
|
|||
import org.junit.After;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import javax.jms.ConnectionFactory;
|
||||
import javax.jms.MessageProducer;
|
||||
import javax.jms.Queue;
|
||||
import javax.jms.QueueBrowser;
|
||||
import javax.jms.Session;
|
||||
import javax.jms.TextMessage;
|
||||
import javax.management.ObjectName;
|
||||
|
||||
/**
|
||||
* Test to determine if expired messages are being reaped if there is
|
||||
|
@ -122,7 +118,6 @@ public class MessageExpirationReaperTest {
|
|||
}
|
||||
|
||||
protected DestinationViewMBean createView(ActiveMQDestination destination) throws Exception {
|
||||
MBeanServer mbeanServer = broker.getManagementContext().getMBeanServer();
|
||||
String domain = "org.apache.activemq";
|
||||
ObjectName name;
|
||||
if (destination.isQueue()) {
|
||||
|
@ -130,6 +125,7 @@ public class MessageExpirationReaperTest {
|
|||
} else {
|
||||
name = new ObjectName(domain + ":BrokerName=" + brokerName + ",Type=Topic,Destination=" + destinationName);
|
||||
}
|
||||
return (DestinationViewMBean)MBeanServerInvocationHandler.newProxyInstance(mbeanServer, name, DestinationViewMBean.class, true);
|
||||
return (DestinationViewMBean) broker.getManagementContext().newProxyInstance(name, DestinationViewMBean.class,
|
||||
true);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -16,29 +16,6 @@
|
|||
*/
|
||||
package org.apache.activemq.transport.stomp;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.net.Socket;
|
||||
import java.net.SocketTimeoutException;
|
||||
import java.net.URI;
|
||||
import java.net.URISyntaxException;
|
||||
import java.net.UnknownHostException;
|
||||
import java.util.HashMap;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
import javax.jms.BytesMessage;
|
||||
import javax.jms.Connection;
|
||||
import javax.jms.JMSException;
|
||||
import javax.jms.MapMessage;
|
||||
import javax.jms.MessageConsumer;
|
||||
import javax.jms.MessageProducer;
|
||||
import javax.jms.ObjectMessage;
|
||||
import javax.jms.Session;
|
||||
import javax.jms.TextMessage;
|
||||
import javax.management.MBeanServer;
|
||||
import javax.management.MBeanServerInvocationHandler;
|
||||
import javax.management.ObjectName;
|
||||
|
||||
import org.apache.activemq.ActiveMQConnectionFactory;
|
||||
import org.apache.activemq.CombinationTestSupport;
|
||||
import org.apache.activemq.broker.BrokerFactory;
|
||||
|
@ -48,6 +25,25 @@ import org.apache.activemq.command.ActiveMQQueue;
|
|||
import org.apache.activemq.command.ActiveMQTextMessage;
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
import java.io.IOException;
|
||||
import java.net.Socket;
|
||||
import java.net.SocketTimeoutException;
|
||||
import java.net.URI;
|
||||
import java.net.URISyntaxException;
|
||||
import java.net.UnknownHostException;
|
||||
import java.util.HashMap;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
import javax.jms.BytesMessage;
|
||||
import javax.jms.Connection;
|
||||
import javax.jms.JMSException;
|
||||
import javax.jms.MapMessage;
|
||||
import javax.jms.MessageConsumer;
|
||||
import javax.jms.MessageProducer;
|
||||
import javax.jms.ObjectMessage;
|
||||
import javax.jms.Session;
|
||||
import javax.jms.TextMessage;
|
||||
import javax.management.ObjectName;
|
||||
|
||||
public class StompTest extends CombinationTestSupport {
|
||||
private static final Log LOG = LogFactory.getLog(StompTest.class);
|
||||
|
@ -882,12 +878,11 @@ public class StompTest extends CombinationTestSupport {
|
|||
|
||||
public void testDurableUnsub() throws Exception {
|
||||
// get broker JMX view
|
||||
MBeanServer mbeanServer = broker.getManagementContext().getMBeanServer();
|
||||
|
||||
|
||||
String domain = "org.apache.activemq";
|
||||
ObjectName brokerName = new ObjectName(domain + ":Type=Broker,BrokerName=localhost");
|
||||
|
||||
BrokerViewMBean view = (BrokerViewMBean)MBeanServerInvocationHandler.newProxyInstance(mbeanServer, brokerName, BrokerViewMBean.class, true);
|
||||
BrokerViewMBean view = (BrokerViewMBean)broker.getManagementContext().newProxyInstance(brokerName, BrokerViewMBean.class, true);
|
||||
|
||||
// connect
|
||||
String frame = "CONNECT\n" + "login: system\n" + "passcode: manager\nclient-id:test\n\n" + Stomp.NULL;
|
||||
|
|
|
@ -16,21 +16,6 @@
|
|||
*/
|
||||
package org.apache.activemq.usecases;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.concurrent.atomic.AtomicLong;
|
||||
|
||||
import javax.jms.Connection;
|
||||
import javax.jms.DeliveryMode;
|
||||
import javax.jms.Message;
|
||||
import javax.jms.MessageConsumer;
|
||||
import javax.jms.MessageProducer;
|
||||
import javax.jms.Session;
|
||||
import javax.management.MBeanServer;
|
||||
import javax.management.MBeanServerInvocationHandler;
|
||||
import javax.management.ObjectName;
|
||||
|
||||
import junit.framework.Test;
|
||||
|
||||
import org.apache.activemq.ActiveMQConnectionFactory;
|
||||
import org.apache.activemq.CombinationTestSupport;
|
||||
import org.apache.activemq.broker.BrokerService;
|
||||
|
@ -44,6 +29,16 @@ import org.apache.activemq.store.amq.AMQPersistenceAdapter;
|
|||
import org.apache.activemq.util.Wait;
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
import java.io.File;
|
||||
import java.util.concurrent.atomic.AtomicLong;
|
||||
import javax.jms.Connection;
|
||||
import javax.jms.DeliveryMode;
|
||||
import javax.jms.Message;
|
||||
import javax.jms.MessageConsumer;
|
||||
import javax.jms.MessageProducer;
|
||||
import javax.jms.Session;
|
||||
import javax.management.ObjectName;
|
||||
import junit.framework.Test;
|
||||
|
||||
public class ExpiredMessagesTest extends CombinationTestSupport {
|
||||
|
||||
|
@ -289,16 +284,18 @@ public class ExpiredMessagesTest extends CombinationTestSupport {
|
|||
}
|
||||
|
||||
protected DestinationViewMBean createView(ActiveMQDestination destination) throws Exception {
|
||||
MBeanServer mbeanServer = broker.getManagementContext().getMBeanServer();
|
||||
String domain = "org.apache.activemq";
|
||||
ObjectName name;
|
||||
if (destination.isQueue()) {
|
||||
name = new ObjectName(domain + ":BrokerName=localhost,Type=Queue,Destination=" + destination.getPhysicalName());
|
||||
} else {
|
||||
name = new ObjectName(domain + ":BrokerName=localhost,Type=Topic,Destination=" + destination.getPhysicalName());
|
||||
}
|
||||
return (DestinationViewMBean)MBeanServerInvocationHandler.newProxyInstance(mbeanServer, name, DestinationViewMBean.class, true);
|
||||
}
|
||||
String domain = "org.apache.activemq";
|
||||
ObjectName name;
|
||||
if (destination.isQueue()) {
|
||||
name = new ObjectName(domain + ":BrokerName=localhost,Type=Queue,Destination="
|
||||
+ destination.getPhysicalName());
|
||||
} else {
|
||||
name = new ObjectName(domain + ":BrokerName=localhost,Type=Topic,Destination="
|
||||
+ destination.getPhysicalName());
|
||||
}
|
||||
return (DestinationViewMBean) broker.getManagementContext().newProxyInstance(name, DestinationViewMBean.class,
|
||||
true);
|
||||
}
|
||||
|
||||
protected void tearDown() throws Exception {
|
||||
connection.stop();
|
||||
|
|
|
@ -16,21 +16,6 @@
|
|||
*/
|
||||
package org.apache.activemq.usecases;
|
||||
|
||||
import java.util.concurrent.CountDownLatch;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import javax.jms.Connection;
|
||||
import javax.jms.Message;
|
||||
import javax.jms.MessageConsumer;
|
||||
import javax.jms.MessageListener;
|
||||
import javax.jms.MessageProducer;
|
||||
import javax.jms.Session;
|
||||
import javax.management.MBeanServer;
|
||||
import javax.management.MBeanServerInvocationHandler;
|
||||
import javax.management.ObjectName;
|
||||
|
||||
import junit.framework.Test;
|
||||
|
||||
import org.apache.activemq.ActiveMQConnectionFactory;
|
||||
import org.apache.activemq.CombinationTestSupport;
|
||||
import org.apache.activemq.broker.BrokerService;
|
||||
|
@ -42,6 +27,16 @@ import org.apache.activemq.command.ActiveMQQueue;
|
|||
import org.apache.activemq.util.Wait;
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
import java.util.concurrent.CountDownLatch;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import javax.jms.Connection;
|
||||
import javax.jms.Message;
|
||||
import javax.jms.MessageConsumer;
|
||||
import javax.jms.MessageListener;
|
||||
import javax.jms.MessageProducer;
|
||||
import javax.jms.Session;
|
||||
import javax.management.ObjectName;
|
||||
import junit.framework.Test;
|
||||
|
||||
|
||||
public class ExpiredMessagesWithNoConsumerTest extends CombinationTestSupport {
|
||||
|
@ -248,16 +243,16 @@ public class ExpiredMessagesWithNoConsumerTest extends CombinationTestSupport {
|
|||
}
|
||||
|
||||
protected DestinationViewMBean createView(ActiveMQDestination destination) throws Exception {
|
||||
MBeanServer mbeanServer = broker.getManagementContext().getMBeanServer();
|
||||
String domain = "org.apache.activemq";
|
||||
ObjectName name;
|
||||
if (destination.isQueue()) {
|
||||
name = new ObjectName(domain + ":BrokerName=localhost,Type=Queue,Destination=test");
|
||||
} else {
|
||||
name = new ObjectName(domain + ":BrokerName=localhost,Type=Topic,Destination=test");
|
||||
}
|
||||
return (DestinationViewMBean)MBeanServerInvocationHandler.newProxyInstance(mbeanServer, name, DestinationViewMBean.class, true);
|
||||
}
|
||||
String domain = "org.apache.activemq";
|
||||
ObjectName name;
|
||||
if (destination.isQueue()) {
|
||||
name = new ObjectName(domain + ":BrokerName=localhost,Type=Queue,Destination=test");
|
||||
} else {
|
||||
name = new ObjectName(domain + ":BrokerName=localhost,Type=Topic,Destination=test");
|
||||
}
|
||||
return (DestinationViewMBean) broker.getManagementContext().newProxyInstance(name, DestinationViewMBean.class,
|
||||
true);
|
||||
}
|
||||
|
||||
protected void tearDown() throws Exception {
|
||||
connection.stop();
|
||||
|
|
|
@ -16,17 +16,13 @@
|
|||
*/
|
||||
package org.apache.activemq.xbean;
|
||||
|
||||
import java.net.URI;
|
||||
import java.util.Hashtable;
|
||||
|
||||
import javax.management.MBeanServer;
|
||||
import javax.management.ObjectName;
|
||||
|
||||
import junit.framework.TestCase;
|
||||
|
||||
import org.apache.activemq.broker.BrokerFactory;
|
||||
import org.apache.activemq.broker.BrokerService;
|
||||
import org.apache.activemq.util.JMXSupport;
|
||||
import java.net.URI;
|
||||
import java.util.Hashtable;
|
||||
import javax.management.ObjectName;
|
||||
import junit.framework.TestCase;
|
||||
|
||||
/**
|
||||
* @version $Revision: 1.1 $
|
||||
|
@ -36,19 +32,14 @@ public class ManagementContextXBeanConfigTest extends TestCase {
|
|||
protected BrokerService brokerService;
|
||||
|
||||
public void testManagmentContextConfiguredCorrectly() throws Exception {
|
||||
|
||||
assertEquals(2011, brokerService.getManagementContext().getConnectorPort());
|
||||
assertEquals("test.domain", brokerService.getManagementContext().getJmxDomainName());
|
||||
|
||||
MBeanServer beanServer = brokerService.getManagementContext().getMBeanServer();
|
||||
|
||||
// Make sure the broker is registered in the right jmx domain.
|
||||
Hashtable<String, String> map = new Hashtable<String, String>();
|
||||
map.put("Type", "Broker");
|
||||
map.put("BrokerName", JMXSupport.encodeObjectNamePart("localhost"));
|
||||
ObjectName on = new ObjectName("test.domain", map);
|
||||
|
||||
Object value = beanServer.getAttribute(on, "TotalEnqueueCount");
|
||||
Object value = brokerService.getManagementContext().getAttribute(on, "TotalEnqueueCount");
|
||||
assertNotNull(value);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue