Package com.caucho.quercus.env

Examples of com.caucho.quercus.env.SessionArrayValue


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

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

        if (session.isValid())
          list.add(session);
      }
    }

    for (int i = list.size() - 1; i >= 0; i--) {
      SessionArrayValue session = list.get(i);

      try {
        if (session.isValid()) {
          synchronized (session) {
            if (! session.isEmpty())
              session.storeOnShutdown();
          }
        }

        _sessions.remove(session.getId());
      } catch (Exception e) {
        if (! isError)
          log.log(Level.WARNING, "Can't store session: " + e, e);
        isError = true;
      }
View Full Code Here


  /**
   * Notification from the cluster.
   */
  public void notifyRemove(String id)
  {
    SessionArrayValue session = _sessions.remove(id);

    if (session != null)
      session.invalidate();
  }
View Full Code Here

   * Saves the session.
   */
  public void store(OutputStream out, Object obj)
    throws IOException
  {
    SessionArrayValue session = (SessionArrayValue) obj;

    session.store(Env.getInstance(), out);
  }
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;
    boolean killSession = 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();

    if (_persistentStore != null) {
      _persistentStore.put(session.getId(), copy.encode(env));
    }
  }
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

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.