use of com.networknt.session.Session in project light-session-4j by networknt.
the class JdbcSessionManager method getSession.
@Override
public Session getSession(final HttpServerExchange serverExchange) {
if (serverExchange != null) {
JdbcSessionRepository.JdbcSession newSession = serverExchange.getAttachment(NEW_SESSION);
if (newSession != null) {
return newSession;
}
}
String sessionId = sessionConfig.findSessionId(serverExchange);
Session session = getSession(sessionId);
if (session == null) {
sessionConfig.clearSession(serverExchange, sessionId);
}
return session;
}
use of com.networknt.session.Session in project light-session-4j by networknt.
the class JdbcSessionMultipleTest method getTestHandler.
static RoutingHandler getTestHandler() {
return Handlers.routing().add(Methods.GET, "/get", exchange -> {
SessionManager sessionManager = SingletonServiceFactory.getBean(SessionManager.class);
Session session = sessionManager.getSession(exchange);
if (session == null) {
session = sessionManager.createSession(exchange);
session.setAttribute(COUNT, 0);
logger.debug("first time access create a session and count is 0 sessionId = " + session.getId());
}
Integer count = (Integer) session.getAttribute(COUNT);
logger.debug("not the first time, get count from session = " + count + " sessionId = " + session.getId());
exchange.getResponseHeaders().add(new HttpString(COUNT), count.toString());
session.setAttribute(COUNT, ++count);
});
}
use of com.networknt.session.Session in project light-session-4j by networknt.
the class RedisSessionSingleIT method getTestHandler.
static RoutingHandler getTestHandler() {
return Handlers.routing().add(Methods.GET, "/get", exchange -> {
SessionManager sessionManager = SingletonServiceFactory.getBean(SessionManager.class);
Session session = sessionManager.getSession(exchange);
if (session == null) {
session = sessionManager.createSession(exchange);
session.setAttribute(COUNT, 0);
logger.debug("first time access create a session and count is 0 sessionId = " + session.getId());
}
Integer count = (Integer) session.getAttribute(COUNT);
logger.debug("not the first time, get count from session = " + count + " sessionId = " + session.getId());
exchange.getResponseHeaders().add(new HttpString(COUNT), count.toString());
session.setAttribute(COUNT, ++count);
});
}
use of com.networknt.session.Session in project light-session-4j by networknt.
the class HazelcastSessionManager method removeSession.
@Override
public Session removeSession(HttpServerExchange serverExchange) {
if (serverExchange != null) {
String sessionId = sessionConfig.findSessionId(serverExchange);
Session oldSession = serverExchange.removeAttachment(NEW_SESSION);
removeSession(sessionId);
return oldSession;
}
return null;
}
use of com.networknt.session.Session in project light-session-4j by networknt.
the class HazelcastSessionManager method getSession.
@Override
public Session getSession(HttpServerExchange serverExchange) {
if (serverExchange != null) {
HazelcastSessionRepository.HazelcastSession newSession = serverExchange.getAttachment(NEW_SESSION);
if (newSession != null) {
return newSession;
}
}
String sessionId = sessionConfig.findSessionId(serverExchange);
Session session = getSession(sessionId);
if (session == null) {
sessionConfig.clearSession(serverExchange, sessionId);
}
return session;
}
Aggregations