1 18 package org.apache.activemq.broker.jmx; 19 20 import javax.jms.JMSException ; 21 import javax.management.ObjectName ; 22 23 import org.apache.activemq.broker.ConnectionContext; 24 import org.apache.activemq.broker.region.Destination; 25 import org.apache.activemq.broker.region.DestinationFactory; 26 import org.apache.activemq.broker.region.DestinationStatistics; 27 import org.apache.activemq.broker.region.Subscription; 28 import org.apache.activemq.broker.region.TopicRegion; 29 import org.apache.activemq.command.ActiveMQDestination; 30 import org.apache.activemq.command.ConsumerInfo; 31 import org.apache.activemq.memory.UsageManager; 32 import org.apache.activemq.thread.TaskRunnerFactory; 33 34 public class ManagedTopicRegion extends TopicRegion { 35 36 private final ManagedRegionBroker regionBroker; 37 38 public ManagedTopicRegion(ManagedRegionBroker broker, DestinationStatistics destinationStatistics, UsageManager memoryManager, TaskRunnerFactory taskRunnerFactory, DestinationFactory destinationFactory) { 39 super(broker,destinationStatistics, memoryManager, taskRunnerFactory, destinationFactory); 40 regionBroker = broker; 41 } 42 43 protected Subscription createSubscription(ConnectionContext context, ConsumerInfo info) throws JMSException { 44 Subscription sub = super.createSubscription(context, info); 45 ObjectName name = regionBroker.registerSubscription(context,sub); 46 sub.setObjectName(name); 47 return sub; 48 } 49 50 protected void destroySubscription(Subscription sub) { 51 regionBroker.unregisterSubscription(sub); 52 super.destroySubscription(sub); 53 } 54 55 protected Destination createDestination(ConnectionContext context, ActiveMQDestination destination) throws Exception { 56 Destination rc = super.createDestination(context, destination); 57 regionBroker.register(destination, rc); 58 return rc; 59 } 60 61 public void removeDestination(ConnectionContext context, ActiveMQDestination destination, long timeout) throws Exception { 62 super.removeDestination(context, destination, timeout); 63 regionBroker.unregister(destination); 64 } 65 66 } 67 | Popular Tags |