注解处理器父接口重命名 SaAnnotationAbstractHandler -> SaAnnotationHandlerInterface

This commit is contained in:
click33
2024-08-20 13:00:22 +08:00
parent c4b6a6381e
commit 0ca8a1ab2d
23 changed files with 42 additions and 42 deletions

View File

@@ -24,7 +24,7 @@ import java.lang.reflect.Method;
* @author click33 * @author click33
* @since 2024/8/2 * @since 2024/8/2
*/ */
public interface SaAnnotationAbstractHandler<T extends Annotation> { public interface SaAnnotationHandlerInterface<T extends Annotation> {
/** /**
* 获取所要处理的注解类型 * 获取所要处理的注解类型

View File

@@ -27,7 +27,7 @@ import java.lang.reflect.Method;
* @author click33 * @author click33
* @since 2024/8/2 * @since 2024/8/2
*/ */
public class SaCheckDisableHandler implements SaAnnotationAbstractHandler<SaCheckDisable> { public class SaCheckDisableHandler implements SaAnnotationHandlerInterface<SaCheckDisable> {
@Override @Override
public Class<SaCheckDisable> getHandlerAnnotationClass() { public Class<SaCheckDisable> getHandlerAnnotationClass() {

View File

@@ -26,7 +26,7 @@ import java.lang.reflect.Method;
* @author click33 * @author click33
* @since 2024/8/2 * @since 2024/8/2
*/ */
public class SaCheckHttpBasicHandler implements SaAnnotationAbstractHandler<SaCheckHttpBasic> { public class SaCheckHttpBasicHandler implements SaAnnotationHandlerInterface<SaCheckHttpBasic> {
@Override @Override
public Class<SaCheckHttpBasic> getHandlerAnnotationClass() { public Class<SaCheckHttpBasic> getHandlerAnnotationClass() {

View File

@@ -28,7 +28,7 @@ import java.lang.reflect.Method;
* @author click33 * @author click33
* @since 2024/8/2 * @since 2024/8/2
*/ */
public class SaCheckHttpDigestHandler implements SaAnnotationAbstractHandler<SaCheckHttpDigest> { public class SaCheckHttpDigestHandler implements SaAnnotationHandlerInterface<SaCheckHttpDigest> {
@Override @Override
public Class<SaCheckHttpDigest> getHandlerAnnotationClass() { public Class<SaCheckHttpDigest> getHandlerAnnotationClass() {

View File

@@ -27,7 +27,7 @@ import java.lang.reflect.Method;
* @author click33 * @author click33
* @since 2024/8/2 * @since 2024/8/2
*/ */
public class SaCheckLoginHandler implements SaAnnotationAbstractHandler<SaCheckLogin> { public class SaCheckLoginHandler implements SaAnnotationHandlerInterface<SaCheckLogin> {
@Override @Override
public Class<SaCheckLogin> getHandlerAnnotationClass() { public Class<SaCheckLogin> getHandlerAnnotationClass() {

View File

@@ -31,7 +31,7 @@ import java.util.List;
* @author click33 * @author click33
* @since 2024/8/2 * @since 2024/8/2
*/ */
public class SaCheckOrHandler implements SaAnnotationAbstractHandler<SaCheckOr> { public class SaCheckOrHandler implements SaAnnotationHandlerInterface<SaCheckOr> {
@Override @Override
public Class<SaCheckOr> getHandlerAnnotationClass() { public Class<SaCheckOr> getHandlerAnnotationClass() {

View File

@@ -30,7 +30,7 @@ import java.lang.reflect.Method;
* @author click33 * @author click33
* @since 2024/8/2 * @since 2024/8/2
*/ */
public class SaCheckPermissionHandler implements SaAnnotationAbstractHandler<SaCheckPermission> { public class SaCheckPermissionHandler implements SaAnnotationHandlerInterface<SaCheckPermission> {
@Override @Override
public Class<SaCheckPermission> getHandlerAnnotationClass() { public Class<SaCheckPermission> getHandlerAnnotationClass() {

View File

@@ -28,7 +28,7 @@ import java.lang.reflect.Method;
* @author click33 * @author click33
* @since 2024/8/2 * @since 2024/8/2
*/ */
public class SaCheckRoleHandler implements SaAnnotationAbstractHandler<SaCheckRole> { public class SaCheckRoleHandler implements SaAnnotationHandlerInterface<SaCheckRole> {
@Override @Override
public Class<SaCheckRole> getHandlerAnnotationClass() { public Class<SaCheckRole> getHandlerAnnotationClass() {

View File

@@ -27,7 +27,7 @@ import java.lang.reflect.Method;
* @author click33 * @author click33
* @since 2024/8/2 * @since 2024/8/2
*/ */
public class SaCheckSafeHandler implements SaAnnotationAbstractHandler<SaCheckSafe> { public class SaCheckSafeHandler implements SaAnnotationHandlerInterface<SaCheckSafe> {
@Override @Override
public Class<SaCheckSafe> getHandlerAnnotationClass() { public Class<SaCheckSafe> getHandlerAnnotationClass() {

View File

@@ -26,7 +26,7 @@ import java.lang.reflect.Method;
* @author click33 * @author click33
* @since 2024/8/2 * @since 2024/8/2
*/ */
public class SaIgnoreHandler implements SaAnnotationAbstractHandler<SaIgnore> { public class SaIgnoreHandler implements SaAnnotationHandlerInterface<SaIgnore> {
@Override @Override
public Class<SaIgnore> getHandlerAnnotationClass() { public Class<SaIgnore> getHandlerAnnotationClass() {

View File

@@ -18,7 +18,7 @@ package cn.dev33.satoken.listener;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; 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.config.SaTokenConfig;
import cn.dev33.satoken.error.SaErrorCode; import cn.dev33.satoken.error.SaErrorCode;
import cn.dev33.satoken.exception.SaTokenException; import cn.dev33.satoken.exception.SaTokenException;
@@ -292,7 +292,7 @@ public class SaTokenEventCenter {
* 事件发布:有新的注解处理器载入到框架中 * 事件发布:有新的注解处理器载入到框架中
* @param handler 注解处理器 * @param handler 注解处理器
*/ */
public static void doRegisterAnnotationHandler(SaAnnotationAbstractHandler<?> handler) { public static void doRegisterAnnotationHandler(SaAnnotationHandlerInterface<?> handler) {
for (SaTokenListener listener : listenerList) { for (SaTokenListener listener : listenerList) {
listener.doRegisterAnnotationHandler(handler); listener.doRegisterAnnotationHandler(handler);
} }

View File

@@ -15,7 +15,7 @@
*/ */
package cn.dev33.satoken.listener; 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.config.SaTokenConfig;
import cn.dev33.satoken.stp.SaLoginModel; import cn.dev33.satoken.stp.SaLoginModel;
import cn.dev33.satoken.stp.StpLogic; import cn.dev33.satoken.stp.StpLogic;
@@ -130,7 +130,7 @@ public interface SaTokenListener {
* 注册了自定义注解处理器 * 注册了自定义注解处理器
* @param handler 注解处理器 * @param handler 注解处理器
*/ */
default void doRegisterAnnotationHandler(SaAnnotationAbstractHandler<?> handler) {} default void doRegisterAnnotationHandler(SaAnnotationHandlerInterface<?> handler) {}
/** /**
* StpLogic 对象替换 * StpLogic 对象替换

View File

@@ -15,7 +15,7 @@
*/ */
package cn.dev33.satoken.listener; 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.config.SaTokenConfig;
import cn.dev33.satoken.stp.SaLoginModel; import cn.dev33.satoken.stp.SaLoginModel;
import cn.dev33.satoken.stp.StpLogic; import cn.dev33.satoken.stp.StpLogic;
@@ -136,7 +136,7 @@ public class SaTokenListenerForLog implements SaTokenListener {
* @param handler 注解处理器 * @param handler 注解处理器
*/ */
@Override @Override
public void doRegisterAnnotationHandler(SaAnnotationAbstractHandler<?> handler) { public void doRegisterAnnotationHandler(SaAnnotationHandlerInterface<?> handler) {
if(handler != null) { if(handler != null) {
log.info("注解扩展 @{} (处理器: {})", handler.getHandlerAnnotationClass().getSimpleName(), handler.getClass().getCanonicalName()); log.info("注解扩展 @{} (处理器: {})", handler.getHandlerAnnotationClass().getSimpleName(), handler.getClass().getCanonicalName());
} }

View File

@@ -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); annotationHandlerMap.put(handler.getHandlerAnnotationClass(), handler);
SaTokenEventCenter.doRegisterAnnotationHandler(handler); SaTokenEventCenter.doRegisterAnnotationHandler(handler);
} }
@@ -77,8 +77,8 @@ public final class SaAnnotationStrategy {
/** /**
* 注册一个注解处理器,到首位 * 注册一个注解处理器,到首位
*/ */
public void registerAnnotationHandlerToFirst(SaAnnotationAbstractHandler<?> handler) { public void registerAnnotationHandlerToFirst(SaAnnotationHandlerInterface<?> handler) {
Map<Class<?>, SaAnnotationAbstractHandler<?>> newMap = new LinkedHashMap<>(); Map<Class<?>, SaAnnotationHandlerInterface<?>> newMap = new LinkedHashMap<>();
newMap.put(handler.getHandlerAnnotationClass(), handler); newMap.put(handler.getHandlerAnnotationClass(), handler);
newMap.putAll(annotationHandlerMap); newMap.putAll(annotationHandlerMap);
this.annotationHandlerMap = newMap; this.annotationHandlerMap = newMap;
@@ -98,7 +98,7 @@ public final class SaAnnotationStrategy {
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
public SaCheckMethodAnnotationFunction checkMethodAnnotation = (method) -> { public SaCheckMethodAnnotationFunction checkMethodAnnotation = (method) -> {
// 遍历所有的注解处理器,检查此 method 是否具有这些指定的注解 // 遍历所有的注解处理器,检查此 method 是否具有这些指定的注解
for (Map.Entry<Class<?>, SaAnnotationAbstractHandler<?>> entry: annotationHandlerMap.entrySet()) { for (Map.Entry<Class<?>, SaAnnotationHandlerInterface<?>> entry: annotationHandlerMap.entrySet()) {
// 先校验 Method 所属 Class 上的注解 // 先校验 Method 所属 Class 上的注解
Annotation classTakeAnnotation = instance.getAnnotation.apply(method.getDeclaringClass(), (Class<Annotation>)entry.getKey()); Annotation classTakeAnnotation = instance.getAnnotation.apply(method.getDeclaringClass(), (Class<Annotation>)entry.getKey());

View File

@@ -1,6 +1,6 @@
package com.pj.satoken.custom_annotation.handler; package com.pj.satoken.custom_annotation.handler;
import cn.dev33.satoken.annotation.handler.SaAnnotationAbstractHandler; import cn.dev33.satoken.annotation.handler.SaAnnotationHandlerInterface;
import cn.dev33.satoken.context.SaHolder; import cn.dev33.satoken.context.SaHolder;
import cn.dev33.satoken.exception.SaTokenException; import cn.dev33.satoken.exception.SaTokenException;
import com.pj.satoken.custom_annotation.CheckAccount; import com.pj.satoken.custom_annotation.CheckAccount;
@@ -15,7 +15,7 @@ import java.lang.reflect.Method;
* *
*/ */
@Component @Component
public class CheckAccountHandler implements SaAnnotationAbstractHandler<CheckAccount> { public class CheckAccountHandler implements SaAnnotationHandlerInterface<CheckAccount> {
// 指定这个处理器要处理哪个注解 // 指定这个处理器要处理哪个注解
@Override @Override

View File

@@ -1,6 +1,6 @@
package com.pj.satoken.custom_annotation.handler; package com.pj.satoken.custom_annotation.handler;
import cn.dev33.satoken.annotation.handler.SaAnnotationAbstractHandler; import cn.dev33.satoken.annotation.handler.SaAnnotationHandlerInterface;
import cn.dev33.satoken.annotation.handler.SaCheckLoginHandler; import cn.dev33.satoken.annotation.handler.SaCheckLoginHandler;
import com.pj.satoken.StpUserUtil; import com.pj.satoken.StpUserUtil;
import com.pj.satoken.custom_annotation.SaUserCheckLogin; import com.pj.satoken.custom_annotation.SaUserCheckLogin;
@@ -14,7 +14,7 @@ import java.lang.reflect.Method;
* @author click33 * @author click33
*/ */
@Component @Component
public class SaUserCheckLoginHandler implements SaAnnotationAbstractHandler<SaUserCheckLogin> { public class SaUserCheckLoginHandler implements SaAnnotationHandlerInterface<SaUserCheckLogin> {
@Override @Override
public Class<SaUserCheckLogin> getHandlerAnnotationClass() { public Class<SaUserCheckLogin> getHandlerAnnotationClass() {

View File

@@ -1,6 +1,6 @@
package com.pj.satoken.custom_annotation.handler; package com.pj.satoken.custom_annotation.handler;
import cn.dev33.satoken.annotation.handler.SaAnnotationAbstractHandler; import cn.dev33.satoken.annotation.handler.SaAnnotationHandlerInterface;
import cn.dev33.satoken.annotation.handler.SaCheckPermissionHandler; import cn.dev33.satoken.annotation.handler.SaCheckPermissionHandler;
import com.pj.satoken.StpUserUtil; import com.pj.satoken.StpUserUtil;
import com.pj.satoken.custom_annotation.SaUserCheckPermission; import com.pj.satoken.custom_annotation.SaUserCheckPermission;
@@ -14,7 +14,7 @@ import java.lang.reflect.Method;
* @author click33 * @author click33
*/ */
@Component @Component
public class SaUserCheckPermissionHandler implements SaAnnotationAbstractHandler<SaUserCheckPermission> { public class SaUserCheckPermissionHandler implements SaAnnotationHandlerInterface<SaUserCheckPermission> {
@Override @Override
public Class<SaUserCheckPermission> getHandlerAnnotationClass() { public Class<SaUserCheckPermission> getHandlerAnnotationClass() {

View File

@@ -1,6 +1,6 @@
package com.pj.satoken.custom_annotation.handler; package com.pj.satoken.custom_annotation.handler;
import cn.dev33.satoken.annotation.handler.SaAnnotationAbstractHandler; import cn.dev33.satoken.annotation.handler.SaAnnotationHandlerInterface;
import cn.dev33.satoken.annotation.handler.SaCheckRoleHandler; import cn.dev33.satoken.annotation.handler.SaCheckRoleHandler;
import com.pj.satoken.StpUserUtil; import com.pj.satoken.StpUserUtil;
import com.pj.satoken.custom_annotation.SaUserCheckRole; import com.pj.satoken.custom_annotation.SaUserCheckRole;
@@ -14,7 +14,7 @@ import java.lang.reflect.Method;
* @author click33 * @author click33
*/ */
@Component @Component
public class SaUserCheckRoleHandler implements SaAnnotationAbstractHandler<SaUserCheckRole> { public class SaUserCheckRoleHandler implements SaAnnotationHandlerInterface<SaUserCheckRole> {
@Override @Override
public Class<SaUserCheckRole> getHandlerAnnotationClass() { public Class<SaUserCheckRole> getHandlerAnnotationClass() {

View File

@@ -1,6 +1,6 @@
package com.pj.satoken.custom_annotation.handler; package com.pj.satoken.custom_annotation.handler;
import cn.dev33.satoken.annotation.handler.SaAnnotationAbstractHandler; import cn.dev33.satoken.annotation.handler.SaAnnotationHandlerInterface;
import cn.dev33.satoken.annotation.handler.SaCheckSafeHandler; import cn.dev33.satoken.annotation.handler.SaCheckSafeHandler;
import com.pj.satoken.StpUserUtil; import com.pj.satoken.StpUserUtil;
import com.pj.satoken.custom_annotation.SaUserCheckSafe; import com.pj.satoken.custom_annotation.SaUserCheckSafe;
@@ -14,7 +14,7 @@ import java.lang.reflect.Method;
* @author click33 * @author click33
*/ */
@Component @Component
public class SaUserCheckSafeHandler implements SaAnnotationAbstractHandler<SaUserCheckSafe> { public class SaUserCheckSafeHandler implements SaAnnotationHandlerInterface<SaUserCheckSafe> {
@Override @Override
public Class<SaUserCheckSafe> getHandlerAnnotationClass() { public Class<SaUserCheckSafe> getHandlerAnnotationClass() {

View File

@@ -1,6 +1,6 @@
package com.pj.satoken.custom_annotation.handler; package com.pj.satoken.custom_annotation.handler;
import cn.dev33.satoken.annotation.handler.SaAnnotationAbstractHandler; import cn.dev33.satoken.annotation.handler.SaAnnotationHandlerInterface;
import cn.dev33.satoken.context.SaHolder; import cn.dev33.satoken.context.SaHolder;
import cn.dev33.satoken.exception.SaTokenException; import cn.dev33.satoken.exception.SaTokenException;
import com.pj.satoken.custom_annotation.CheckAccount; import com.pj.satoken.custom_annotation.CheckAccount;
@@ -15,7 +15,7 @@ import java.lang.reflect.Method;
* *
*/ */
@Component @Component
public class CheckAccountHandler implements SaAnnotationAbstractHandler<CheckAccount> { public class CheckAccountHandler implements SaAnnotationHandlerInterface<CheckAccount> {
// 指定这个处理器要处理哪个注解 // 指定这个处理器要处理哪个注解
@Override @Override

View File

@@ -1,6 +1,6 @@
package cn.dev33.satoken.aop; package cn.dev33.satoken.aop;
import cn.dev33.satoken.annotation.handler.SaAnnotationAbstractHandler; import cn.dev33.satoken.annotation.handler.SaAnnotationHandlerInterface;
import cn.dev33.satoken.strategy.SaAnnotationStrategy; import cn.dev33.satoken.strategy.SaAnnotationStrategy;
import org.springframework.aop.aspectj.AspectJExpressionPointcut; import org.springframework.aop.aspectj.AspectJExpressionPointcut;
import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Bean;
@@ -30,7 +30,7 @@ public class SaAopPointcutAdvisorBeanRegister {
public static SaAroundAnnotationPointcutAdvisor saAroundAnnoAdvisor; public static SaAroundAnnotationPointcutAdvisor saAroundAnnoAdvisor;
@Bean @Bean
public SaAroundAnnotationPointcutAdvisor saAroundAnnotationHandlePointcutAdvisor (List<SaAnnotationAbstractHandler<?>> handlerList) { public SaAroundAnnotationPointcutAdvisor saAroundAnnotationHandlePointcutAdvisor (List<SaAnnotationHandlerInterface<?>> handlerList) {
SaAroundAnnotationPointcutAdvisor advisor = new SaAroundAnnotationPointcutAdvisor(); SaAroundAnnotationPointcutAdvisor advisor = new SaAroundAnnotationPointcutAdvisor();
// 定义切入规则 // 定义切入规则
@@ -52,14 +52,14 @@ public class SaAopPointcutAdvisorBeanRegister {
* @param appendHandlerList 追加的 SaAnnotationAbstractHandler 处理器 * @param appendHandlerList 追加的 SaAnnotationAbstractHandler 处理器
* @return / * @return /
*/ */
public static String calcExpression(List<SaAnnotationAbstractHandler<?>> appendHandlerList) { public static String calcExpression(List<SaAnnotationHandlerInterface<?>> appendHandlerList) {
// 框架内置的 // 框架内置的
List<Class<?>> list = new ArrayList<>(SaAnnotationStrategy.instance.annotationHandlerMap.keySet()); List<Class<?>> list = new ArrayList<>(SaAnnotationStrategy.instance.annotationHandlerMap.keySet());
// 额外追加的 // 额外追加的
if(appendHandlerList != null) { if(appendHandlerList != null) {
for (SaAnnotationAbstractHandler<?> handler : appendHandlerList) { for (SaAnnotationHandlerInterface<?> handler : appendHandlerList) {
Class<?> cls = handler.getHandlerAnnotationClass(); Class<?> cls = handler.getHandlerAnnotationClass();
if(!list.contains(cls)) { if(!list.contains(cls)) {
list.add(handler.getHandlerAnnotationClass()); list.add(handler.getHandlerAnnotationClass());

View File

@@ -16,7 +16,7 @@
package cn.dev33.satoken.solon; package cn.dev33.satoken.solon;
import cn.dev33.satoken.SaManager; import cn.dev33.satoken.SaManager;
import cn.dev33.satoken.annotation.handler.SaAnnotationAbstractHandler; import cn.dev33.satoken.annotation.handler.SaAnnotationHandlerInterface;
import cn.dev33.satoken.config.SaTokenConfig; import cn.dev33.satoken.config.SaTokenConfig;
import cn.dev33.satoken.context.second.SaTokenSecondContextCreator; import cn.dev33.satoken.context.second.SaTokenSecondContextCreator;
import cn.dev33.satoken.dao.SaTokenDao; import cn.dev33.satoken.dao.SaTokenDao;
@@ -98,7 +98,7 @@ public class XPluginImp implements Plugin {
}); });
// 注入自定义注解处理器 Bean (可以有多个) // 注入自定义注解处理器 Bean (可以有多个)
context.subBeansOfType(SaAnnotationAbstractHandler.class, sl -> { context.subBeansOfType(SaAnnotationHandlerInterface.class, sl -> {
SaAnnotationStrategy.instance.registerAnnotationHandler(sl); SaAnnotationStrategy.instance.registerAnnotationHandler(sl);
}); });

View File

@@ -16,7 +16,7 @@
package cn.dev33.satoken.spring; package cn.dev33.satoken.spring;
import cn.dev33.satoken.SaManager; import cn.dev33.satoken.SaManager;
import cn.dev33.satoken.annotation.handler.SaAnnotationAbstractHandler; import cn.dev33.satoken.annotation.handler.SaAnnotationHandlerInterface;
import cn.dev33.satoken.config.SaTokenConfig; import cn.dev33.satoken.config.SaTokenConfig;
import cn.dev33.satoken.context.SaTokenContext; import cn.dev33.satoken.context.SaTokenContext;
import cn.dev33.satoken.context.second.SaTokenSecondContextCreator; import cn.dev33.satoken.context.second.SaTokenSecondContextCreator;
@@ -126,8 +126,8 @@ public class SaBeanInject {
* @param handlerList 自定义注解处理器集合 * @param handlerList 自定义注解处理器集合
*/ */
@Autowired(required = false) @Autowired(required = false)
public void setSaAnnotationHandler(List<SaAnnotationAbstractHandler<?>> handlerList) { public void setSaAnnotationHandler(List<SaAnnotationHandlerInterface<?>> handlerList) {
for (SaAnnotationAbstractHandler<?> handler : handlerList) { for (SaAnnotationHandlerInterface<?> handler : handlerList) {
SaAnnotationStrategy.instance.registerAnnotationHandler(handler); SaAnnotationStrategy.instance.registerAnnotationHandler(handler);
} }
} }