This commit is contained in:
rajdavies 2013-11-14 09:48:34 +00:00
parent 291ec5ea17
commit 0a67b12c64
1 changed files with 20 additions and 2 deletions

View File

@ -40,22 +40,40 @@ public class PrefixDestinationFilter extends DestinationFilter {
this.destinationType = destinationType;
}
public boolean matches(ActiveMQDestination destination) {
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);
}