me.chanjar.weixin.common.session

## 类 StandardSessionManager

- java.lang.Object
- - me.chanjar.weixin.common.session.StandardSessionManager

所有已实现的接口:
  InternalSessionManager, WxSessionManager

    public class StandardSessionManager
    extends Object
    implements WxSessionManager, InternalSessionManager

基于内存的session manager

### 字段概要

字段
`protected int` `backgroundProcessorDelay` background processor delay in seconds
`protected org.slf4j.Logger` `log`
`protected int` `maxActive`
`protected int` `maxActiveSessions` The maximum number of active Sessions allowed, or -1 for no limit.
`protected int` `maxInactiveInterval` The default maximum inactive interval for Sessions created by this Manager.
`protected int` `processExpiresFrequency` Frequency of the session expiration, and related manager operations.
`protected long` `processingTime` Processing time during session expiration.
`protected int` `rejectedSessions` Number of session creations that failed due to maxActiveSessions.
`protected long` `sessionCounter`
`protected Map<String,InternalSession>` `sessions` The set of currently active Sessions for this Manager, keyed by session identifier.
`protected static StringManager` `sm`

### 构造器概要

构造器
构造器和说明
`StandardSessionManager()`

### 方法概要

方法
`void` `add(InternalSession session)` Add this Session to the set of active Sessions for this Manager.
`void` `backgroundProcess()` Implements the Manager interface, direct call to processExpires
`InternalSession` `createEmptySession()` Get a session from the recycled ones or create a new empty one.
`InternalSession` `createSession(String sessionId)` Construct and return a new session object, based on the default settings specified by this Manager's properties.
`InternalSession` `findSession(String id)` Return the active Session, associated with this Manager, with the specified session id (if any); otherwise return `null`.
`InternalSession[]` `findSessions()` Return the set of active Sessions associated with this Manager.
`int` `getActiveSessions()` Returns the number of active sessions
`String` `getName()` Return the descriptive short name of this Manager implementation.
`protected InternalSession` `getNewSession()` Get new session class to be used in the doLoad() method.
`WxSession` `getSession(String sessionId)` 获取某个sessionId对应的session,如果sessionId没有对应的session，则新建一个并返回。
`WxSession` `getSession(String sessionId, boolean create)` 获取某个sessionId对应的session,如果sessionId没有对应的session，若create为true则新建一个，否则返回null。
`void` `processExpires()` Invalidate all sessions that have expired.
`void` `remove(InternalSession session)` Remove this Session from the active Sessions for this Manager.
`void` `remove(InternalSession session, boolean update)` Remove this Session from the active Sessions for this Manager.
`void` `setBackgroundProcessorDelay(int backgroundProcessorDelay)` Set the manager background processor delay 设置manager sleep几秒，尝试执行一次background操作（清理过期session）
`void` `setMaxActiveSessions(int max)` Set the maximum number of active Sessions allowed, or -1 for no limit.
`void` `setMaxInactiveInterval(int interval)` Set the default maximum inactive interval (in seconds) for Sessions created by this Manager.
`void` `setProcessExpiresFrequency(int processExpiresFrequency)` Set the manager checks frequency.

### 从类继承的方法 java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

### 字段详细资料

#### sm

    protected static final StringManager sm

#### log

    protected final org.slf4j.Logger log

#### sessions

    protected Map<String,InternalSession> sessions

The set of currently active Sessions for this Manager, keyed by session identifier.

#### maxActiveSessions

    protected int maxActiveSessions

The maximum number of active Sessions allowed, or -1 for no limit.

#### rejectedSessions

    protected int rejectedSessions

Number of session creations that failed due to maxActiveSessions.

#### maxInactiveInterval

    protected int maxInactiveInterval

The default maximum inactive interval for Sessions created by this Manager.

#### sessionCounter

    protected long sessionCounter

#### maxActive

    protected volatile int maxActive

#### processingTime

    protected long processingTime

Processing time during session expiration.

#### processExpiresFrequency

    protected int processExpiresFrequency

Frequency of the session expiration, and related manager operations. Manager operations will be done once for the specified amount of backgrondProcess calls (ie, the lower the amount, the most often the checks will occur).

#### backgroundProcessorDelay

    protected int backgroundProcessorDelay

background processor delay in seconds

### 构造器详细资料

#### StandardSessionManager

    public StandardSessionManager()

### 方法详细资料

#### getSession

    public WxSession getSession(String sessionId)

从接口复制的说明: `WxSessionManager`
获取某个sessionId对应的session,如果sessionId没有对应的session，则新建一个并返回。

指定者:
  `getSession` 在接口中 `WxSessionManager`

#### getSession

    public WxSession getSession(String sessionId,
                       boolean create)

从接口复制的说明: `WxSessionManager`
获取某个sessionId对应的session,如果sessionId没有对应的session，若create为true则新建一个，否则返回null。

指定者:
  `getSession` 在接口中 `WxSessionManager`

#### remove

    public void remove(InternalSession session)

从接口复制的说明: `InternalSessionManager`
Remove this Session from the active Sessions for this Manager.

指定者:
  `remove` 在接口中 `InternalSessionManager`
参数:
  `session` - Session to be removed

#### remove

    public void remove(InternalSession session,
              boolean update)

从接口复制的说明: `InternalSessionManager`
Remove this Session from the active Sessions for this Manager.

指定者:
  `remove` 在接口中 `InternalSessionManager`
参数:
  `session` - Session to be removed
  `update` - Should the expiration statistics be updated

#### findSession

    public InternalSession findSession(String id)

从接口复制的说明: `InternalSessionManager`
Return the active Session, associated with this Manager, with the specified session id (if any); otherwise return `null`.

指定者:
  `findSession` 在接口中 `InternalSessionManager`
参数:
  `id` - The session id for the session to be returned

#### createSession

    public InternalSession createSession(String sessionId)

从接口复制的说明: `InternalSessionManager`
Construct and return a new session object, based on the default settings specified by this Manager's properties. The session id specified will be used as the session id. If a new session cannot be created for any reason, return `null`.

指定者:
  `createSession` 在接口中 `InternalSessionManager`
参数:
  `sessionId` - The session id which should be used to create the new session; if `null`, a new session id will be generated

#### getActiveSessions

    public int getActiveSessions()

从接口复制的说明: `InternalSessionManager`
Returns the number of active sessions

指定者:
  `getActiveSessions` 在接口中 `InternalSessionManager`
返回:
  number of sessions active

#### createEmptySession

    public InternalSession createEmptySession()

从接口复制的说明: `InternalSessionManager`
Get a session from the recycled ones or create a new empty one. The PersistentManager manager does not need to create session data because it reads it from the Store.

指定者:
  `createEmptySession` 在接口中 `InternalSessionManager`

#### getNewSession

    protected InternalSession getNewSession()

Get new session class to be used in the doLoad() method.

#### add

    public void add(InternalSession session)

从接口复制的说明: `InternalSessionManager`
Add this Session to the set of active Sessions for this Manager.

指定者:
  `add` 在接口中 `InternalSessionManager`
参数:
  `session` - Session to be added

#### findSessions

    public InternalSession[] findSessions()

Return the set of active Sessions associated with this Manager. If this Manager has no active Sessions, a zero-length array is returned.

指定者:
  `findSessions` 在接口中 `InternalSessionManager`

#### backgroundProcess

    public void backgroundProcess()

从接口复制的说明: `InternalSessionManager`
Implements the Manager interface, direct call to processExpires

指定者:
  `backgroundProcess` 在接口中 `InternalSessionManager`

#### processExpires

    public void processExpires()

Invalidate all sessions that have expired.

#### setMaxInactiveInterval

    public void setMaxInactiveInterval(int interval)

从接口复制的说明: `InternalSessionManager`
Set the default maximum inactive interval (in seconds) for Sessions created by this Manager.

指定者:
  `setMaxInactiveInterval` 在接口中 `InternalSessionManager`
参数:
  `interval` - The new default value

#### setProcessExpiresFrequency

    public void setProcessExpiresFrequency(int processExpiresFrequency)

Set the manager checks frequency.

指定者:
  `setProcessExpiresFrequency` 在接口中 `InternalSessionManager`
参数:
  `processExpiresFrequency` - the new manager checks frequency

#### setBackgroundProcessorDelay

    public void setBackgroundProcessorDelay(int backgroundProcessorDelay)

从接口复制的说明: `InternalSessionManager`

     Set the manager background processor delay
     设置manager sleep几秒，尝试执行一次background操作（清理过期session）

指定者:
  `setBackgroundProcessorDelay` 在接口中 `InternalSessionManager`

#### getName

    public String getName()

Return the descriptive short name of this Manager implementation.

#### setMaxActiveSessions

    public void setMaxActiveSessions(int max)

Set the maximum number of active Sessions allowed, or -1 for no limit.

指定者:
  `setMaxActiveSessions` 在接口中 `InternalSessionManager`
参数:
  `max` - The new maximum number of sessions