public class EzySimpleSessionManager<S extends EzySession> extends com.tvd12.ezyfox.pattern.EzyObjectProvider<S> implements EzySessionManager<S>
| Modifier and Type | Class and Description |
|---|---|
static class |
EzySimpleSessionManager.Builder<S extends EzySession> |
| Modifier and Type | Field and Description |
|---|---|
protected static AtomicInteger |
COUNTER |
protected ConcurrentHashMap<Long,S> |
loggedInSession |
protected int |
maxSessions |
protected ConcurrentHashMap<Object,S> |
sessionsByConnection |
protected ConcurrentHashMap<Long,S> |
sessionsById |
protected EzySessionTokenGenerator |
tokenGenerator |
| Modifier | Constructor and Description |
|---|---|
protected |
EzySimpleSessionManager(EzySimpleSessionManager.Builder<S> builder) |
| Modifier and Type | Method and Description |
|---|---|
void |
addLoggedInSession(S session)
Recognize that the session has logged in
|
protected void |
checkAndRemoveSessions() |
protected void |
checkMaxSessions(com.tvd12.ezyfox.constant.EzyConstant connectionType) |
protected void |
checkToRemoveSession(S session,
com.tvd12.ezyfox.constant.EzyConstant reason) |
void |
clearSession(S session)
clear session
|
boolean |
containsSession(long id)
Check contains session mapped to id or not
|
void |
destroy() |
int |
getAliveSessionCount() |
List<S> |
getAliveSessions()
Get all alive sessions
|
int |
getAllSessionCount() |
List<S> |
getAllSessions()
Get all sessions
|
int |
getLoggedInSessionCount() |
List<S> |
getLoggedInSessions()
Get logged in sessions
|
EzySession |
getSession(long id)
Get session by id
|
S |
getSession(Object connection)
Get session by connection
|
protected long |
getSessionRemainWaitingTime(EzySession session) |
protected boolean |
isIdleSession(S session) |
protected boolean |
isUnloggedInSession(EzySession session) |
protected String |
newSessionToken() |
S |
provideSession(EzyChannel channel)
Provide session from pool and map the session to channel
|
protected S |
provideSession(com.tvd12.ezyfox.constant.EzyConstant connectionType) |
void |
removeSession(S session,
com.tvd12.ezyfox.constant.EzyConstant reason)
Add session to disconnect queue
|
protected void |
removeStaleObjects() |
protected boolean |
shouldRemoveSession(S session) |
void |
start() |
protected void |
unmapSession(S session) |
clearAll, createObject, getProvidedObjects, newProvidedObjects, newValidationTask, provideObject, shutdownAll, startValidationServiceclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitremoveSessionprotected final int maxSessions
protected final EzySessionTokenGenerator tokenGenerator
protected final ConcurrentHashMap<Long,S extends EzySession> loggedInSession
protected final ConcurrentHashMap<Long,S extends EzySession> sessionsById
protected final ConcurrentHashMap<Object,S extends EzySession> sessionsByConnection
protected static final AtomicInteger COUNTER
protected EzySimpleSessionManager(EzySimpleSessionManager.Builder<S> builder)
public void addLoggedInSession(S session)
EzySessionManageraddLoggedInSession in interface EzySessionManager<S extends EzySession>session - the sessionpublic boolean containsSession(long id)
EzySessionManagercontainsSession in interface EzySessionManager<S extends EzySession>id - the session idpublic void removeSession(S session, com.tvd12.ezyfox.constant.EzyConstant reason)
EzySessionManagerremoveSession in interface EzySessionManager<S extends EzySession>session - the sessionreason - the reasonpublic void clearSession(S session)
EzySessionManagerclearSession in interface EzySessionManager<S extends EzySession>session - the sessionprotected void checkToRemoveSession(S session, com.tvd12.ezyfox.constant.EzyConstant reason)
protected boolean shouldRemoveSession(S session)
protected void unmapSession(S session)
public S provideSession(EzyChannel channel)
EzySessionManagerprovideSession in interface EzySessionManager<S extends EzySession>channel - the channelprotected S provideSession(com.tvd12.ezyfox.constant.EzyConstant connectionType)
protected void checkMaxSessions(com.tvd12.ezyfox.constant.EzyConstant connectionType)
public EzySession getSession(long id)
EzySessionManagergetSession in interface EzySessionManager<S extends EzySession>id - the idpublic S getSession(Object connection)
EzySessionManagergetSession in interface EzySessionManager<S extends EzySession>connection - the connectionpublic List<S> getAllSessions()
EzySessionManagergetAllSessions in interface EzySessionManager<S extends EzySession>public List<S> getAliveSessions()
EzySessionManagergetAliveSessions in interface EzySessionManager<S extends EzySession>public List<S> getLoggedInSessions()
EzySessionManagergetLoggedInSessions in interface EzySessionManager<S extends EzySession>public int getAllSessionCount()
getAllSessionCount in interface EzySessionManager<S extends EzySession>public int getAliveSessionCount()
getAliveSessionCount in interface EzySessionManager<S extends EzySession>public int getLoggedInSessionCount()
getLoggedInSessionCount in interface EzySessionManager<S extends EzySession>public void start()
throws Exception
start in interface com.tvd12.ezyfox.util.EzyStartablestart in class com.tvd12.ezyfox.pattern.EzyObjectProvider<S extends EzySession>Exceptionprotected void removeStaleObjects()
removeStaleObjects in class com.tvd12.ezyfox.pattern.EzyObjectProvider<S extends EzySession>protected void checkAndRemoveSessions()
protected boolean isIdleSession(S session)
protected boolean isUnloggedInSession(EzySession session)
protected long getSessionRemainWaitingTime(EzySession session)
protected String newSessionToken()
public void destroy()
destroy in interface com.tvd12.ezyfox.util.EzyDestroyabledestroy in class com.tvd12.ezyfox.pattern.EzyObjectProvider<S extends EzySession>Copyright © 2021 Young Monkeys. All rights reserved.