de.yourinspiration.jexpresso.session.SessionImpl Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of jexpresso-session Show documentation
Show all versions of jexpresso-session Show documentation
A JExpresso middleware providing user sessions.
package de.yourinspiration.jexpresso.session;
import java.io.Serializable;
import de.yourinspiration.jexpresso.Request;
/**
* Simple implemenation for {@link Session}.
*
* @author Marcel Härle
*
*/
public class SessionImpl implements Session {
private final Request request;
private final SessionStore sessionStore;
private final String sessionId;
/**
* Constructs a new object.
*
* @param request
* the request
* @param sessionStore
* the session store
*/
protected SessionImpl(final Request request, final SessionStore sessionStore) {
this.request = request;
this.sessionStore = sessionStore;
this.sessionId = request.cookie(JExpressoSession.COOKIE_NAME).getValue();
}
@Override
public T get(final String name, final Class clazz) {
return sessionStore.get(name, sessionId, clazz);
}
@Override
public void set(final String name, final Serializable value) {
sessionStore.set(name, value, sessionId);
}
@Override
public void invalidate() {
sessionStore.clear(sessionId);
request.cookie(JExpressoSession.COOKIE_NAME).setDiscard(true);
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy