mirror of https://github.com/apache/activemq.git
This commit is contained in:
parent
291ec5ea17
commit
0a67b12c64
|
@ -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);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue