|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.apache.wiki.auth.SessionMonitor
public class SessionMonitor
Manages WikiSession's for different WikiEngine's.
The WikiSession's are stored both in the remote user HttpSession and in the SessionMonitor for the WikeEngine. This class must be configured as a session listener in the web.xml for the wiki web application.
Constructor Summary | |
---|---|
SessionMonitor()
Construct the SessionListener |
Method Summary | |
---|---|
void |
addWikiEventListener(WikiEventListener listener)
Registers a WikiEventListener with this instance. |
WikiSession |
find(javax.servlet.http.HttpSession session)
Looks up the wiki session associated with a user's Http session and adds it to the session cache. |
protected void |
fireEvent(int type,
Principal principal,
WikiSession session)
Fires a WikiSecurityEvent to all registered listeners. |
static SessionMonitor |
getInstance(WikiEngine engine)
Returns the instance of the SessionMonitor for this wiki. |
void |
remove(javax.servlet.http.HttpSession session)
Removes the wiki session associated with the user's HttpSession from the session cache. |
void |
removeWikiEventListener(WikiEventListener listener)
Un-registers a WikiEventListener with this instance. |
void |
sessionCreated(javax.servlet.http.HttpSessionEvent se)
Fires when the web container creates a new HTTP session. |
void |
sessionDestroyed(javax.servlet.http.HttpSessionEvent se)
Removes the user's WikiSession from the internal session cache when the web container destoys an HTTP session. |
int |
sessions()
Returns the current number of active wiki sessions. |
Principal[] |
userPrincipals()
Returns the current wiki users as a sorted array of Principal objects. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public SessionMonitor()
Method Detail |
---|
public static final SessionMonitor getInstance(WikiEngine engine)
engine
- the wiki engine
public final WikiSession find(javax.servlet.http.HttpSession session)
Looks up the wiki session associated with a user's Http session
and adds it to the session cache. This method will return the
"guest session" as constructed by WikiSession.guestSession(WikiEngine)
if the HttpSession is not currently associated with a WikiSession.
This method is guaranteed to return a non-null
WikiSession.
Internally, the session is stored in a HashMap; keys are
the HttpSession objects, while the values are
WeakReference
-wrapped WikiSessions.
session
- the HTTP session
public final void remove(javax.servlet.http.HttpSession session)
session
- the user's HTTP sessionpublic final int sessions()
public final Principal[] userPrincipals()
Returns the current wiki users as a sorted array of
Principal objects. The principals are those returned by
each WikiSession's WikiSession.getUserPrincipal()
's
method.
To obtain the list of current WikiSessions, we iterate
through our session Map and obtain the list of values,
which are WikiSessions wrapped in WeakReference
objects. Those WeakReference
s whose get()
method returns non-null
values are valid
sessions.
public final void addWikiEventListener(WikiEventListener listener)
listener
- the event listenerpublic final void removeWikiEventListener(WikiEventListener listener)
listener
- the event listenerprotected final void fireEvent(int type, Principal principal, WikiSession session)
type
- the event typeprincipal
- the user principal associated with this sessionsession
- the wiki sessionpublic void sessionCreated(javax.servlet.http.HttpSessionEvent se)
sessionCreated
in interface javax.servlet.http.HttpSessionListener
se
- the HTTP session eventpublic void sessionDestroyed(javax.servlet.http.HttpSessionEvent se)
sessionDestroyed
in interface javax.servlet.http.HttpSessionListener
se
- the HTTP session event
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |