uk.org.ogsadai.sessions.impl
Class SessionTerminator

java.lang.Object
  |
  +--uk.org.ogsadai.sessions.impl.SessionTerminator
All Implemented Interfaces:
SessionListener

public class SessionTerminator
extends java.lang.Object
implements SessionListener

A session listener that starts an expiry timer whenever the session has no participants.

If the expiry time is reached, the session is automatically terminated and any subsequent attempts to join the session will result in a "no such session" error. If the expiry timer is running an a participant joins the session, the expiry timer will be cancelled, and a new timer will be created only when the session has no participants again. In other words, a session will not expire as long as it has one or more participants.

Author:
The OGSA-DAI Project Team

Field Summary
private static?java.lang.String COPYRIGHT_NOTICE
???????????
private static?DAILogger LOG
???????????
private ?SessionManager mManager
???????????
private ?boolean mSessionAlive
???????????
private ?java.util.TimerTask mTerminatorTask
???????????
private ?java.util.Timer mTimer
???????????
?
Constructor Summary
SessionTerminator(SessionManager?manager)
??????????Constructs a SessionTerminator that uses the specified session manager.
?
Method Summary
private ?java.util.TimerTask createTimerTask(InternalSession?session)
??????????Creates a TimerTask that will terminate a session.
?void sessionCleanedUp(SessionEvent?event)
??????????Invoked when a session is cleaned up during its termination.
?void sessionJoined(SessionEvent?event)
??????????Invoked when a session participant joins a session.
?void sessionLeft(SessionEvent?event)
??????????Invoked when a session participant leaves a session.
private ?void terminateSession(InternalSession?session)
??????????Terminates the specified session and logs an error if one occurs.
?
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
?

Field Detail

COPYRIGHT_NOTICE

private static final java.lang.String COPYRIGHT_NOTICE
See Also:
Constant Field Values

LOG

private static final DAILogger LOG

mTimer

private final java.util.Timer mTimer

mTerminatorTask

private java.util.TimerTask mTerminatorTask

mManager

private final SessionManager mManager

mSessionAlive

private boolean mSessionAlive
Constructor Detail

SessionTerminator

public SessionTerminator(SessionManager?manager)
Constructs a SessionTerminator that uses the specified session manager.

Parameters:
manager - The session manager to use for terminating the session when expiry occurs.
Method Detail

sessionJoined

public void sessionJoined(SessionEvent?event)
Description copied from interface: SessionListener
Invoked when a session participant joins a session.

Specified by:
sessionJoined in interface SessionListener
Parameters:
event - Describes the details of the event.

sessionLeft

public void sessionLeft(SessionEvent?event)
Description copied from interface: SessionListener
Invoked when a session participant leaves a session.

Specified by:
sessionLeft in interface SessionListener
Parameters:
event - Describes the details of the event.

sessionCleanedUp

public void sessionCleanedUp(SessionEvent?event)
Description copied from interface: SessionListener
Invoked when a session is cleaned up during its termination.

Specified by:
sessionCleanedUp in interface SessionListener
Parameters:
event - Describes the details of the event.

createTimerTask

private java.util.TimerTask createTimerTask(InternalSession?session)
Creates a TimerTask that will terminate a session.

Parameters:
session - The session that the TimerTask will terminate.
Returns:
the TimerTask.

terminateSession

private void terminateSession(InternalSession?session)
Terminates the specified session and logs an error if one occurs.

Parameters:
session - The session to terminate.