mirror of
https://gitee.com/binary/weixin-java-tools.git
synced 2025-10-20 18:47:38 +08:00
🎨 优化部分代码
This commit is contained in:
@@ -1,21 +1,19 @@
|
||||
package me.chanjar.weixin.common.session;
|
||||
|
||||
import me.chanjar.weixin.common.util.res.StringManager;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.concurrent.atomic.AtomicBoolean;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import me.chanjar.weixin.common.util.res.StringManager;
|
||||
|
||||
/**
|
||||
* 基于内存的session manager.
|
||||
*
|
||||
* @author Daniel Qian
|
||||
*/
|
||||
public class StandardSessionManager implements WxSessionManager, InternalSessionManager {
|
||||
|
||||
protected static final StringManager SM = StringManager.getManager(Constants.PACKAGE);
|
||||
/**
|
||||
* The descriptive name of this Manager implementation (for logging).
|
||||
@@ -51,7 +49,9 @@ public class StandardSessionManager implements WxSessionManager, InternalSession
|
||||
*/
|
||||
protected int maxInactiveInterval = 30 * 60;
|
||||
|
||||
// Number of sessions created by this manager
|
||||
/**
|
||||
* Number of sessions created by this manager
|
||||
*/
|
||||
protected long sessionCounter = 0;
|
||||
|
||||
protected volatile int maxActive = 0;
|
||||
@@ -154,12 +154,10 @@ public class StandardSessionManager implements WxSessionManager, InternalSession
|
||||
session.setValid(true);
|
||||
session.setCreationTime(System.currentTimeMillis());
|
||||
session.setMaxInactiveInterval(this.maxInactiveInterval);
|
||||
String id = sessionId;
|
||||
session.setId(id);
|
||||
session.setId(sessionId);
|
||||
this.sessionCounter++;
|
||||
|
||||
return (session);
|
||||
|
||||
return session;
|
||||
}
|
||||
|
||||
|
||||
@@ -181,10 +179,8 @@ public class StandardSessionManager implements WxSessionManager, InternalSession
|
||||
return new StandardSession(this);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void add(InternalSession session) {
|
||||
|
||||
// 当第一次有session创建的时候,开启session清理线程
|
||||
if (!this.backgroundProcessStarted.getAndSet(true)) {
|
||||
Thread t = new Thread(new Runnable() {
|
||||
|
Reference in New Issue
Block a user