All Downloads are FREE. Search and download functionalities are using the official Maven repository.

de.yourinspiration.jexpresso.session.SessionImpl Maven / Gradle / Ivy

There is a newer version: 1.0.1
Show newest version
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