SaTokenDao 新增默认方法 onChange,当 SaManager.saTokenDao 变更时,调用该方法

This commit is contained in:
moon69 2023-10-14 12:36:00 +08:00
parent f2416a6175
commit 8db78e0a5d
3 changed files with 14 additions and 7 deletions

View File

@ -102,8 +102,8 @@ public class SaManager {
SaTokenEventCenter.doRegisterComponent("SaTokenDao", saTokenDao);
}
private static void setSaTokenDaoMethod(SaTokenDao saTokenDao) {
if((SaManager.saTokenDao instanceof SaTokenDaoDefaultImpl)) {
((SaTokenDaoDefaultImpl)SaManager.saTokenDao).endRefreshThread();
if (SaManager.saTokenDao != null) {
SaManager.saTokenDao.onChange();
}
SaManager.saTokenDao = saTokenDao;
}

View File

@ -201,4 +201,11 @@ public interface SaTokenDao {
List<String> searchData(String prefix, String keyword, int start, int size, boolean sortType);
// --------------------- 实例相关 ---------------------
/**
* SaManager.saTokenDao 变更时调用该方法
*/
default void onChange() {
}
}

View File

@ -264,8 +264,8 @@ public class SaTokenDaoDefaultImpl implements SaTokenDao {
/**
* 结束定时任务不再定时清理过期数据
*/
public void endRefreshThread() {
@Override
public void onChange() {
this.refreshFlag = false;
}
}