aop拦截器优化,新增忽略全局拦截器的注解参数"ignoreGlobal"

This commit is contained in:
aoshiguchen
2022-06-29 18:09:58 +08:00
parent fec58c39ef
commit 4221e23ee0
4 changed files with 7 additions and 2 deletions
@@ -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());
}
}
@@ -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 {
}