- Add the Codota plugin to your IDE and get smart completions
private void myMethod () {}
@Override public void onStop(Session session) { LOGGER.debug("会话停止:" + session.getId()); }
/** * Immediately delegates to the underlying proxied session. */ public Serializable getId() { return delegate.getId(); }
@Override public void onStart(Session session) { LOGGER.debug("会话创建:" + session.getId()); }
@Override public void onExpiration(Session session) { LOGGER.debug("会话过期:" + session.getId()); }
public void disableUpdatesForSession(final Session session) { noUpdateSessionsCache.put(session.getId(), Boolean.TRUE); }
public void delete(Session session) { if (session == null) { throw new NullPointerException("session argument cannot be null."); } Serializable id = session.getId(); if (id != null) { sessions.remove(id); } }
@Override protected void doDelete(Session session) { LOG.debug("Deleting session {}", session); final Serializable id = session.getId(); final MongoDbSession dbSession = mongoDBSessionService.load(id.toString()); if (dbSession != null) { final int deleted = mongoDBSessionService.destroy(dbSession); LOG.debug("Deleted {} sessions with ID {} from database", deleted, id); } else { LOG.debug("Session {} not found in database", id); } }
public String getId() { return getSession().getId().toString(); }
public void enableUpdatesForSession(final Session session) { noUpdateSessionsCache.invalidate(session.getId()); doUpdate(session); }
public void update(Session session) throws UnknownSessionException { storeSession(session.getId(), session); }
public SessionModelDao(final Session session) { this.id = session.getId() == null ? null : session.getId().toString(); this.startTimestamp = new DateTime(session.getStartTimestamp(), DateTimeZone.UTC); this.lastAccessTime = new DateTime(session.getLastAccessTime(), DateTimeZone.UTC); this.timeout = session.getTimeout(); this.host = session.getHost(); try { this.sessionData = serializeSessionData(session); } catch (final IOException e) { this.sessionData = new byte[]{}; } }
@Override protected void doUpdate(Session session) { // 如果会话过期/停止 没必要再更新了 if(session instanceof ValidatingSession && !((ValidatingSession)session).isValid()) { return; } // 更新session的最后一次访问时间 UpmsSession upmsSession = (UpmsSession) session; UpmsSession cacheUpmsSession = (UpmsSession) doReadSession(session.getId()); if (null != cacheUpmsSession) { upmsSession.setStatus(cacheUpmsSession.getStatus()); upmsSession.setAttribute("FORCE_LOGOUT", cacheUpmsSession.getAttribute("FORCE_LOGOUT")); } RedisUtil.set(ZHENG_UPMS_SHIRO_SESSION_ID + "_" + session.getId(), SerializableUtil.serialize(session), (int) session.getTimeout() / 1000); // 更新ZHENG_UPMS_SERVER_SESSION_ID、ZHENG_UPMS_SERVER_CODE过期时间 TODO LOGGER.debug("doUpdate >>>>> sessionId={}", session.getId()); }
protected void onExpiration(Session s, ExpiredSessionException ese, SessionKey key) { log.trace("Session with id [{}] has expired.", s.getId()); try { onExpiration(s); notifyExpiration(s); } finally { afterExpired(s); } }
protected void onInvalidation(Session s, InvalidSessionException ise, SessionKey key) { if (ise instanceof ExpiredSessionException) { onExpiration(s, (ExpiredSessionException) ise, key); return; } log.trace("Session with id [{}] is invalid.", s.getId()); try { onStop(s); notifyStop(s); } finally { afterStopped(s); } }
public void stop(SessionKey key) throws InvalidSessionException { Session session = lookupRequiredSession(key); try { if (log.isDebugEnabled()) { log.debug("Stopping session with id [" + session.getId() + "]"); } session.stop(); onStop(session, key); notifyStop(session); } finally { afterStopped(session); } }
protected Session createExposedSession(Session session, SessionContext context) { if (!WebUtils.isWeb(context)) { return super.createExposedSession(session, context); } ServletRequest request = WebUtils.getRequest(context); ServletResponse response = WebUtils.getResponse(context); SessionKey key = new WebSessionKey(session.getId(), request, response); return new DelegatingSession(this, key); }
protected Session createExposedSession(Session session, SessionKey key) { if (!WebUtils.isWeb(key)) { return super.createExposedSession(session, key); } ServletRequest request = WebUtils.getRequest(key); ServletResponse response = WebUtils.getResponse(key); SessionKey sessionKey = new WebSessionKey(session.getId(), request, response); return new DelegatingSession(this, sessionKey); }
@Test public void testSessionListenerStopNotification() { final boolean[] stopped = new boolean[1]; SessionListener listener = new SessionListenerAdapter() { public void onStop(Session session) { stopped[0] = true; } }; sm.getSessionListeners().add(listener); Session session = sm.start(null); sm.stop(new DefaultSessionKey(session.getId())); assertTrue(stopped[0]); }
@Test public void testGlobalTimeout() { long timeout = 1000; sm.setGlobalSessionTimeout(timeout); Session session = sm.start(null); assertNotNull(session); assertNotNull(session.getId()); assertEquals(session.getTimeout(), timeout); }
@Before public void setup() { ThreadContext.remove(); sm = new DefaultSessionManager(); this.session = new DelegatingSession(sm, new DefaultSessionKey(sm.start(null).getId())); }