Package com.networknt.session.jdbc
Class JdbcSessionRepository
java.lang.Object
com.networknt.session.jdbc.JdbcSessionRepository
- All Implemented Interfaces:
SessionRepository<com.networknt.session.jdbc.JdbcSessionRepository.JdbcSession>
public class JdbcSessionRepository
extends Object
implements SessionRepository<com.networknt.session.jdbc.JdbcSessionRepository.JdbcSession>
A
SessionRepository implementation that uses
Database to store sessions in a relational database. This
implementation does not support publishing of session events.
An example of how to create a new instance can be seen below:
JdbcSessionRepository sessionRepository = new JdbcSessionRepository(dataSource);
Depending on your database, the table definition can be described as below:
CREATE TABLE light_session ( session_id VARCHAR2(100) NOT NULL, creation_time bigint NOT NULL, last_access_time bigint NOT NULL, max_inactive_interval int, expiry_time bigint, principal_name VARCHAR(100), PRIMARY KEY(session_id) ); CREATE TABLE light_session_attributes ( session_id VARCHAR2(100) NOT NULL, attribute_name VARCHAR(200) NOT NULL, attribute_bytes BYTEA, PRIMARY KEY(session_id, attribute_name) );
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidcom.networknt.session.jdbc.JdbcSessionRepository.JdbcSessionvoiddeleteById(String id) List<com.networknt.session.jdbc.JdbcSessionRepository.JdbcSession> extractData(ResultSet rs) com.networknt.session.jdbc.JdbcSessionRepository.JdbcSessionvoidsave(com.networknt.session.jdbc.JdbcSessionRepository.JdbcSession session) voidsetDefaultMaxInactiveInterval(int defaultMaxInactiveInterval) Set the maximum inactive interval in seconds between requests before newly created sessions will be invalidated.void
-
Constructor Details
-
JdbcSessionRepository
-
-
Method Details
-
setDefaultMaxInactiveInterval
public void setDefaultMaxInactiveInterval(int defaultMaxInactiveInterval) Set the maximum inactive interval in seconds between requests before newly created sessions will be invalidated. A negative time indicates that the session will never timeout. The default is 1800 (30 minutes).- Parameters:
defaultMaxInactiveInterval- the maximum inactive interval in seconds
-
createSession
public com.networknt.session.jdbc.JdbcSessionRepository.JdbcSession createSession()- Specified by:
createSessionin interfaceSessionRepository<com.networknt.session.jdbc.JdbcSessionRepository.JdbcSession>
-
getSessions
-
save
public void save(com.networknt.session.jdbc.JdbcSessionRepository.JdbcSession session) - Specified by:
savein interfaceSessionRepository<com.networknt.session.jdbc.JdbcSessionRepository.JdbcSession>
-
findById
- Specified by:
findByIdin interfaceSessionRepository<com.networknt.session.jdbc.JdbcSessionRepository.JdbcSession>
-
deleteById
- Specified by:
deleteByIdin interfaceSessionRepository<com.networknt.session.jdbc.JdbcSessionRepository.JdbcSession>
-
cleanUpExpiredSessions
public void cleanUpExpiredSessions() -
updateSessionLastAccessTime
-
extractData
public List<com.networknt.session.jdbc.JdbcSessionRepository.JdbcSession> extractData(ResultSet rs) throws SQLException - Throws:
SQLException
-