This commit is contained in:
click33 2023-10-17 11:42:19 +08:00
commit 0f7e1e977c
4 changed files with 19 additions and 9 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;
}
}

View File

@ -74,9 +74,12 @@ public class SaTokenActionHandler extends ActionHandler {
// Controller controller = action.getControllerClass().newInstance();
controller = controllerFactory.getController(action.getControllerClass());
CPI._init_(controller, action, request, response, urlPara[0]);
//加入SaToken上下文处理
if (resolveJson && controller.isJsonRequest()) {
// 注入 JsonRequest 包装对象接管 request
controller.setHttpServletRequest(jsonRequestFactory.apply(controller.getRawData(), controller.getRequest()));
}
//加入SaToken上下文处理
SaControllerContext.hold(controller);
if (devMode) {
if (actionReporter.isReportAfterInvocation(request)) {
new Invocation(action, controller).invoke();