in dubbo-common/src/main/java/org/apache/dubbo/common/extension/support/ActivateComparator.java [53:124]
public int compare(Class o1, Class o2) {
if (o1 == null && o2 == null) {
return 0;
}
if (o1 == null) {
return -1;
}
if (o2 == null) {
return 1;
}
if (o1.equals(o2)) {
return 0;
}
Class<?> inf = findSpi(o1);
ActivateInfo a1 = parseActivate(o1);
ActivateInfo a2 = parseActivate(o2);
if ((a1.applicableToCompare() || a2.applicableToCompare()) && inf != null) {
if (a1.applicableToCompare()) {
String n2 = null;
for (ExtensionDirector director : extensionDirectors) {
ExtensionLoader<?> extensionLoader = director.getExtensionLoader(inf);
n2 = extensionLoader.getExtensionName(o2);
if (n2 != null) {
break;
}
}
if (a1.isLess(n2)) {
return -1;
}
if (a1.isMore(n2)) {
return 1;
}
}
if (a2.applicableToCompare()) {
String n1 = null;
for (ExtensionDirector director : extensionDirectors) {
ExtensionLoader<?> extensionLoader = director.getExtensionLoader(inf);
n1 = extensionLoader.getExtensionName(o1);
if (n1 != null) {
break;
}
}
if (a2.isLess(n1)) {
return 1;
}
if (a2.isMore(n1)) {
return -1;
}
}
return a1.order > a2.order ? 1 : -1;
}
// In order to avoid the problem of inconsistency between the loading order of two filters
// in different loading scenarios without specifying the order attribute of the filter,
// when the order is the same, compare its filterName
if (a1.order > a2.order) {
return 1;
} else if (a1.order == a2.order) {
return o1.getSimpleName().compareTo(o2.getSimpleName()) > 0 ? 1 : -1;
} else {
return -1;
}
}