public class RedisSessionRepository extends Object implements SessionRepository
SessionRepository.CommitTransaction| Constructor and Description |
|---|
RedisSessionRepository(RedisFacade redis,
String namespace,
String owner,
ExpirationStrategy strategy,
boolean sticky) |
| Modifier and Type | Method and Description |
|---|---|
boolean |
cleanSessionsOnShutdown()
If repository supports cleaning of sessions on application shutdown, it
should return
true from this method. |
void |
close()
Called to shutdown the repository and release resources.
|
Set<String> |
getAllKeys(SessionData session)
Retrieves all attribute keys associated with session.
|
Collection<String> |
getOwnedSessionIds()
Returns session ids stored in repository and owned by current application
node.
|
Object |
getSessionAttribute(SessionData session,
String attribute)
Returns value of the attribute or
null if attribute or session
have not been found |
SessionData |
getSessionData(String id)
This method retrieves session data from repository.
|
boolean |
prepareRemove(SessionData session)
Prepares session repository for removal of session.
|
void |
remove(SessionData session)
Removes session from the repository.
|
void |
removeSessionAttribute(SessionData session,
String name)
The attribute for the session will be removed from the repository.
|
void |
requestFinished()
Called to clean up resources after the request has been completed and the
session will no longer be used in the current thread.
|
void |
sessionIdChange(SessionData sessionData)
Changes session id.
|
byte[] |
sessionKey(String sessionId)
Returns session key used to index session in redis.
|
void |
setSessionAttribute(SessionData session,
String name,
Object value)
Sets the value of the attribute for the session in the repository.
|
void |
setSessionManager(SessionManager sessionManager)
This method starts a separate thread that listens to key expirations
events.
|
SessionRepository.CommitTransaction |
startCommit(SessionData session)
Starts transaction on remote session.
|
void |
storeSessionData(SessionData sessionData)
The method stores session metadata in redis and marks session as accessed
(resets session expire instant).
|
public RedisSessionRepository(RedisFacade redis, String namespace, String owner, ExpirationStrategy strategy, boolean sticky)
public void setSessionManager(SessionManager sessionManager)
setSessionManager in interface SessionRepositorysessionManager - public SessionData getSessionData(String id)
#:getSessionData in interface SessionRepositoryid - session idnull
if data wasn't found in repository.public SessionRepository.CommitTransaction startCommit(SessionData session)
SessionRepositorySessionRepository.CommitTransaction for more information.startCommit in interface SessionRepositorysession - the session informationpublic void remove(SessionData session)
SessionRepositoryremove in interface SessionRepositorysession - the session informationpublic byte[] sessionKey(String sessionId)
sessionId - public Object getSessionAttribute(SessionData session, String attribute)
SessionRepositorynull if attribute or session
have not been foundgetSessionAttribute in interface SessionRepositorysession - the session informationattribute - the key of the attribute to retrievenull if attribute or session
have not been foundpublic boolean prepareRemove(SessionData session)
SessionRepositorytrue if caller can proceed with session
removal.prepareRemove in interface SessionRepositorysession - the session informationtrue if caller can proceed with session removalpublic Set<String> getAllKeys(SessionData session)
getAllKeys in interface SessionRepositorysession - public void storeSessionData(SessionData sessionData)
storeSessionData in interface SessionRepositorysessionData - the session informationpublic void requestFinished()
SessionRepositoryrequestFinished in interface SessionRepositorypublic void setSessionAttribute(SessionData session, String name, Object value)
SessionRepositorysetSessionAttribute in interface SessionRepositorysession - the session informationname - attribute namevalue - attribute value. If session is stored remotely, attribute should
be Serializable.public void removeSessionAttribute(SessionData session, String name)
SessionRepositoryremoveSessionAttribute in interface SessionRepositorysession - the session informationname - attribute namepublic boolean cleanSessionsOnShutdown()
SessionRepositorytrue from this method.cleanSessionsOnShutdown in interface SessionRepositorytrue if repository supports cleaning of sessions on
application shutdownpublic Collection<String> getOwnedSessionIds()
SessionRepositoryUnsupportedOperationException if repository
doesn't offer this functionality.getOwnedSessionIds in interface SessionRepositorypublic void close()
SessionRepositoryclose in interface SessionRepositoryclose in interface Closeableclose in interface AutoCloseablepublic void sessionIdChange(SessionData sessionData)
sessionIdChange in interface SessionRepositorysessionData - Copyright © 2018 Amadeus s.a.s.. All rights reserved.