mirror of
https://gitee.com/dromara/sa-token.git
synced 2025-09-19 10:08:07 +08:00
注解处理器父接口重命名 SaAnnotationAbstractHandler -> SaAnnotationHandlerInterface
This commit is contained in:
@@ -24,7 +24,7 @@ import java.lang.reflect.Method;
|
||||
* @author click33
|
||||
* @since 2024/8/2
|
||||
*/
|
||||
public interface SaAnnotationAbstractHandler<T extends Annotation> {
|
||||
public interface SaAnnotationHandlerInterface<T extends Annotation> {
|
||||
|
||||
/**
|
||||
* 获取所要处理的注解类型
|
@@ -27,7 +27,7 @@ import java.lang.reflect.Method;
|
||||
* @author click33
|
||||
* @since 2024/8/2
|
||||
*/
|
||||
public class SaCheckDisableHandler implements SaAnnotationAbstractHandler<SaCheckDisable> {
|
||||
public class SaCheckDisableHandler implements SaAnnotationHandlerInterface<SaCheckDisable> {
|
||||
|
||||
@Override
|
||||
public Class<SaCheckDisable> getHandlerAnnotationClass() {
|
||||
|
@@ -26,7 +26,7 @@ import java.lang.reflect.Method;
|
||||
* @author click33
|
||||
* @since 2024/8/2
|
||||
*/
|
||||
public class SaCheckHttpBasicHandler implements SaAnnotationAbstractHandler<SaCheckHttpBasic> {
|
||||
public class SaCheckHttpBasicHandler implements SaAnnotationHandlerInterface<SaCheckHttpBasic> {
|
||||
|
||||
@Override
|
||||
public Class<SaCheckHttpBasic> getHandlerAnnotationClass() {
|
||||
|
@@ -28,7 +28,7 @@ import java.lang.reflect.Method;
|
||||
* @author click33
|
||||
* @since 2024/8/2
|
||||
*/
|
||||
public class SaCheckHttpDigestHandler implements SaAnnotationAbstractHandler<SaCheckHttpDigest> {
|
||||
public class SaCheckHttpDigestHandler implements SaAnnotationHandlerInterface<SaCheckHttpDigest> {
|
||||
|
||||
@Override
|
||||
public Class<SaCheckHttpDigest> getHandlerAnnotationClass() {
|
||||
|
@@ -27,7 +27,7 @@ import java.lang.reflect.Method;
|
||||
* @author click33
|
||||
* @since 2024/8/2
|
||||
*/
|
||||
public class SaCheckLoginHandler implements SaAnnotationAbstractHandler<SaCheckLogin> {
|
||||
public class SaCheckLoginHandler implements SaAnnotationHandlerInterface<SaCheckLogin> {
|
||||
|
||||
@Override
|
||||
public Class<SaCheckLogin> getHandlerAnnotationClass() {
|
||||
|
@@ -31,7 +31,7 @@ import java.util.List;
|
||||
* @author click33
|
||||
* @since 2024/8/2
|
||||
*/
|
||||
public class SaCheckOrHandler implements SaAnnotationAbstractHandler<SaCheckOr> {
|
||||
public class SaCheckOrHandler implements SaAnnotationHandlerInterface<SaCheckOr> {
|
||||
|
||||
@Override
|
||||
public Class<SaCheckOr> getHandlerAnnotationClass() {
|
||||
|
@@ -30,7 +30,7 @@ import java.lang.reflect.Method;
|
||||
* @author click33
|
||||
* @since 2024/8/2
|
||||
*/
|
||||
public class SaCheckPermissionHandler implements SaAnnotationAbstractHandler<SaCheckPermission> {
|
||||
public class SaCheckPermissionHandler implements SaAnnotationHandlerInterface<SaCheckPermission> {
|
||||
|
||||
@Override
|
||||
public Class<SaCheckPermission> getHandlerAnnotationClass() {
|
||||
|
@@ -28,7 +28,7 @@ import java.lang.reflect.Method;
|
||||
* @author click33
|
||||
* @since 2024/8/2
|
||||
*/
|
||||
public class SaCheckRoleHandler implements SaAnnotationAbstractHandler<SaCheckRole> {
|
||||
public class SaCheckRoleHandler implements SaAnnotationHandlerInterface<SaCheckRole> {
|
||||
|
||||
@Override
|
||||
public Class<SaCheckRole> getHandlerAnnotationClass() {
|
||||
|
@@ -27,7 +27,7 @@ import java.lang.reflect.Method;
|
||||
* @author click33
|
||||
* @since 2024/8/2
|
||||
*/
|
||||
public class SaCheckSafeHandler implements SaAnnotationAbstractHandler<SaCheckSafe> {
|
||||
public class SaCheckSafeHandler implements SaAnnotationHandlerInterface<SaCheckSafe> {
|
||||
|
||||
@Override
|
||||
public Class<SaCheckSafe> getHandlerAnnotationClass() {
|
||||
|
@@ -26,7 +26,7 @@ import java.lang.reflect.Method;
|
||||
* @author click33
|
||||
* @since 2024/8/2
|
||||
*/
|
||||
public class SaIgnoreHandler implements SaAnnotationAbstractHandler<SaIgnore> {
|
||||
public class SaIgnoreHandler implements SaAnnotationHandlerInterface<SaIgnore> {
|
||||
|
||||
@Override
|
||||
public Class<SaIgnore> getHandlerAnnotationClass() {
|
||||
|
@@ -18,7 +18,7 @@ package cn.dev33.satoken.listener;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import cn.dev33.satoken.annotation.handler.SaAnnotationAbstractHandler;
|
||||
import cn.dev33.satoken.annotation.handler.SaAnnotationHandlerInterface;
|
||||
import cn.dev33.satoken.config.SaTokenConfig;
|
||||
import cn.dev33.satoken.error.SaErrorCode;
|
||||
import cn.dev33.satoken.exception.SaTokenException;
|
||||
@@ -292,7 +292,7 @@ public class SaTokenEventCenter {
|
||||
* 事件发布:有新的注解处理器载入到框架中
|
||||
* @param handler 注解处理器
|
||||
*/
|
||||
public static void doRegisterAnnotationHandler(SaAnnotationAbstractHandler<?> handler) {
|
||||
public static void doRegisterAnnotationHandler(SaAnnotationHandlerInterface<?> handler) {
|
||||
for (SaTokenListener listener : listenerList) {
|
||||
listener.doRegisterAnnotationHandler(handler);
|
||||
}
|
||||
|
@@ -15,7 +15,7 @@
|
||||
*/
|
||||
package cn.dev33.satoken.listener;
|
||||
|
||||
import cn.dev33.satoken.annotation.handler.SaAnnotationAbstractHandler;
|
||||
import cn.dev33.satoken.annotation.handler.SaAnnotationHandlerInterface;
|
||||
import cn.dev33.satoken.config.SaTokenConfig;
|
||||
import cn.dev33.satoken.stp.SaLoginModel;
|
||||
import cn.dev33.satoken.stp.StpLogic;
|
||||
@@ -130,7 +130,7 @@ public interface SaTokenListener {
|
||||
* 注册了自定义注解处理器
|
||||
* @param handler 注解处理器
|
||||
*/
|
||||
default void doRegisterAnnotationHandler(SaAnnotationAbstractHandler<?> handler) {}
|
||||
default void doRegisterAnnotationHandler(SaAnnotationHandlerInterface<?> handler) {}
|
||||
|
||||
/**
|
||||
* StpLogic 对象替换
|
||||
|
@@ -15,7 +15,7 @@
|
||||
*/
|
||||
package cn.dev33.satoken.listener;
|
||||
|
||||
import cn.dev33.satoken.annotation.handler.SaAnnotationAbstractHandler;
|
||||
import cn.dev33.satoken.annotation.handler.SaAnnotationHandlerInterface;
|
||||
import cn.dev33.satoken.config.SaTokenConfig;
|
||||
import cn.dev33.satoken.stp.SaLoginModel;
|
||||
import cn.dev33.satoken.stp.StpLogic;
|
||||
@@ -136,7 +136,7 @@ public class SaTokenListenerForLog implements SaTokenListener {
|
||||
* @param handler 注解处理器
|
||||
*/
|
||||
@Override
|
||||
public void doRegisterAnnotationHandler(SaAnnotationAbstractHandler<?> handler) {
|
||||
public void doRegisterAnnotationHandler(SaAnnotationHandlerInterface<?> handler) {
|
||||
if(handler != null) {
|
||||
log.info("注解扩展 @{} (处理器: {})", handler.getHandlerAnnotationClass().getSimpleName(), handler.getClass().getCanonicalName());
|
||||
}
|
||||
|
@@ -49,7 +49,7 @@ public final class SaAnnotationStrategy {
|
||||
/**
|
||||
* 注解处理器集合
|
||||
*/
|
||||
public Map<Class<?>, SaAnnotationAbstractHandler<?>> annotationHandlerMap = new LinkedHashMap<>();
|
||||
public Map<Class<?>, SaAnnotationHandlerInterface<?>> annotationHandlerMap = new LinkedHashMap<>();
|
||||
|
||||
/**
|
||||
* 注册所有默认的注解处理器
|
||||
@@ -69,7 +69,7 @@ public final class SaAnnotationStrategy {
|
||||
/**
|
||||
* 注册一个注解处理器
|
||||
*/
|
||||
public void registerAnnotationHandler(SaAnnotationAbstractHandler<?> handler) {
|
||||
public void registerAnnotationHandler(SaAnnotationHandlerInterface<?> handler) {
|
||||
annotationHandlerMap.put(handler.getHandlerAnnotationClass(), handler);
|
||||
SaTokenEventCenter.doRegisterAnnotationHandler(handler);
|
||||
}
|
||||
@@ -77,8 +77,8 @@ public final class SaAnnotationStrategy {
|
||||
/**
|
||||
* 注册一个注解处理器,到首位
|
||||
*/
|
||||
public void registerAnnotationHandlerToFirst(SaAnnotationAbstractHandler<?> handler) {
|
||||
Map<Class<?>, SaAnnotationAbstractHandler<?>> newMap = new LinkedHashMap<>();
|
||||
public void registerAnnotationHandlerToFirst(SaAnnotationHandlerInterface<?> handler) {
|
||||
Map<Class<?>, SaAnnotationHandlerInterface<?>> newMap = new LinkedHashMap<>();
|
||||
newMap.put(handler.getHandlerAnnotationClass(), handler);
|
||||
newMap.putAll(annotationHandlerMap);
|
||||
this.annotationHandlerMap = newMap;
|
||||
@@ -98,7 +98,7 @@ public final class SaAnnotationStrategy {
|
||||
@SuppressWarnings("unchecked")
|
||||
public SaCheckMethodAnnotationFunction checkMethodAnnotation = (method) -> {
|
||||
// 遍历所有的注解处理器,检查此 method 是否具有这些指定的注解
|
||||
for (Map.Entry<Class<?>, SaAnnotationAbstractHandler<?>> entry: annotationHandlerMap.entrySet()) {
|
||||
for (Map.Entry<Class<?>, SaAnnotationHandlerInterface<?>> entry: annotationHandlerMap.entrySet()) {
|
||||
|
||||
// 先校验 Method 所属 Class 上的注解
|
||||
Annotation classTakeAnnotation = instance.getAnnotation.apply(method.getDeclaringClass(), (Class<Annotation>)entry.getKey());
|
||||
|
Reference in New Issue
Block a user