调整拦截器的顺序

This commit is contained in:
aoshiguchen
2022-07-01 11:10:54 +08:00
parent 8673a4bc74
commit 377ce540f1
@@ -190,22 +190,6 @@ public class InterceptorFactory {
if (null == interceptors || null == intercept) { if (null == interceptors || null == intercept) {
return; return;
} }
if (ArrayUtil.notEmpty(intercept.value())) {
for (Class<? extends Interceptor> clazz : intercept.value()) {
Interceptor interceptor = get(clazz);
if (null != interceptor && !interceptors.contains(interceptor)) {
interceptors.add(interceptor);
}
}
}
if (ArrayUtil.notEmpty(intercept.exclude())) {
for (Class<? extends Interceptor> clazz : intercept.exclude()) {
Interceptor interceptor = get(clazz);
if (null != interceptor && interceptors.contains(interceptor)) {
interceptors.remove(interceptor);
}
}
}
if (ArrayUtil.notEmpty(intercept.filter()) || ArrayUtil.notEmpty(intercept.resultAdvice()) || ArrayUtil.notEmpty(intercept.exceptionHandler())) { if (ArrayUtil.notEmpty(intercept.filter()) || ArrayUtil.notEmpty(intercept.resultAdvice()) || ArrayUtil.notEmpty(intercept.exceptionHandler())) {
InterceptorWrapper wrapper = new InterceptorWrapper(); InterceptorWrapper wrapper = new InterceptorWrapper();
List<Filter> filterList = getFilterList(intercept.filter()); List<Filter> filterList = getFilterList(intercept.filter());
@@ -222,6 +206,22 @@ public class InterceptorFactory {
} }
interceptors.add(wrapper); interceptors.add(wrapper);
} }
if (ArrayUtil.notEmpty(intercept.value())) {
for (Class<? extends Interceptor> clazz : intercept.value()) {
Interceptor interceptor = get(clazz);
if (null != interceptor && !interceptors.contains(interceptor)) {
interceptors.add(interceptor);
}
}
}
if (ArrayUtil.notEmpty(intercept.exclude())) {
for (Class<? extends Interceptor> clazz : intercept.exclude()) {
Interceptor interceptor = get(clazz);
if (null != interceptor && interceptors.contains(interceptor)) {
interceptors.remove(interceptor);
}
}
}
if (intercept.ignoreGlobal()) { if (intercept.ignoreGlobal()) {
interceptors.removeAll(globalInterceptorList); interceptors.removeAll(globalInterceptorList);
} }