org.nanocontainer.nanowar
Class NanoWarContextListener

java.lang.Object
  extended by org.nanocontainer.nanowar.AbstractNanoWarListener
      extended by org.nanocontainer.nanowar.NanoWarContextListener
All Implemented Interfaces:
Serializable, EventListener, javax.servlet.ServletContextListener, KeyConstants

public class NanoWarContextListener
extends AbstractNanoWarListener
implements javax.servlet.ServletContextListener, KeyConstants

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

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

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: if one is interested in both application-scoped and session-scoped components, the org.nanocontainer.nanowar.ServletContainerLister should be configured in the web.xml.

Author:
Michael Rimov, Joe Walnes, Aslak Hellesøy, Philipp Meier, Paul Hammant, Mauro Talevi, Konstantin Pribluda
See Also:
NanoWarSessionListener, ServletContainerListener, 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
NanoWarContextListener()
           
 
Method Summary
 void contextDestroyed(javax.servlet.ServletContextEvent event)
           
 void contextInitialized(javax.servlet.ServletContextEvent event)
           
 
Methods inherited from class org.nanocontainer.nanowar.AbstractNanoWarListener
buildContainer, killContainer
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

NanoWarContextListener

public NanoWarContextListener()
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


Copyright © 2003-2009 Codehaus. All Rights Reserved.