org.apache.turbine.services.session

## Interface SessionService

- All Superinterfaces:
    Initable, Service
  All Known Implementing Classes:
    TurbineSessionService

      public interface SessionService
      extends Service

  The SessionService allows access to the current sessions of the current context. The session objects that are cached by this service are obtained through a listener. The listener must be configured in your web.xml file.
  Since:
    2.3
  Version:
    $Id: SessionService.java 1066925 2011-02-03 19:44:37Z ludwig $
  Author:
    Quinton McCombs
  See Also:
    `SessionListener`

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `static String` | `SERVICE_NAME` The key under which this service is stored in TurbineServices.

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `addSession(HttpSession session)` Adds a session to the current list.
    `Collection<HttpSession>` | `getActiveSessions()` Gets all active sessions
    `Collection<User>` | `getActiveUsers()` Gets a collection of all user objects representing the users currently logged in.
    `HttpSession` | `getSession(String sessionId)` Gets the HttpSession by the session identifier
    `Collection<HttpSession>` | `getSessionsForUser(User user)` Get a collection of all session on which the given user is logged in.
    `User` | `getUserFromSession(HttpSession session)` Gets the User object of the the specified HttpSession.
    `boolean` | `isUserLoggedIn(User user)` Determines if a given user is currently logged in.
    `void` | `removeSession(HttpSession session)` Removes a session from the current list.

    - ### Methods inherited from interface org.apache.turbine.services.Service

      `getConfiguration, getName, getProperties, setName, setServiceBroker`

    - ### Methods inherited from interface org.apache.turbine.services.Initable

      `getInit, init, init, setInitableBroker, shutdown`

- - ### Field Detail

    - #### SERVICE_NAME

          static final String SERVICE_NAME

      The key under which this service is stored in TurbineServices.
      See Also:
        Constant Field Values

  - ### Method Detail

    - #### getActiveSessions

          Collection<HttpSession> getActiveSessions()

      Gets all active sessions
      Returns:
        Collection of HttpSession objects

    - #### addSession

          void addSession(HttpSession session)

      Adds a session to the current list. This method should only be called by the listener.
      Parameters:
        `session` - Session to add

    - #### removeSession

          void removeSession(HttpSession session)

      Removes a session from the current list. This method should only be called by the listener.
      Parameters:
        `session` - Session to remove

    - #### isUserLoggedIn

          boolean isUserLoggedIn(User user)

      Determines if a given user is currently logged in. The actual implementation of the User object must implement the equals() method. By default, Torque based objects (liek TurbineUser) have an implementation of equals() that will compare the result of getPrimaryKey().
      Parameters:
        `user` - User to check for
      Returns:
        true if the user is logged in on one of the active sessions.

    - #### getActiveUsers

          Collection<User> getActiveUsers()

      Gets a collection of all user objects representing the users currently logged in. This will exclude any instances of anonymous user that Turbine will use before the user actually logs on.
      Returns:
        collection of org.apache.turbine.om.security.User objects

    - #### getUserFromSession

          User getUserFromSession(HttpSession session)

      Gets the User object of the the specified HttpSession.
      Parameters:
        `session` - The session from which to extract a user.
      Returns:
        The Turbine User object.

    - #### getSession

          HttpSession getSession(String sessionId)

      Gets the HttpSession by the session identifier
      Parameters:
        `sessionId` - The unique session identifier.
      Returns:
        The session keyed by the specified identifier.

    - #### getSessionsForUser

          Collection<HttpSession> getSessionsForUser(User user)

      Get a collection of all session on which the given user is logged in.
      Parameters:
        `user` - the user
      Returns:
        Collection of HtttSession objects

Copyright © 2000-2015 The Apache Software Foundation. All Rights Reserved.