added some new MBean helper methods

git-svn-id: https://svn.apache.org/repos/asf/activemq/trunk@687034 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
James Strachan 2008-08-19 12:05:58 +00:00
parent 0a997b7eae
commit 52e15a48a1
2 changed files with 45 additions and 0 deletions

View File

@ -21,6 +21,9 @@ import javax.jms.InvalidSelectorException;
import org.apache.activemq.broker.region.Subscription;
import org.apache.activemq.command.ActiveMQDestination;
import org.apache.activemq.command.ConsumerInfo;
import org.apache.activemq.command.ActiveMQQueue;
import org.apache.activemq.command.ActiveMQTopic;
import org.apache.activemq.filter.DestinationFilter;
/**
* @version $Revision: 1.5 $
@ -276,4 +279,30 @@ public class SubscriptionView implements SubscriptionViewMBean {
return subscription != null ? subscription.getPrefetchSize() : 0;
}
public boolean isMatchingQueue(String queueName) {
if (isDestinationQueue()) {
return matchesDestination(new ActiveMQQueue(queueName));
}
return false;
}
public boolean isMatchingTopic(String topicName) {
if (isDestinationTopic()) {
return matchesDestination(new ActiveMQTopic(topicName));
}
return false;
}
/**
* Return true if this subscription matches the given destination
*
* @param destination the destination to compare against
* @return true if this subscription matches the given destination
*/
public boolean matchesDestination(ActiveMQDestination destination) {
ActiveMQDestination subscriptionDestination = subscription.getActiveMQDestination();
DestinationFilter filter = DestinationFilter.parseFilter(subscriptionDestination);
return filter.matches(destination);
}
}

View File

@ -154,4 +154,20 @@ public interface SubscriptionViewMBean {
* consumers.
*/
String getSubcriptionName();
/**
* Returns true if this subscription (which may be using wildcards) matches the given queue name
*
* @param queueName the JMS queue name to match against
* @return true if this subscription matches the given queue or false if not
*/
boolean isMatchingQueue(String queueName);
/**
* Returns true if this subscription (which may be using wildcards) matches the given topic name
*
* @param topicName the JMS topic name to match against
* @return true if this subscription matches the given topic or false if not
*/
boolean isMatchingTopic(String topicName);
}