Refine search
@Override public void remove(Session session, boolean update) { super.remove(session, update); if (session.getIdInternal() != null) { ((RedissonSession)session).delete(); } }
@Override protected void stopInternal() throws LifecycleException { super.stopInternal(); setState(LifecycleState.STOPPING); try { shutdownRedisson(); } catch (Exception e) { throw new LifecycleException(e); } }
@Override public Session findSession(String id) throws IOException { Session result = super.findSession(id); if (result == null) { if (id != null) { result.access(); result.endAccess();
@Override public Session createSession(String sessionId) { if ((maxActiveSessions >= 0) && (getActiveSessions() >= maxActiveSessions)) { rejectedSessions++; throw new TooManyActiveSessionsException( sm.getString("managerBase.createSession.ise"), maxActiveSessions); } // Recycle or create a Session instance Session session = createEmptySession(); // Initialize the properties of the new session and return it session.setNew(true); session.setValid(true); session.setCreationTime(System.currentTimeMillis()); session.setMaxInactiveInterval(getContext().getSessionTimeout() * 60); String id = sessionId; if (id == null) { id = generateSessionId(); } session.setId(id); sessionCounter++; SessionTiming timing = new SessionTiming(session.getCreationTime(), 0); synchronized (sessionCreationTiming) { sessionCreationTiming.add(timing); sessionCreationTiming.poll(); } return session; }
/** * Construct and return a new session object, based on the default * settings specified by this Manager's properties. The session * id specified will be used as the session id. * If a new session cannot be created for any reason, return * <code>null</code>. * * @param sessionId The session id which should be used to create the * new session; if <code>null</code>, a new session id will be * generated * @exception IllegalStateException if a new session cannot be * instantiated for any reason */ public Session createSession(String sessionId, Random random) { // Recycle or create a Session instance Session session = createEmptySession(); // Initialize the properties of the new session and return it session.setNew(true); session.setValid(true); session.setCreationTime(System.currentTimeMillis()); session.setMaxInactiveInterval(this.maxInactiveInterval); if (sessionId == null) { sessionId = generateSessionId(random); } session.setId(sessionId); sessionCounter++; return (session); }
/** * Invalidate all sessions that have expired. */ public void processExpires() { long timeNow = System.currentTimeMillis(); Session sessions[] = findSessions(); int expireHere = 0 ; if(log.isDebugEnabled()) log.debug("Start expire sessions " + getName() + " at " + timeNow + " sessioncount " + sessions.length); for (int i = 0; i < sessions.length; i++) { if (!sessions[i].isValid()) { expireHere++; } } long timeEnd = System.currentTimeMillis(); if(log.isDebugEnabled()) log.debug("End expire sessions " + getName() + " processingTime " + (timeEnd - timeNow) + " expired sessions: " + expireHere); processingTime += ( timeEnd - timeNow ); }
private void removeInternal( final Session session, final boolean update, final boolean removeFromMemcached ) { if ( _log.isDebugEnabled() ) { _log.debug( "remove invoked, removeFromMemcached: " + removeFromMemcached + ", id: " + session.getId() ); } if ( removeFromMemcached ) { _msm.deleteFromMemcached( session.getId() ); } super.remove( session, update ); _msm.sessionRemoved((MemcachedBackupSession) session); }
@Override protected void startInternal() throws LifecycleException { // Ensure caches for timing stats are the right size by filling with // nulls. while (sessionCreationTiming.size() < TIMING_STATS_CACHE_SIZE) { sessionCreationTiming.add(null); } while (sessionExpirationTiming.size() < TIMING_STATS_CACHE_SIZE) { sessionExpirationTiming.add(null); } sessionIdGenerator = new SessionIdGenerator(); sessionIdGenerator.setJvmRoute(getJvmRoute()); sessionIdGenerator.setSecureRandomAlgorithm(getSecureRandomAlgorithm()); sessionIdGenerator.setSecureRandomClass(getSecureRandomClass()); sessionIdGenerator.setSecureRandomProvider(getSecureRandomProvider()); sessionIdGenerator.setSessionIdLength(getSessionIdLength()); // Force initialization of the random number generator if (log.isDebugEnabled()) log.debug("Force random number initialization starting"); sessionIdGenerator.generateSessionId(); if (log.isDebugEnabled()) log.debug("Force random number initialization completed"); }
/** * Change the session ID of the current session to a new randomly generated * session ID. * * @param session The session to change the session ID for */ @Override public void changeSessionId(Session session) { session.setId(generateSessionId()); }
@Override protected void startInternal() throws LifecycleException { super.startInternal(); redisson = buildClient();
public void store(HttpSession session) throws IOException { if (session == null) { return; } if (updateMode == UpdateMode.AFTER_REQUEST) { RedissonSession sess = (RedissonSession) super.findSession(session.getId()); if (sess != null) { sess.save(); } } }
/** * {@inheritDoc} */ @Override public String generateSessionId() { return _msm.newSessionId( super.generateSessionId() ); }
/** * Retrieve the JvmRoute for the enclosing Engine. * @return the JvmRoute or null. */ public String getJvmRoute() { Engine e = getEngine(); return e == null ? null : e.getJvmRoute(); }
/** * Get a session from the recycled ones or create a new empty one. * The PersistentManager manager does not need to create session data * because it reads it from the Store. */ @Override public Session createEmptySession() { return (getNewSession()); }
@Override public void changeSessionId(Session session) { String newId = generateSessionId(); changeSessionId(session, newId, true, true); }
@Override public void removeInternal( final Session session, final boolean update ) { // update is there for tomcat7, not available in tomcat6 super.remove( session ); }
/** * get jvmroute from engine * * @param request current request * @return return jvmRoute from ManagerBase or null */ protected String getLocalJvmRoute(Request request) { Manager manager = getManager(request); if(manager instanceof ManagerBase) return ((ManagerBase) manager).getJvmRoute(); return null ; }
/** * Generate and return a new session identifier. */ protected String generateSessionId(Random random) { byte[] bytes = new byte[sessionIdLength]; random.nextBytes(bytes); // Encode the result char[] id = encode(bytes); String jvmRoute = getJvmRoute(); if (appendJVMRoute() && jvmRoute != null) { StringBuilder buffer = new StringBuilder(); buffer.append(id).append('.').append(jvmRoute); return buffer.toString(); } else { return String.valueOf(id); } }
@Override public Session createSession(String sessionId) { if ((maxActiveSessions >= 0) && (getActiveSessions() >= maxActiveSessions)) { rejectedSessions++; throw new TooManyActiveSessionsException( sm.getString("managerBase.createSession.ise"), maxActiveSessions); } // Recycle or create a Session instance Session session = createEmptySession(); // Initialize the properties of the new session and return it session.setNew(true); session.setValid(true); session.setCreationTime(System.currentTimeMillis()); session.setMaxInactiveInterval(getContext().getSessionTimeout() * 60); String id = sessionId; if (id == null) { id = generateSessionId(); } session.setId(id); sessionCounter++; SessionTiming timing = new SessionTiming(session.getCreationTime(), 0); synchronized (sessionCreationTiming) { sessionCreationTiming.add(timing); sessionCreationTiming.poll(); } return session; }
/** * Construct and return a new session object, based on the default * settings specified by this Manager's properties. The session * id will be assigned by this method, and available via the getId() * method of the returned session. If a new session cannot be created * for any reason, return <code>null</code>. * Hercules: modified * * @exception IllegalStateException if a new session cannot be * instantiated for any reason */ public Session createSession() { // Recycle or create a Session instance Session session = null; session = createEmptySession(); //always lock session.lockForeground(); // Initialize the properties of the new session and return it session.setNew(true); session.setValid(true); session.setCreationTime(System.currentTimeMillis()); session.setMaxInactiveInterval(this.maxInactiveInterval); String sessionId = generateSessionId(session); session.setId(sessionId); sessionCounter++; return (session); }