private void configureSession(WebAppContext context) { SessionHandler handler = context.getSessionHandler(); Duration sessionTimeout = getSession().getTimeout(); handler.setMaxInactiveInterval( isNegative(sessionTimeout) ? -1 : (int) sessionTimeout.getSeconds()); if (getSession().isPersistent()) { DefaultSessionCache cache = new DefaultSessionCache(handler); FileSessionDataStore store = new FileSessionDataStore(); store.setStoreDir(getValidSessionStoreDir()); cache.setSessionDataStore(store); handler.setSessionCache(cache); } }
/** * @see org.eclipse.jetty.server.session.SessionCacheFactory#getSessionCache(org.eclipse.jetty.server.session.SessionHandler) */ @Override public SessionCache getSessionCache (SessionHandler handler) { DefaultSessionCache cache = new DefaultSessionCache(handler); cache.setEvictionPolicy(getEvictionPolicy()); cache.setSaveOnInactiveEviction(isSaveOnInactiveEvict()); cache.setSaveOnCreate(isSaveOnCreate()); cache.setRemoveUnloadableSessions(isRemoveUnloadableSessions()); return cache; }
public void assertSessionCounts (int current, int max, int total, SessionHandler manager) { assertEquals(current, ((DefaultSessionCache)manager.getSessionCache()).getSessionsCurrent()); assertEquals(max, ((DefaultSessionCache)manager.getSessionCache()).getSessionsMax()); assertEquals(total, ((DefaultSessionCache)manager.getSessionCache()).getSessionsTotal()); }
public void setSessionDataStore(SessionDataStoreFactory sessionDataStoreFactory) throws Exception { SessionCache sessionCache = getSessionCache(); if (sessionCache != null) { sessionCache.setSessionDataStore(sessionDataStoreFactory.getSessionDataStore(this)); } else { sessionCache = new DefaultSessionCache(this); sessionCache.setSessionDataStore(sessionDataStoreFactory.getSessionDataStore(this)); setSessionCache(sessionCache); } }
/** * @see org.eclipse.jetty.server.session.AbstractSessionCache#newSession(javax.servlet.http.HttpServletRequest, org.eclipse.jetty.server.session.SessionData) */ @Override public Session newSession(HttpServletRequest request, SessionData data) { Session s = new Session(getSessionHandler(),request, data); return s; }
doDelete (session.getId()); //remove from memory session.setResident(false);
String sessionCookie = response1.getHeaders().get("Set-Cookie"); assertTrue( sessionCookie != null ); assertEquals(1, ((DefaultSessionCache)m1.getSessionCache()).getSessionsCurrent()); assertEquals(1, ((DefaultSessionCache)m1.getSessionCache()).getSessionsMax()); assertEquals(1, ((DefaultSessionCache)m1.getSessionCache()).getSessionsTotal());
setSessionCache(ssFactory != null?ssFactory.getSessionCache(this):new DefaultSessionCache(this)); SessionDataStore sds = null; SessionDataStoreFactory sdsFactory = server.getBean(SessionDataStoreFactory.class);
/** * @see org.eclipse.jetty.server.session.AbstractSessionCache#newSession(org.eclipse.jetty.server.session.SessionData) */ @Override public Session newSession(SessionData data) { Session s = new Session (getSessionHandler(), data); return s; }