public.javadoc.org.spincast.plugins.session.SpincastSessionManagerDefault.html Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of spincast-website Show documentation
Show all versions of spincast-website Show documentation
Source code for the https://www.spincast.org website.
SpincastSessionManagerDefault (org.spincast:spincast-framework 1.2.0 API)
org.spincast.plugins.session
Class SpincastSessionManagerDefault
- java.lang.Object
-
- org.spincast.plugins.session.SpincastSessionManagerDefault
-
- All Implemented Interfaces:
- SpincastSessionManager
public class SpincastSessionManagerDefault
extends Object
implements SpincastSessionManager
-
-
Field Summary
Fields
Modifier and Type
Field and Description
protected static org.slf4j.Logger
logger
static String
REQUEST_CONTEXT_VARIABLE_SESSION
The name of the request context variable used to
save the user session.
-
Constructor Summary
Constructors
Constructor and Description
SpincastSessionManagerDefault(SpincastSessionFactory spincastSessionFactory,
com.google.inject.Provider<RequestContext<?>> requestContextProvider,
JsonManager jsonManager,
SpincastSessionConfig spincastSessionConfig,
SpincastSessionRepository spincastSessionRepository)
-
Method Summary
All Methods Instance Methods Concrete Methods
Modifier and Type
Method and Description
SpincastSession
createNewSession()
Creates a new session.
SpincastSession
createSession(String sessionId,
Instant creationDate,
Instant modificationDate,
JsonObject attributes)
Creates a session from infos, with existing
attributes if any (null
otherwise)
void
deleteCurrentSession()
Deletes the current session in the request
context, if any.
void
deleteOldInactiveSession(int sessionMaxInactiveMinutes)
Deletes the deletes that were inactive for too long.
void
deleteSession(String sessionId)
Deletes a saved session.
void
deleteSessionIdOnUser()
Deletes the session id on the user.
String
generateNewSessionId()
Generates a new session id.
SpincastSession
getCurrentSession()
Gets the session of the current user, from the
request context.
protected JsonManager
getJsonManager()
protected com.google.inject.Provider<RequestContext<?>>
getRequestContextProvider()
SpincastSession
getSavedSession(String sessionId)
Gets a session from the database/data source.
protected SpincastSessionConfig
getSpincastSessionConfig()
protected SpincastSessionFactory
getSpincastSessionFactory()
protected SpincastSessionRepository
getSpincastSessionRepository()
void
saveSession(SpincastSession session)
Save session.
protected void
saveSessionIdOnUser(RequestContext<?> context,
String sessionId,
boolean permanent)
void
saveSessionIdOnUser(String sessionId,
boolean permanent)
Will save the session id to the user (by default using
a cookie).
void
updateModificationDateAndSaveSession(SpincastSession session)
Saves a session, but update its modification date first.
-
-
Field Detail
-
logger
protected static final org.slf4j.Logger logger
-
REQUEST_CONTEXT_VARIABLE_SESSION
public static final String REQUEST_CONTEXT_VARIABLE_SESSION
The name of the request context variable used to
save the user session.
-
Constructor Detail
-
SpincastSessionManagerDefault
@Inject
public SpincastSessionManagerDefault(SpincastSessionFactory spincastSessionFactory,
com.google.inject.Provider<RequestContext<?>> requestContextProvider,
JsonManager jsonManager,
SpincastSessionConfig spincastSessionConfig,
SpincastSessionRepository spincastSessionRepository)
-
Method Detail
-
getSpincastSessionFactory
protected SpincastSessionFactory getSpincastSessionFactory()
-
getRequestContextProvider
protected com.google.inject.Provider<RequestContext<?>> getRequestContextProvider()
-
getJsonManager
protected JsonManager getJsonManager()
-
getSpincastSessionConfig
protected SpincastSessionConfig getSpincastSessionConfig()
-
getSpincastSessionRepository
protected SpincastSessionRepository getSpincastSessionRepository()
-
createNewSession
public SpincastSession createNewSession()
Description copied from interface: SpincastSessionManager
Creates a new session.
- Specified by:
createNewSession
in interface SpincastSessionManager
-
createSession
public SpincastSession createSession(String sessionId,
Instant creationDate,
Instant modificationDate,
JsonObject attributes)
Description copied from interface: SpincastSessionManager
Creates a session from infos, with existing
attributes if any (null
otherwise)
- Specified by:
createSession
in interface SpincastSessionManager
-
getCurrentSession
public SpincastSession getCurrentSession()
Description copied from interface: SpincastSessionManager
Gets the session of the current user, from the
request context. If not in a request context,
returns null
.
- Specified by:
getCurrentSession
in interface SpincastSessionManager
-
generateNewSessionId
public String generateNewSessionId()
Description copied from interface: SpincastSessionManager
Generates a new session id.
- Specified by:
generateNewSessionId
in interface SpincastSessionManager
-
deleteSessionIdOnUser
public void deleteSessionIdOnUser()
Description copied from interface: SpincastSessionManager
Deletes the session id on the user. By default, will delete
the session id cookie.
- Specified by:
deleteSessionIdOnUser
in interface SpincastSessionManager
-
saveSessionIdOnUser
public void saveSessionIdOnUser(String sessionId,
boolean permanent)
Description copied from interface: SpincastSessionManager
Will save the session id to the user (by default using
a cookie).
- Specified by:
saveSessionIdOnUser
in interface SpincastSessionManager
permanent
- if true
, the session id will be kept
when the browser session expires.
-
saveSessionIdOnUser
protected void saveSessionIdOnUser(RequestContext<?> context,
String sessionId,
boolean permanent)
-
updateModificationDateAndSaveSession
public final void updateModificationDateAndSaveSession(SpincastSession session)
Description copied from interface: SpincastSessionManager
Saves a session, but update its modification date first.
The session to save must have a session id.
- Specified by:
updateModificationDateAndSaveSession
in interface SpincastSessionManager
-
deleteCurrentSession
public void deleteCurrentSession()
Description copied from interface: SpincastSessionManager
Deletes the current session in the request
context, if any.
- Specified by:
deleteCurrentSession
in interface SpincastSessionManager
-
getSavedSession
public SpincastSession getSavedSession(String sessionId)
Description copied from interface: SpincastSessionManager
Gets a session from the database/data source.
- Specified by:
getSavedSession
in interface SpincastSessionManager
- Returns:
- the session or
null
if not found.
-
saveSession
public void saveSession(SpincastSession session)
Description copied from interface: SpincastSessionManager
Save session.
- Specified by:
saveSession
in interface SpincastSessionManager
-
deleteSession
public void deleteSession(String sessionId)
Description copied from interface: SpincastSessionManager
Deletes a saved session.
- Specified by:
deleteSession
in interface SpincastSessionManager
-
deleteOldInactiveSession
public void deleteOldInactiveSession(int sessionMaxInactiveMinutes)
Description copied from interface: SpincastSessionManager
Deletes the deletes that were inactive for too long.
This means their last "modification date" must be older than
the specified number of mminutes.
- Specified by:
deleteOldInactiveSession
in interface SpincastSessionManager
Copyright © 2019. All rights reserved.