mirror of
https://gitee.com/dromara/sa-token.git
synced 2025-04-05 17:37:53 +08:00
refactor: 重构 sa-token-alone-redis 插件
This commit is contained in:
parent
935a8db3ae
commit
5dbaab1966
@ -25,11 +25,11 @@
|
||||
<module>sa-token-fastjson</module>
|
||||
<module>sa-token-fastjson2</module>
|
||||
<module>sa-token-hutool-timed-cache</module>
|
||||
<module>sa-token-alone-redis</module>
|
||||
|
||||
<module>sa-token-redisson-jackson</module>
|
||||
<module>sa-token-redisson-jackson2</module>
|
||||
<module>sa-token-redisx</module>
|
||||
<module>sa-token-alone-redis</module>
|
||||
<module>sa-token-dialect-thymeleaf</module>
|
||||
<module>sa-token-freemarker</module>
|
||||
<module>sa-token-sso</module>
|
||||
|
@ -24,20 +24,10 @@
|
||||
<optional>true</optional>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>cn.dev33</groupId>
|
||||
<artifactId>sa-token-jackson</artifactId>
|
||||
<groupId>cn.dev33</groupId>
|
||||
<artifactId>sa-token-redis-template-jdk-serializer</artifactId>
|
||||
<optional>true</optional>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>cn.dev33</groupId>
|
||||
<artifactId>sa-token-fastjson</artifactId>
|
||||
<optional>true</optional>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>cn.dev33</groupId>
|
||||
<artifactId>sa-token-fastjson2</artifactId>
|
||||
<optional>true</optional>
|
||||
</dependency>
|
||||
</dependency>
|
||||
<!-- redis pool -->
|
||||
<dependency>
|
||||
<groupId>org.apache.commons</groupId>
|
||||
|
@ -17,9 +17,8 @@ package cn.dev33.satoken.dao.alone;
|
||||
|
||||
import cn.dev33.satoken.dao.SaTokenDao;
|
||||
import cn.dev33.satoken.dao.SaTokenDaoDefaultImpl;
|
||||
import cn.dev33.satoken.dao.SaTokenDaoRedisFastjson;
|
||||
import cn.dev33.satoken.dao.SaTokenDaoRedisFastjson2;
|
||||
import cn.dev33.satoken.dao.SaTokenDaoForRedisTemplate;
|
||||
import cn.dev33.satoken.dao.SaTokenDaoForRedisTemplateUseJdkSerializer;
|
||||
import cn.dev33.satoken.exception.SaTokenException;
|
||||
import org.apache.commons.pool2.impl.GenericObjectPoolConfig;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
@ -44,10 +43,8 @@ import java.util.stream.Collectors;
|
||||
* <p>
|
||||
* 使用方式:在引入 sa-token redis 集成相关包的前提下,继续引入当前依赖 <br> <br>
|
||||
* 注意事项:目前本依赖仅对以下插件有 Redis 分离效果: <br>
|
||||
* sa-token-redis <br>
|
||||
* sa-token-redis-jackson <br>
|
||||
* sa-token-redis-fastjson <br>
|
||||
* sa-token-redis-fastjson2 <br>
|
||||
* sa-token-redis-template <br>
|
||||
* sa-token-redis-template-jdk-serializer <br>
|
||||
* </p>
|
||||
*
|
||||
*
|
||||
@ -212,7 +209,16 @@ public class SaAloneRedisInject implements EnvironmentAware{
|
||||
|
||||
// 3. 开始初始化 SaTokenDao ,此处需要依次判断开发者引入的是哪个 redis 库
|
||||
|
||||
// 如果开发者引入的是:sa-token-redis
|
||||
// 如果开发者引入的是:sa-token-redis-template-jdk-serializer
|
||||
try {
|
||||
Class.forName("cn.dev33.satoken.dao.SaTokenDaoForRedisTemplateUseJdkSerializer");
|
||||
SaTokenDaoForRedisTemplateUseJdkSerializer dao = (SaTokenDaoForRedisTemplateUseJdkSerializer)saTokenDao;
|
||||
dao.isInit = false;
|
||||
dao.init(factory);
|
||||
return;
|
||||
} catch (ClassNotFoundException ignored) {
|
||||
}
|
||||
// 如果开发者引入的是:sa-token-redis-template
|
||||
try {
|
||||
Class.forName("cn.dev33.satoken.dao.SaTokenDaoForRedisTemplate");
|
||||
SaTokenDaoForRedisTemplate dao = (SaTokenDaoForRedisTemplate)saTokenDao;
|
||||
@ -221,33 +227,6 @@ public class SaAloneRedisInject implements EnvironmentAware{
|
||||
return;
|
||||
} catch (ClassNotFoundException ignored) {
|
||||
}
|
||||
// TODO: 如果开发者引入的是:sa-token-redis-jdk-serializer
|
||||
// try {
|
||||
// Class.forName("cn.dev33.satoken.dao.SaTokenDaoForRedisTemplate");
|
||||
// SaTokenDaoRedisJackson dao = (SaTokenDaoRedisJackson)saTokenDao;
|
||||
// dao.isInit = false;
|
||||
// dao.init(factory);
|
||||
// return;
|
||||
// } catch (ClassNotFoundException ignored) {
|
||||
// }
|
||||
// 如果开发者引入的是:sa-token-redis-fastjson
|
||||
try {
|
||||
Class.forName("cn.dev33.satoken.dao.SaTokenDaoRedisFastjson");
|
||||
SaTokenDaoRedisFastjson dao = (SaTokenDaoRedisFastjson)saTokenDao;
|
||||
dao.isInit = false;
|
||||
dao.init(factory);
|
||||
return;
|
||||
} catch (ClassNotFoundException ignored) {
|
||||
}
|
||||
// 如果开发者引入的是:sa-token-redis-fastjson2
|
||||
try {
|
||||
Class.forName("cn.dev33.satoken.dao.SaTokenDaoRedisFastjson2");
|
||||
SaTokenDaoRedisFastjson2 dao = (SaTokenDaoRedisFastjson2)saTokenDao;
|
||||
dao.isInit = false;
|
||||
dao.init(factory);
|
||||
return;
|
||||
} catch (ClassNotFoundException ignored) {
|
||||
}
|
||||
|
||||
// 至此,说明开发者一个 redis 插件也没引入,或者引入的 redis 插件不在 sa-token-alone-redis 的支持范围内
|
||||
|
||||
|
@ -28,7 +28,7 @@ import java.util.concurrent.TimeUnit;
|
||||
|
||||
/**
|
||||
* Sa-Token 持久层实现 [ RedisTemplate 存储 ] (可用环境: SpringBoot2、SpringBoot3)
|
||||
* <br> copy by: sa-token-redis-template 插件
|
||||
* <br> copy by: sa-token-redis-template 插件
|
||||
*
|
||||
* @author click33
|
||||
* @since 1.34.0
|
||||
|
Loading…
Reference in New Issue
Block a user