1 18 package org.apache.activemq.broker.jmx; 19 20 import javax.management.openmbean.CompositeData ; 21 import javax.management.openmbean.OpenDataException ; 22 import javax.management.openmbean.TabularData ; 23 24 import org.apache.activemq.broker.ConnectionContext; 25 import org.apache.activemq.broker.region.Subscription; 26 import org.apache.activemq.command.RemoveSubscriptionInfo; 27 30 public class DurableSubscriptionView extends SubscriptionView implements DurableSubscriptionViewMBean { 31 32 protected ManagedRegionBroker broker; 33 protected String subscriptionName; 34 39 public DurableSubscriptionView(ManagedRegionBroker broker,String clientId,Subscription sub){ 40 super(clientId,sub); 41 this.broker = broker; 42 this.subscriptionName = sub.getConsumerInfo().getSubscriptionName(); 43 } 44 45 48 public String getSubscriptionName(){ 49 return subscriptionName; 50 } 51 52 58 public CompositeData [] browse() throws OpenDataException { 59 return broker.browse(this); 60 } 61 62 68 public TabularData browseAsTable() throws OpenDataException { 69 return broker.browseAsTable(this); 70 } 71 72 75 public void destroy() throws Exception { 76 RemoveSubscriptionInfo info = new RemoveSubscriptionInfo(); 77 info.setClientId(clientId); 78 info.setSubcriptionName(subscriptionName); 79 ConnectionContext context = new ConnectionContext(); 80 context.setBroker(broker); 81 context.setClientId(clientId); 82 broker.removeSubscription(context, info); 83 } 84 85 public String toString(){ 86 return "InactiveDurableSubscriptionView: " + getClientId() + ":" + getSubscriptionName(); 87 } 88 } 89 | Popular Tags |