aop拦截器优化,新增忽略全局拦截器的注解参数"ignoreGlobal"
This commit is contained in:
@@ -37,4 +37,5 @@ import java.lang.annotation.*;
|
||||
public @interface Intercept {
|
||||
Class<? extends Interceptor>[] value() default {};
|
||||
Class<? extends Interceptor>[] exclude() default {};
|
||||
boolean ignoreGlobal() default false;
|
||||
}
|
||||
|
||||
@@ -25,6 +25,7 @@ import fun.asgc.neutrino.core.aop.interceptor.Interceptor;
|
||||
import fun.asgc.neutrino.core.aop.interceptor.InterceptorFactory;
|
||||
import fun.asgc.neutrino.core.aop.proxy.ProxyCache;
|
||||
import fun.asgc.neutrino.core.util.CollectionUtil;
|
||||
import fun.asgc.neutrino.core.util.TypeUtil;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
import java.lang.reflect.Method;
|
||||
@@ -61,6 +62,7 @@ public class Invocation {
|
||||
this.interceptors.get(index++).intercept(this);
|
||||
} else {
|
||||
returnValue = callback.get();
|
||||
returnValue = TypeUtil.conversion(returnValue, this.targetMethod.getReturnType());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+3
@@ -105,6 +105,9 @@ public class InterceptorFactory {
|
||||
}
|
||||
}
|
||||
}
|
||||
if (intercept.ignoreGlobal()) {
|
||||
interceptors.removeAll(globalInterceptorList);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -22,13 +22,12 @@
|
||||
package fun.asgc.neutrino.core.db.mapper;
|
||||
|
||||
import fun.asgc.neutrino.core.aop.Intercept;
|
||||
import fun.asgc.neutrino.core.aop.interceptor.InnerGlobalInterceptor;
|
||||
|
||||
/**
|
||||
* @author: aoshiguchen
|
||||
* @date: 2022/6/28
|
||||
*/
|
||||
@Intercept(value = SqlMapperInterceptor.class, exclude = InnerGlobalInterceptor.class)
|
||||
@Intercept(value = SqlMapperInterceptor.class, ignoreGlobal = true)
|
||||
public interface SqlMapper {
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user