com.creamtec.ajaxswing.servlet

## Class SessionManager

- java.lang.Object
- - java.lang.Thread
  - - com.creamtec.ajaxswing.servlet.SessionManager

- All Implemented Interfaces:
    java.lang.Runnable

      public class SessionManager
      extends java.lang.Thread

  AjaxSwing does its own session management because certain servlet engines had problems with session expiration. The session manager runs a background thread that periodically checks if the sessions have been accessed. If a session has not been accessed for more then a timeout, is expired.

- - ### Nested Class Summary

    Nested Classes
    Modifier and Type | Class and Description
    --- | ---
    `static class` | `SessionManager.SessionInfo` Stores information about the managed session

    - ### Nested classes/interfaces inherited from class java.lang.Thread

      `java.lang.Thread.State, java.lang.Thread.UncaughtExceptionHandler`

  - ### Field Summary

    - ### Fields inherited from class java.lang.Thread

      `MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `SessionManager(long sessionTimeout)` Initializes and starts the session manager
    `SessionManager(long sessionTimeout, java.lang.String name)` Initializes and starts the session manager

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `actionPerformed(java.lang.Object session)` Resets timeout information for the given session.
    `void` | `addSession(java.lang.Object session, SessionListener listener, ClientAgentRemote agent)` Places a session into a map of sessions.
    `SessionManager.SessionInfo` | `getSession(int clientId)`
    `java.util.Set` | `getSessions()` Returns a set of all active sessions.
    `long` | `getSessionTimeout()` Returns session timeout
    `void` | `removeSession(java.lang.Object session)` Removes a given session from the managed list
    `void` | `run()` Periodically iterate all sessions and expire those that timed out
    `void` | `setSessionTimeout(long timeout)` Sets session timeout
    `void` | `shutdown()` Stops background session tracking thread.

    - ### Methods inherited from class java.lang.Thread

      `activeCount, checkAccess, countStackFrames, currentThread, destroy, dumpStack, enumerate, getAllStackTraces, getContextClassLoader, getDefaultUncaughtExceptionHandler, getId, getName, getPriority, getStackTrace, getState, getThreadGroup, getUncaughtExceptionHandler, holdsLock, interrupt, interrupted, isAlive, isDaemon, isInterrupted, join, join, join, resume, setContextClassLoader, setDaemon, setDefaultUncaughtExceptionHandler, setName, setPriority, setUncaughtExceptionHandler, sleep, sleep, start, stop, stop, suspend, toString, yield`

    - ### Methods inherited from class java.lang.Object

      `equals, getClass, hashCode, notify, notifyAll, wait, wait, wait`

- - ### Constructor Detail

    - #### SessionManager

          public SessionManager(long sessionTimeout)

      Initializes and starts the session manager
      Parameters:
        `sessionTimeout` - timeout in seconds

    - #### SessionManager

          public SessionManager(long sessionTimeout,
                        java.lang.String name)

      Initializes and starts the session manager
      Parameters:
        `sessionTimeout` - timeout in seconds
        `name` - application name used for logging

  - ### Method Detail

    - #### addSession

          public void addSession(java.lang.Object session,
                        SessionListener listener,
                        ClientAgentRemote agent)

      Places a session into a map of sessions.
      Parameters:
        `session` - session
        `listener` - will be called when this session has expired

    - #### removeSession

          public void removeSession(java.lang.Object session)

      Removes a given session from the managed list
      Parameters:
        `session` - Object

    - #### actionPerformed

          public void actionPerformed(java.lang.Object session)

      Resets timeout information for the given session.
      Parameters:
        `session` - session

    - #### shutdown

          public void shutdown()

      Stops background session tracking thread.

    - #### getSessions

          public java.util.Set getSessions()

      Returns a set of all active sessions.
      Returns:
        Set

    - #### getSessionTimeout

          public long getSessionTimeout()

      Returns session timeout
      Returns:
        timeout

    - #### setSessionTimeout

          public void setSessionTimeout(long timeout)

      Sets session timeout
      Parameters:
        `timeout` - new timeout

    - #### run

          public void run()

      Periodically iterate all sessions and expire those that timed out
      Specified by:
        `run` in interface `java.lang.Runnable`
      Overrides:
        `run` in class `java.lang.Thread`

    - #### getSession

          public SessionManager.SessionInfo getSession(int clientId)

Copyright © 2000-2012 CreamTec LLC. All Rights Reserved.