Package com.caucho.quercus.env

Examples of com.caucho.quercus.env.SessionArrayValue


   */
  public SessionArrayValue loadSession(Env env, String sessionId)
  {
    long now = env.getCurrentTime();

    SessionArrayValue session
      = _sessionManager.getSession(env, sessionId, now);

    if (session == null)
      session = _sessionManager.createSession(env, sessionId, now);

View Full Code Here


   */
  public SessionArrayValue loadSession(Env env, String sessionId)
  {
    long now = env.getCurrentTime();

    SessionArrayValue session
      = _sessionManager.getSession(env, sessionId, now);

    if (session == null)
      session = _sessionManager.createSession(env, sessionId, now);

View Full Code Here

   * @param obj the session object to be deserialized
   */
  public void load(ObjectInputStream in, Object obj)
    throws IOException
  {
    SessionArrayValue session = (SessionArrayValue) obj;

    session.load(null, in);
  }
View Full Code Here

  /**
   * Checks if the session is empty.
   */
  public boolean isEmpty(Object obj)
  {
    SessionArrayValue session = (SessionArrayValue) obj;

    return session.isEmpty();
  }
View Full Code Here

    String id = oldId;

    if (id == null || id.length() < 4)
      id = createSessionId(env);

    SessionArrayValue session = create(env, id, now);

    if (session == null)
      return null;
   
    synchronized (_statisticsLock) {
View Full Code Here

   * @return the cached session.
   *
   */
  public SessionArrayValue getSession(Env env, String key, long now)
  {
    SessionArrayValue session;
    boolean isNew = false;

    if (_sessions == null)
      return null;

    // Check the cache first
    session = _sessions.get(key);

    if (session != null && ! session.getId().equals(key))
      throw new IllegalStateException(key + " != " + session.getId());

    if (session != null) {
      if (session.inUse()) {
        return (SessionArrayValue)session.copy(env);
      }
    }

    if (session == null)
      return null;

    if (isNew) {
      isNew = ! load(env, session, now);
    }
    else if (! getSaveOnlyOnShutdown() && ! session.load()) {
      // if the load failed, then the session died out from underneath
      session.reset(now);
      isNew = true;
    }

    if (! isNew)
      session.setAccess(now);
   
    return (SessionArrayValue)session.copy(env);
  }
View Full Code Here

    return (SessionArrayValue)session.copy(env);
  }

  public void saveSession(Env env, SessionArrayValue session)
  {
    SessionArrayValue copy = (SessionArrayValue) session.copy(env);

    _sessions.put(session.getId(), copy);
    session.finish();
  }
View Full Code Here

   * Creates a session.  It's already been established that the
   * key does not currently have a session.
   */
  protected SessionArrayValue create(Env env, String key, long now)
  {
    SessionArrayValue session
      = createSessionValue(key, now, _sessionTimeout);

    load(env, session, now);

    // If another thread has created and stored a new session,
    // putIfNew will return the old session
    session = _sessions.putIfNew(key, session);

    if (! key.equals(session.getId()))
      throw new IllegalStateException(key + " != " + session.getId());

    return (SessionArrayValue)session.copy(env);
  }
View Full Code Here

   * Creates a new SessionArrayValue instance.
   */
  protected SessionArrayValue createSessionValue(String key, long now,
                                                 long sessionTimeout)
  {
    return new SessionArrayValue(key, now, _sessionTimeout);
  }
View Full Code Here

      synchronized (_sessions) {
        _sessionIter = _sessions.values(_sessionIter);

        while (_sessionIter.hasNext()) {
          SessionArrayValue session = _sessionIter.next();

          long maxIdleTime = session.getMaxInactiveInterval();

          if (session.inUse())
            liveSessions++;
          else if (session.getAccessTime() + maxIdleTime < now)
            _sessionList.add(session);
          else
            liveSessions++;
        }
      }

      synchronized (_statisticsLock) {
        _sessionTimeoutCount += _sessionList.size();
      }

      for (int i = 0; i < _sessionList.size(); i++) {
        SessionArrayValue session = _sessionList.get(i);

        try {
          session.getMaxInactiveInterval();
          _sessions.remove(session.getId());

          session.invalidate();
        } catch (Throwable e) {
          log.log(Level.FINER, e.toString(), e);
        }
      }
    } finally {}
View Full Code Here

TOP

Related Classes of com.caucho.quercus.env.SessionArrayValue

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.