org.nanocontainer.nanowar
Class ServletContainerListener

java.lang.Object
  extended byorg.nanocontainer.nanowar.ServletContainerListener
All Implemented Interfaces:
EventListener, javax.servlet.http.HttpSessionListener, KeyConstants, Serializable, javax.servlet.ServletContextListener

public class ServletContainerListener
extends Object
implements javax.servlet.ServletContextListener, javax.servlet.http.HttpSessionListener, KeyConstants, Serializable

Servlet listener class that hooks into the underlying servlet container and instantiates, assembles, starts, stores and disposes the appropriate pico containers when applications/sessions start/stop.

To use, simply add as a listener to web.xml the listener-class org.nanocontainer.nanowar.ServletContainerListener.

The containers are configured via context-params in web.xml, in two ways:

  1. A NanoContainer script via a parameter whose name is nanocontainer., where is one of the supported scripting languages, see ScriptedContainerBuilderFactory. The parameter value can be either an inlined script (enclosed in ), or a resource path for the script (relative to the webapp context).
  2. A ContainerComposer class via the parameter name CONTAINER_COMPOSER, which can be configured via an optional parameter CONTAINER_COMPOSER_CONFIGURATION.

Note: This listener simply delegates to NanoWarContextListener and NanoWarSessionListener. The application-level listeners can also be configured separately in web.xml if one is interested in application-scoped components only or has issues with session-scoped components (serialization, clustering, etc).

Author:
Joe Walnes, Aslak Hellesøy, Philipp Meier, Paul Hammant, Mauro Talevi, Konstantin Pribluda
See Also:
NanoWarContextListener, NanoWarSessionListener, Serialized Form

Field Summary
 
Fields inherited from interface org.nanocontainer.nanowar.KeyConstants
ACTIONS_CONTAINER, APPLICATION_CONTAINER, BUILDER, CONTAINER_COMPOSER, CONTAINER_COMPOSER_CONFIGURATION, KILLER_HELPER, NANOCONTAINER_PREFIX, REQUEST_CONTAINER, SESSION_CONTAINER
 
Constructor Summary
ServletContainerListener()
           
 
Method Summary
protected  org.picocontainer.PicoContainer buildContainer(org.nanocontainer.script.ScriptedContainerBuilder builder)
          Deprecated. Use NanoWarContextListener.buildContainer() instead.
 void contextDestroyed(javax.servlet.ServletContextEvent event)
           
 void contextInitialized(javax.servlet.ServletContextEvent event)
           
 void sessionCreated(javax.servlet.http.HttpSessionEvent event)
           
 void sessionDestroyed(javax.servlet.http.HttpSessionEvent event)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ServletContainerListener

public ServletContainerListener()
Method Detail

contextInitialized

public void contextInitialized(javax.servlet.ServletContextEvent event)
Specified by:
contextInitialized in interface javax.servlet.ServletContextListener

contextDestroyed

public void contextDestroyed(javax.servlet.ServletContextEvent event)
Specified by:
contextDestroyed in interface javax.servlet.ServletContextListener

sessionCreated

public void sessionCreated(javax.servlet.http.HttpSessionEvent event)
Specified by:
sessionCreated in interface javax.servlet.http.HttpSessionListener

sessionDestroyed

public void sessionDestroyed(javax.servlet.http.HttpSessionEvent event)
Specified by:
sessionDestroyed in interface javax.servlet.http.HttpSessionListener

buildContainer

protected org.picocontainer.PicoContainer buildContainer(org.nanocontainer.script.ScriptedContainerBuilder builder)
Deprecated. Use NanoWarContextListener.buildContainer() instead.

Parameters:
builder - ScriptedContainerBuilder
Returns:
PicoContainer


Copyright © 2003-2006 Codehaus. All Rights Reserved.