1 18 package org.apache.activemq.web; 19 20 import org.apache.activemq.broker.jmx.BrokerViewMBean; 21 import org.apache.activemq.broker.jmx.ManagementContext; 22 import org.apache.activemq.command.ActiveMQDestination; 23 24 import javax.management.MBeanServerConnection ; 25 import javax.management.MBeanServerInvocationHandler ; 26 import javax.management.MalformedObjectNameException ; 27 import javax.management.ObjectName ; 28 29 34 public class JMXBrokerFacade extends BrokerFacadeSupport { 35 private ManagementContext managementContext; 36 private ObjectName brokerName; 37 38 public BrokerViewMBean getBrokerAdmin() throws Exception { 39 MBeanServerConnection mbeanServer = getManagementContext().getMBeanServer(); 40 return (BrokerViewMBean) MBeanServerInvocationHandler.newProxyInstance(mbeanServer, getBrokerName(), BrokerViewMBean.class, true); 41 } 42 43 public void purgeQueue(ActiveMQDestination destination) throws Exception { 44 45 } 46 47 public ManagementContext getManagementContext() { 48 if (managementContext == null) { 49 managementContext = new ManagementContext(); 50 managementContext.setCreateConnector(true); 51 } 52 return managementContext; 53 } 54 55 public void setManagementContext(ManagementContext managementContext) { 56 this.managementContext = managementContext; 57 } 58 59 public ObjectName getBrokerName() throws MalformedObjectNameException { 60 if (brokerName == null) { 61 brokerName = createBrokerName(); 62 } 63 return brokerName; 64 } 65 66 public void setBrokerName(ObjectName brokerName) { 67 this.brokerName = brokerName; 68 } 69 70 protected ObjectName createBrokerName() throws MalformedObjectNameException { 71 return new ObjectName (getManagementContext().getJmxDomainName() + ":Type=Broker"); 72 } 73 } 74 | Popular Tags |