Package org.openbravo.erpCommon.security
Class SessionListener
- java.lang.Object
-
- org.openbravo.erpCommon.security.SessionListener
-
- All Implemented Interfaces:
EventListener
,javax.servlet.http.HttpSessionListener
,javax.servlet.ServletContextListener
public class SessionListener extends Object implements javax.servlet.http.HttpSessionListener, javax.servlet.ServletContextListener
Keeps track of active sessions in this context so they can be marked as no active in database when they are destroyed. Also used to keep last activity info for CU management.
-
-
Constructor Summary
Constructors Constructor Description SessionListener()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static void
addSession(String sessionId)
Add a session to session tracking.void
contextDestroyed(javax.servlet.ServletContextEvent event)
This method is invoked when the server is shot down, it deactivates all sessions in this context.void
contextInitialized(javax.servlet.ServletContextEvent event)
Sets the current context and deactivates orphan sessions.static javax.servlet.http.HttpSession
getActiveSession(String sessionId)
Returns theHttpSession
identified bysessionId
it is present in this context.static boolean
isSessionActiveInContext(String sessionId)
Check whether a session is in the current context and it is activevoid
sessionCreated(javax.servlet.http.HttpSessionEvent event)
void
sessionDestroyed(javax.servlet.http.HttpSessionEvent event)
This method is called whenever the session is destroyed because of user action or time out.
-
-
-
Method Detail
-
sessionDestroyed
public void sessionDestroyed(javax.servlet.http.HttpSessionEvent event)
This method is called whenever the session is destroyed because of user action or time out. It deactivates the session in db- Specified by:
sessionDestroyed
in interfacejavax.servlet.http.HttpSessionListener
-
contextDestroyed
public void contextDestroyed(javax.servlet.ServletContextEvent event)
This method is invoked when the server is shot down, it deactivates all sessions in this context.- Specified by:
contextDestroyed
in interfacejavax.servlet.ServletContextListener
-
addSession
public static void addSession(String sessionId)
Add a session to session tracking. This will be used when shut dowing the server- Parameters:
sessionId
- db id for the session to keep track
-
contextInitialized
public void contextInitialized(javax.servlet.ServletContextEvent event)
Sets the current context and deactivates orphan sessions. Orphan sessions occur after a wrong context shutdown.- Specified by:
contextInitialized
in interfacejavax.servlet.ServletContextListener
-
sessionCreated
public void sessionCreated(javax.servlet.http.HttpSessionEvent event)
- Specified by:
sessionCreated
in interfacejavax.servlet.http.HttpSessionListener
-
getActiveSession
public static javax.servlet.http.HttpSession getActiveSession(String sessionId)
Returns theHttpSession
identified bysessionId
it is present in this context. If not presentnull
is returned.
-
isSessionActiveInContext
public static boolean isSessionActiveInContext(String sessionId)
Check whether a session is in the current context and it is active- Parameters:
sessionId
- session to check- Returns:
- true in case it is in the context and active
-
-