Class ExcaliburComponentManagerServlet

  extended byjavax.servlet.GenericServlet
      extended byorg.apache.avalon.excalibur.component.servlet.ExcaliburComponentManagerServlet
All Implemented Interfaces:, javax.servlet.Servlet, javax.servlet.ServletConfig

Deprecated. ECM is no longer supported

public class ExcaliburComponentManagerServlet
extends javax.servlet.GenericServlet

Makes it possible for servlets to work with Avalon components without having to do any coding to setup and manage the lifecycle of the ServiceManager (ComponentManager).

To make use of the ExcaliburComponentManagerServet. You will need to define the servlet in your web.xml file as follows:

  <!-- ExcaliburComponentManagerServlet (for initializing ComponentManager).   -->
      <description>Creates component manager, does not service requests.</description>

      <!-- This parameter points to the logkit configuration file.             -->
      <!-- Note that the path is specified in absolute notation but it will be -->
      <!-- resolved relative to the servlets webapp context path               -->

      <!-- This parameter points to the components configuration file.         -->

      <!-- Roles file supplements configuration file to make the latter        -->
      <!-- more readable. Most likely you don't want to change the roles       -->
      <!-- file -->

      <!-- This parameter points to the instrument manager configuration file. -->

Please pay particular attention to the load-on-startup element. It is used to control the order in which servlets are started by the servlet engine. It must have a value which is less than any other servlets making use of the ServiceManager. This is to ensure that the ServiceManager is initialized before any other servlets attempt to start using it.

All of the configuration files are located in the WEB-INF directory by default. The instrument configuration file is optional. Please see the ExcaliburComponentManagerCreator class for details on what goes into these configuration files. Note that the lifecycle of the ExcaliburComponentManagerCreator is managed automatically by this servlet, so there is no need to access the class directly.

Once the servlet has been configured, other servlets may gain access to the ServiceManager (ComponentManager), InstrumentManager and LoggerManager via the ServletContext using the following code within a servlet:

  // Get a reference to the ServletContext
  ServletContext servletContext = getServletContext();

  // Acquire the LoggerManager
  LoggerManager loggerManager =
      (LoggerManager)m_servletContext.getAttribute( LoggerManager.class.getName() );

  // Acquire the InstrumentManager
  InstrumentManager instrumentManager =
      (InstrumentManager)m_servletContext.getAttribute( InstrumentManager.class.getName() );

  // Acquire the ServiceManager
  ServiceManager serviceManager =
      (ServiceManager)m_servletContext.getAttribute( ServiceManager.class.getName() );

  // Acquire the ComponentManager ( Deprecated )
  ComponentManager componentManager =
      (ComponentManager)m_servletContext.getAttribute( ComponentManager.class.getName() );
The ExcaliburComponentManagerServlet makes use of a proxy system to manage reference to the above managers, so it is not necessary to release them when a servlet is done using them.

It may be necessary to add the following code to the end of the dispose method of any servlets referencing any of the above proxies. This is because on some containers, like Tomcat, the classloader is immediately invalidated after the last servlet is disposed. If this happens before the managers have all been disposed, then you may see errors in the console like: WebappClassLoader: Lifecycle error : CL stopped

  catch ( InterruptedException e ) {}
Note that servlets which extend the AbstractComponentManagerServlet will behave correctly.

CVS $Revision: 1.4 $ $Date: 2004/02/28 11:47:16 $
Avalon Development Team
See Also:
Serialized Form

Constructor Summary
Method Summary
 void destroy()
          Deprecated. Called by the servlet container to destroy the servlet.
 void init(javax.servlet.ServletConfig servletConfig)
          Deprecated. Builds the component manager and stores references to the ComponentManager, LoggerManager, and InstrumentManager into the ServletContext.
 void service(javax.servlet.ServletRequest servletRequest, javax.servlet.ServletResponse servletResponse)
          Deprecated. This servlet does not accept requests.
Methods inherited from class javax.servlet.GenericServlet
getInitParameter, getInitParameterNames, getServletConfig, getServletContext, getServletInfo, getServletName, init, log, log
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

Constructor Detail


public ExcaliburComponentManagerServlet()
Method Detail


public void init(javax.servlet.ServletConfig servletConfig)
          throws javax.servlet.ServletException
Builds the component manager and stores references to the ComponentManager, LoggerManager, and InstrumentManager into the ServletContext.

servletConfig - Servlet configuration
javax.servlet.ServletException - If there are any problems initializing the servlet.


public void destroy()
Called by the servlet container to destroy the servlet.


public void service(javax.servlet.ServletRequest servletRequest,
                    javax.servlet.ServletResponse servletResponse)
             throws javax.servlet.UnavailableException
This servlet does not accept requests. It will complain if called.

javax.servlet.UnavailableException - always

Copyright © 1997-2005 The Apache Software Foundation. All Rights Reserved.