Skip to content

Commit 8cb709f

Browse files
committed
Merge branch 'feature/session2' into develop
2 parents 8c80ca2 + 3216cb5 commit 8cb709f

58 files changed

Lines changed: 2706 additions & 479 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

‎pom.xml‎

Lines changed: 215 additions & 202 deletions
Large diffs are not rendered by default.
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
/*
2+
* Licensed to the Apache Software Foundation (ASF) under one or more
3+
* contributor license agreements. See the NOTICE file distributed with
4+
* this work for additional information regarding copyright ownership.
5+
* The ASF licenses this file to You under the Apache License, Version 2.0
6+
* (the "License"); you may not use this file except in compliance with
7+
* the License. You may obtain a copy of the License at
8+
*
9+
* http://www.apache.org/licenses/LICENSE-2.0
10+
*
11+
* Unless required by applicable law or agreed to in writing, software
12+
* distributed under the License is distributed on an "AS IS" BASIS,
13+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
* See the License for the specific language governing permissions and
15+
* limitations under the License.
16+
*/
17+
18+
package me.chanjar.weixin.common.session;
19+
20+
/**
21+
* Manifest constants for the <code>org.apache.catalina.session</code>
22+
* package.
23+
*
24+
* @author Craig R. McClanahan
25+
*/
26+
27+
public class Constants {
28+
29+
public static final String Package = "me.chanjar.weixin.common.session";
30+
31+
}
Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
package me.chanjar.weixin.common.session;
2+
3+
public interface InternalSession {
4+
5+
/**
6+
* Return the <code>HttpSession</code> for which this object
7+
* is the facade.
8+
*/
9+
WxSession getSession();
10+
11+
/**
12+
* Set the <code>isValid</code> flag for this session.
13+
*
14+
* @param isValid The new value for the <code>isValid</code> flag
15+
*/
16+
public void setValid(boolean isValid);
17+
18+
/**
19+
* Return the <code>isValid</code> flag for this session.
20+
*/
21+
boolean isValid();
22+
23+
/**
24+
* Return the session identifier for this session.
25+
*/
26+
String getIdInternal();
27+
28+
/**
29+
* Perform the internal processing required to invalidate this session,
30+
* without triggering an exception if the session has already expired.
31+
*/
32+
void expire();
33+
34+
/**
35+
* Update the accessed time information for this session. This method
36+
* should be called by the context when a request comes in for a particular
37+
* session, even if the application does not reference it.
38+
*/
39+
void access();
40+
41+
/**
42+
* End the access.
43+
*/
44+
void endAccess();
45+
46+
/**
47+
* Set the creation time for this session. This method is called by the
48+
* Manager when an existing Session instance is reused.
49+
*
50+
* @param time The new creation time
51+
*/
52+
void setCreationTime(long time);
53+
54+
/**
55+
* Set the default maximum inactive interval (in seconds)
56+
* for Sessions created by this Manager.
57+
*
58+
* @param interval The new default value
59+
*/
60+
void setMaxInactiveInterval(int interval);
61+
62+
/**
63+
* Set the session identifier for this session.
64+
*
65+
* @param id The new session identifier
66+
*/
67+
void setId(String id);
68+
}
Lines changed: 113 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,113 @@
1+
package me.chanjar.weixin.common.session;
2+
3+
public interface InternalSessionManager {
4+
5+
/**
6+
* Return the active Session, associated with this Manager, with the
7+
* specified session id (if any); otherwise return <code>null</code>.
8+
*
9+
* @param id The session id for the session to be returned
10+
*
11+
* @exception IllegalStateException if a new session cannot be
12+
* instantiated for any reason
13+
* @exception java.io.IOException if an input/output error occurs while
14+
* processing this request
15+
*/
16+
InternalSession findSession(String id);
17+
18+
/**
19+
* Construct and return a new session object, based on the default
20+
* settings specified by this Manager's properties. The session
21+
* id specified will be used as the session id.
22+
* If a new session cannot be created for any reason, return
23+
* <code>null</code>.
24+
*
25+
* @param sessionId The session id which should be used to create the
26+
* new session; if <code>null</code>, a new session id will be
27+
* generated
28+
* @exception IllegalStateException if a new session cannot be
29+
* instantiated for any reason
30+
*/
31+
public InternalSession createSession(String sessionId);
32+
33+
/**
34+
* Remove this Session from the active Sessions for this Manager.
35+
*
36+
* @param session Session to be removed
37+
*/
38+
public void remove(InternalSession session);
39+
40+
/**
41+
* Remove this Session from the active Sessions for this Manager.
42+
*
43+
* @param session Session to be removed
44+
* @param update Should the expiration statistics be updated
45+
*/
46+
public void remove(InternalSession session, boolean update);
47+
48+
/**
49+
* Add this Session to the set of active Sessions for this Manager.
50+
*
51+
* @param session Session to be added
52+
*/
53+
void add(InternalSession session);
54+
55+
56+
/**
57+
* Returns the number of active sessions
58+
*
59+
* @return number of sessions active
60+
*/
61+
int getActiveSessions();
62+
/**
63+
* Get a session from the recycled ones or create a new empty one.
64+
* The PersistentManager manager does not need to create session data
65+
* because it reads it from the Store.
66+
*/
67+
InternalSession createEmptySession();
68+
69+
InternalSession[] findSessions();
70+
71+
/**
72+
* Implements the Manager interface, direct call to processExpires
73+
*/
74+
public void backgroundProcess();
75+
76+
/**
77+
* Set the default maximum inactive interval (in seconds)
78+
* for Sessions created by this Manager.
79+
*
80+
* @param interval The new default value
81+
*/
82+
void setMaxInactiveInterval(int interval);
83+
84+
/**
85+
* <pre>
86+
* Set the manager checks frequency.
87+
* 设置每尝试多少次清理过期session,才真的会执行一次清理动作
88+
* 要和{@link #setBackgroundProcessorDelay(int)}联合起来看
89+
* 如果把这个数字设置为6(默认),那么就是说manager要等待 6 * backgroundProcessorDay的时间才会清理过期session
90+
* </pre>
91+
* @param processExpiresFrequency the new manager checks frequency
92+
*/
93+
void setProcessExpiresFrequency(int processExpiresFrequency);
94+
95+
/**
96+
* <pre>
97+
* Set the manager background processor delay
98+
* 设置manager sleep几秒,尝试执行一次background操作(清理过期session)
99+
* </pre>
100+
* @param backgroundProcessorDelay
101+
*/
102+
void setBackgroundProcessorDelay(int backgroundProcessorDelay);
103+
104+
105+
/**
106+
* Set the maximum number of active Sessions allowed, or -1 for
107+
* no limit.
108+
* 设置最大活跃session数,默认无限
109+
* @param max The new maximum number of sessions
110+
*/
111+
void setMaxActiveSessions(int max);
112+
113+
}
Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
# Licensed to the Apache Software Foundation (ASF) under one or more
2+
# contributor license agreements. See the NOTICE file distributed with
3+
# this work for additional information regarding copyright ownership.
4+
# The ASF licenses this file to You under the Apache License, Version 2.0
5+
# (the "License"); you may not use this file except in compliance with
6+
# the License. You may obtain a copy of the License at
7+
#
8+
# http://www.apache.org/licenses/LICENSE-2.0
9+
#
10+
# Unless required by applicable law or agreed to in writing, software
11+
# distributed under the License is distributed on an "AS IS" BASIS,
12+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
# See the License for the specific language governing permissions and
14+
# limitations under the License.
15+
16+
applicationSession.session.ise=invalid session state
17+
applicationSession.value.iae=null value
18+
fileStore.saving=Saving Session {0} to file {1}
19+
fileStore.loading=Loading Session {0} from file {1}
20+
fileStore.removing=Removing Session {0} at file {1}
21+
fileStore.deleteFailed=Unable to delete file [{0}] which is preventing the creation of the session storage location
22+
fileStore.createFailed=Unable to create directory [{0}] for the storage of session data
23+
JDBCStore.close=Exception closing database connection {0}
24+
JDBCStore.saving=Saving Session {0} to database {1}
25+
JDBCStore.loading=Loading Session {0} from database {1}
26+
JDBCStore.removing=Removing Session {0} at database {1}
27+
JDBCStore.SQLException=SQL Error {0}
28+
serverSession.value.iae=null value
29+
sessionManagerImpl.createRandom=Created random number generator for session ID generation in {0}ms.
30+
sessionManagerImpl.createSession.tmase=createSession: Too many active sessions
31+
sessionManagerImpl.sessionTimeout=Invalid session timeout setting {0}
32+
sessionManagerImpl.getSession.ise=getSession: Session id cannot be null
33+
sessionManagerImpl.expireException=processsExpire: Exception during session expiration
34+
sessionManagerImpl.loading=Loading persisted sessions from {0}
35+
sessionManagerImpl.loading.cnfe=ClassNotFoundException while loading persisted sessions: {0}
36+
sessionManagerImpl.loading.ioe=IOException while loading persisted sessions: {0}
37+
sessionManagerImpl.unloading=Saving persisted sessions to {0}
38+
sessionManagerImpl.unloading.debug=Unloading persisted sessions
39+
sessionManagerImpl.unloading.ioe=IOException while saving persisted sessions: {0}
40+
sessionManagerImpl.unloading.nosessions=No persisted sessions to unload
41+
sessionManagerImpl.managerLoad=Exception loading sessions from persistent storage
42+
sessionManagerImpl.managerUnload=Exception unloading sessions to persistent storage
43+
sessionManagerImpl.createSession.ise=createSession: Session id cannot be null
44+
sessionImpl.attributeEvent=Session attribute event listener threw exception
45+
sessionImpl.bindingEvent=Session binding event listener threw exception
46+
sessionImpl.invalidate.ise=invalidate: Session already invalidated
47+
sessionImpl.isNew.ise=isNew: Session already invalidated
48+
sessionImpl.getAttribute.ise=getAttribute: Session already invalidated
49+
sessionImpl.getAttributeNames.ise=getAttributeNames: Session already invalidated
50+
sessionImpl.getCreationTime.ise=getCreationTime: Session already invalidated
51+
sessionImpl.getThisAccessedTime.ise=getThisAccessedTime: Session already invalidated
52+
sessionImpl.getLastAccessedTime.ise=getLastAccessedTime: Session already invalidated
53+
sessionImpl.getId.ise=getId: Session already invalidated
54+
sessionImpl.getMaxInactiveInterval.ise=getMaxInactiveInterval: Session already invalidated
55+
sessionImpl.getValueNames.ise=getValueNames: Session already invalidated
56+
sessionImpl.logoutfail=Exception logging out user when expiring session
57+
sessionImpl.notSerializable=Cannot serialize session attribute {0} for session {1}
58+
sessionImpl.removeAttribute.ise=removeAttribute: Session already invalidated
59+
sessionImpl.sessionEvent=Session event listener threw exception
60+
sessionImpl.setAttribute.iae=setAttribute: Non-serializable attribute {0}
61+
sessionImpl.setAttribute.ise=setAttribute: Session [{0}] has already been invalidated
62+
sessionImpl.setAttribute.namenull=setAttribute: name parameter cannot be null
63+
sessionImpl.sessionCreated=Created Session id = {0}
64+
persistentManager.loading=Loading {0} persisted sessions
65+
persistentManager.unloading=Saving {0} persisted sessions
66+
persistentManager.expiring=Expiring {0} sessions before saving them
67+
persistentManager.deserializeError=Error deserializing Session {0}: {1}
68+
persistentManager.serializeError=Error serializing Session {0}: {1}
69+
persistentManager.swapMaxIdle=Swapping session {0} to Store, idle for {1} seconds
70+
persistentManager.backupMaxIdle=Backing up session {0} to Store, idle for {1} seconds
71+
persistentManager.backupException=Exception occurred when backing up Session {0}: {1}
72+
persistentManager.tooManyActive=Too many active sessions, {0}, looking for idle sessions to swap out
73+
persistentManager.swapTooManyActive=Swapping out session {0}, idle for {1} seconds too many sessions active
74+
persistentManager.processSwaps=Checking for sessions to swap out, {0} active sessions in memory
75+
persistentManager.activeSession=Session {0} has been idle for {1} seconds
76+
persistentManager.swapIn=Swapping session {0} in from Store
77+
persistentManager.swapInException=Exception in the Store during swapIn: {0}
78+
persistentManager.swapInInvalid=Swapped session {0} is invalid
79+
persistentManager.storeKeysException=Unable to determine the list of session IDs for sessions in the session store, assuming that the store is empty
80+
persistentManager.storeSizeException=Unable to determine the number of sessions in the session store, assuming that the store is empty

0 commit comments

Comments
 (0)