mirror of
https://gitee.com/durcframework/SOP.git
synced 2025-08-11 21:57:56 +08:00
2.5.7
This commit is contained in:
@@ -42,7 +42,7 @@
|
||||
<dependency>
|
||||
<groupId>net.oschina.durcframework</groupId>
|
||||
<artifactId>easyopen-spring-boot-starter</artifactId>
|
||||
<version>1.16.2</version>
|
||||
<version>1.16.5</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
|
@@ -1,58 +0,0 @@
|
||||
package com.gitee.sop.adminserver.common;
|
||||
|
||||
import com.gitee.easyopen.exception.ApiException;
|
||||
import com.gitee.easyopen.session.ApiSessionManager;
|
||||
import com.google.common.cache.LoadingCache;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
import javax.servlet.ServletContext;
|
||||
import javax.servlet.http.HttpSession;
|
||||
|
||||
/**
|
||||
* @author tanghc
|
||||
*/
|
||||
@Slf4j
|
||||
public class MyApiSessionManager extends ApiSessionManager {
|
||||
|
||||
private volatile LoadingCache<String, HttpSession> cache;
|
||||
|
||||
@Override
|
||||
public HttpSession getSession(String sessionId) {
|
||||
if (sessionId == null) {
|
||||
return this.createSession(sessionId);
|
||||
}
|
||||
try {
|
||||
return getCache().get(sessionId);
|
||||
} catch (Exception e) {
|
||||
log.error(e.getMessage(), e);
|
||||
throw new ApiException("create session error");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 创建一个session
|
||||
*
|
||||
* @param sessionId 传null将返回一个新session
|
||||
* @return 返回session
|
||||
*/
|
||||
@Override
|
||||
protected HttpSession createSession(String sessionId) {
|
||||
ServletContext servletContext = getServletContext();
|
||||
HttpSession session = this.newSession(sessionId, servletContext);
|
||||
session.setMaxInactiveInterval(getSessionTimeout());
|
||||
getCache().put(session.getId(), session);
|
||||
return session;
|
||||
}
|
||||
|
||||
public LoadingCache<String, HttpSession> getCache() {
|
||||
if (cache == null) {
|
||||
synchronized (ApiSessionManager.class) {
|
||||
if (cache == null) {
|
||||
cache = buildCache();
|
||||
}
|
||||
}
|
||||
}
|
||||
return cache;
|
||||
}
|
||||
|
||||
}
|
@@ -8,7 +8,6 @@ import com.gitee.easyopen.ApiParamParser;
|
||||
import com.gitee.easyopen.ParamNames;
|
||||
import com.gitee.easyopen.interceptor.ApiInterceptor;
|
||||
import com.gitee.easyopen.session.ApiSessionManager;
|
||||
import com.gitee.sop.adminserver.common.MyApiSessionManager;
|
||||
import com.gitee.sop.adminserver.interceptor.LoginInterceptor;
|
||||
import com.gitee.sop.adminserver.service.RegistryService;
|
||||
import com.gitee.sop.adminserver.service.impl.RegistryServiceEurekaImpl;
|
||||
@@ -49,7 +48,7 @@ public class WebConfig {
|
||||
, SerializerFeature.WriteDateUseDateFormat)
|
||||
);
|
||||
|
||||
ApiSessionManager apiSessionManager = new MyApiSessionManager();
|
||||
ApiSessionManager apiSessionManager = new ApiSessionManager();
|
||||
// session有效期
|
||||
int timeout = NumberUtils.toInt(accessTokenTimeout, 30);
|
||||
apiSessionManager.setSessionTimeout(timeout);
|
||||
|
Reference in New Issue
Block a user