diff --git a/activemq-client/src/main/java/org/apache/activemq/filter/PrefixDestinationFilter.java b/activemq-client/src/main/java/org/apache/activemq/filter/PrefixDestinationFilter.java index abe7530f8d..5f9b6bc8f2 100755 --- a/activemq-client/src/main/java/org/apache/activemq/filter/PrefixDestinationFilter.java +++ b/activemq-client/src/main/java/org/apache/activemq/filter/PrefixDestinationFilter.java @@ -40,22 +40,40 @@ public class PrefixDestinationFilter extends DestinationFilter { this.destinationType = destinationType; } + public boolean matches(ActiveMQDestination destination) { - if (destination.getDestinationType() != destinationType) return false; + if (destination.getDestinationType() != destinationType) return false; String[] path = DestinationPath.getDestinationPaths(destination.getPhysicalName()); + + int length = prefixes.length; if (path.length >= length) { int size = length - 1; for (int i = 0; i < size; i++) { - if (!path[i].equals(ANY_CHILD) && !prefixes[i].equals(ANY_CHILD) && !prefixes[i].equals(path[i])) { + if (!matches(prefixes[i],path[i])) { return false; } } return true; + }else{ + //want to look for the case where A matches A.> + boolean match = true; + for (int i = 0; (i < path.length && match); i++){ + match &= matches(prefixes[i],path[i]); + } + //paths get compacted - e.g. A.*.> will be compacted to A.> and by definition - the last element on + //the prefix will be > + if (match && prefixes.length == (path.length + 1)){ + return true; + } } return false; } + private boolean matches(String prefix,String path){ + return path.equals(ANY_CHILD) || prefix.equals(ANY_CHILD) || prefix.equals(path); + } + public String getText() { return DestinationPath.toString(prefixes); }