SPT Core API

com.sptci.echo.http
Class ContextListener

java.lang.Object
  extended by com.sptci.echo.http.ContextListener
All Implemented Interfaces:
EventListener, HttpSessionListener, ServletContextListener
Direct Known Subclasses:
JDOApplicationListener

public abstract class ContextListener
extends Object
implements ServletContextListener, HttpSessionListener

A ServletContextListener and HttpSessionListener to close any resources that are held by the Application instance or its subclasses.

© Copyright 2006 Sans Pareil Technologies, Inc.

Version:
$Id: ContextListener.java 4856 2009-08-11 15:22:46Z rakesh $
Author:
Rakesh Vidyadharan 2006-12-28

Field Summary
protected static Logger logger
          The logger to use to log messages to.
static String SESSION_KEY
          The session key associated with the echo application.
 
Constructor Summary
ContextListener()
           
 
Method Summary
protected abstract  void close()
          Close or cleanup any resources when the context is destroyed.
protected abstract  void close(HttpSession session)
          Close any resources associated with the session.
 void contextDestroyed(ServletContextEvent event)
          Iterate over collection of sessions and invalidate them.
 void contextInitialized(ServletContextEvent event)
          
protected  Application getApplication(HttpSession httpSession)
          Return the application instance associated with the specified session.
 void sessionCreated(HttpSessionEvent event)
          Add the session to the collection of sessions.
 void sessionDestroyed(HttpSessionEvent event)
          Close any resources associated with the session.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

SESSION_KEY

public static final String SESSION_KEY
The session key associated with the echo application. "EchoUserInstance:servlet"

See Also:
Constant Field Values

logger

protected static final Logger logger
The logger to use to log messages to.

Constructor Detail

ContextListener

public ContextListener()
Method Detail

contextInitialized

public void contextInitialized(ServletContextEvent event)

Specified by:
contextInitialized in interface ServletContextListener

contextDestroyed

public void contextDestroyed(ServletContextEvent event)
Iterate over collection of sessions and invalidate them.

Specified by:
contextDestroyed in interface ServletContextListener

sessionCreated

public void sessionCreated(HttpSessionEvent event)
Add the session to the collection of sessions.

Specified by:
sessionCreated in interface HttpSessionListener

sessionDestroyed

public void sessionDestroyed(HttpSessionEvent event)
Close any resources associated with the session.

Specified by:
sessionDestroyed in interface HttpSessionListener
See Also:
close(javax.servlet.http.HttpSession)

getApplication

protected Application getApplication(HttpSession httpSession)
Return the application instance associated with the specified session.

Parameters:
httpSession - The session for which the application instance is to be retrieved.
Returns:
The application instance associated with the session or null if no application instance is associated.

close

protected abstract void close(HttpSession session)
Close any resources associated with the session. Sub-classes must over-ride this method.

Parameters:
session - The session in which the connection was established.

close

protected abstract void close()
Close or cleanup any resources when the context is destroyed.


SPT Core API