public class SessionTool extends Object implements ApplicationTool
Constructor and Description |
---|
SessionTool() |
Modifier and Type | Method and Description |
---|---|
void |
addSession(javax.servlet.http.HttpSession session)
Adds a session to the current list.
|
Collection<javax.servlet.http.HttpSession> |
getActiveSessions()
Gets a list of the active sessions
|
Collection<User> |
getActiveUsers()
Gets a collection of all user objects representing the users currently
logged in.
|
Collection<javax.servlet.http.HttpSession> |
getSessionsForUser(User user)
Get a collection of all session on which the given user
is logged in.
|
User |
getUserFromSession(javax.servlet.http.HttpSession session)
Gets the User object of the the specified HttpSession.
|
void |
init(Object o)
Initialize the application tool.
|
boolean |
isUserLoggedIn(User user)
Determines if a given user is currently logged in.
|
void |
refresh()
Refresh the application tool.
|
void |
removeSession(javax.servlet.http.HttpSession session)
Removes a session from the current list.
|
public SessionTool()
public void init(Object o)
ApplicationTool
It is possible that session scope tools will be initialized with a null
User
object. This happens when the first request on a
session happens to the be login action.
If your session tool depends on having a User
object, you
should look at implementing the RunDataApplicationTool
interface
instead.
init
in interface ApplicationTool
o
- initialization datapublic void refresh()
ApplicationTool
refresh
in interface ApplicationTool
public Collection<javax.servlet.http.HttpSession> getActiveSessions()
public void addSession(javax.servlet.http.HttpSession session)
session
- Session to addpublic void removeSession(javax.servlet.http.HttpSession session)
session
- Session to removepublic boolean isUserLoggedIn(User user)
user
- User to check forpublic Collection<User> getActiveUsers()
public User getUserFromSession(javax.servlet.http.HttpSession session)
session
- public Collection<javax.servlet.http.HttpSession> getSessionsForUser(User user)
user
- the userCopyright © 2000–2018 The Apache Software Foundation. All rights reserved.