avalon-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mcconn...@apache.org
Subject cvs commit: avalon-sandbox/merlin/merlin-smp/xdocs/extensions/servlet navigation.xml index.xml
Date Tue, 08 Apr 2003 08:59:19 GMT
mcconnell    2003/04/08 01:59:19

  Added:       merlin/merlin-smp/xdocs/extensions/servlet navigation.xml
                        index.xml
  Log:
  Inital commit of the documentation supportinig the Merlin Servlet implementation.
  
  Revision  Changes    Path
  1.1                  avalon-sandbox/merlin/merlin-smp/xdocs/extensions/servlet/navigation.xml
  
  Index: navigation.xml
  ===================================================================
  <?xml version="1.0" encoding="UTF-8"?>
  <project>
   <title>Merlin</title>
  
   <body>
  
      <links>
        <item name="Avalon" href="http://avalon.apache.org/"/>
        <item name="Excalibur" href="http://avalon.apache.org/excalibur"/>
      </links>
  
      <menu name="About Merlin">
        <item name="Overview" href="/about/index.html"/>
        <item name="Getting Started" href="/starting/index.html"/>
        <item name="Merlin System" href="/merlin/index.html"/>
        <item name="Meta Model" href="/meta/index.html"/>
        <item name="Tools" href="/tools/index.html"/>
      </menu>
  
      <menu name="Extensions">
        <item name="JNDI" href="/extensions/jndi/index.html"/>
        <item name="Servlet" href="/extensions/servlet/index.html"/>
      </menu>
  
   </body>
  
  </project>
  
  
  
  1.1                  avalon-sandbox/merlin/merlin-smp/xdocs/extensions/servlet/index.xml
  
  Index: index.xml
  ===================================================================
  <?xml version="1.0"?>
  
  <document>
  
    <properties>
      <title>Merlin Servlet</title>
      <author email="avalon-dev@jakarta.apache.org">Avalon Development Team</author>
    </properties>
  
    <body>
  
      <section name="Merlin Servlet">
  
  <p>
  The Merlin Servlet package contains an abstract Servlet implementation that contains an
embedded Merlin Kernel.
  </p>
  
      <subsection name="Development Notes">
  <p>
  This is an inimial implementation of a Servlet that contains an embedded kernel.  The behaviour
is a function of the block.xml resource resolved via the initialization parameters.  No support
is included for configuration of the kernel and as such the kernel is established relative
to defaults.  This will be enhanced in a leter revision.
  </p>
  
      </subsection>
      <subsection name="Example web.xml">
        <p><i>web.xml</i></p>
  <source><![CDATA[
  <!DOCTYPE web-app 
      PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN" 
      "http://java.sun.com/dtd/web-app_2_3.dtd">
  
  <web-app>
  
    <display-name>Merlin Servlet</display-name>
  
    <description>
      Merlin Servlet Test Page.
    </description>
  
    <servlet>
      <servlet-name>merlin</servlet-name>
      <servlet-class>org.apache.avalon.merlin.servlet.TestServlet</servlet-class>
      <init-param>
        <param-name>block</param-name>
        <param-value>/BLOCK-INF/block.xml</param-value>
      </init-param>
      <load-on-startup>1</load-on-startup>
    </servlet>
  </web-app>
  ]]></source>
  
      </subsection>
      <subsection name="Servlet Implementation">
        <p><i>MerlinServlet.java</i></p>
  <source>
  package org.apache.avalon.merlin.servlet;
  
  import java.io.File;
  import java.net.URL;
  import java.io.IOException;
  
  import javax.servlet.ServletException;
  import javax.servlet.ServletRequest;
  import javax.servlet.ServletResponse;
  import javax.servlet.http.HttpServlet;
  
  import org.apache.avalon.assembly.locator.DefaultLocator;
  import org.apache.avalon.merlin.block.Block;
  import org.apache.avalon.merlin.kernel.Kernel;
  import org.apache.avalon.merlin.kernel.impl.DefaultKernel;
  
  /**
   * Servlet implementing the Merlin Kernel interface.
   *
   * @author <a href="mailto:mcconnell@apache.org">Stephen McConnell</a>
   */
  public class MerlinServlet extends HttpServlet implements Kernel
  {
      private DefaultKernel m_kernel;
  
      /**
       * Initializes Servlet by the web server container.
       *
       * @exception ServletException if an error occurs
       */
      public void init()
          throws ServletException
      {
          try
          {
              ClassLoader loader = Thread.currentThread().getContextClassLoader();
  
              String homePath = getServletContext().getRealPath( "." );
              File home = new File( homePath );
  
              String blockPath = getInitParameter( "block", "BLOCK-INF/block.xml" );
              URL block = new File( home, blockPath ).toURL();
  
              DefaultLocator context = new DefaultLocator();
              context.put( "urn:merlin:home", home );
              context.put( "urn:merlin:system", home );
              context.put( "urn:merlin:classloader.common", loader );
              context.put( "urn:merlin:classloader.system", loader );
              context.put( "urn:merlin:debug", "WARN" );
              context.put( "urn:merlin:logging.priority", "INFO" );
              context.put( "urn:merlin:block.url", block );
              context.makeReadOnly();
  
              m_kernel = new DefaultKernel();
              m_kernel.contextualize( context );
              m_kernel.initialize();
  
              log( "kernel established" );
          }
          catch( Exception e )
          {
              throw new ServletException( "Initialization error.", e );
          }
      }
  
  
  
     /**
      * Return the root block.
      * @return the root block
      */
      public Block getRootBlock()
      {
          if( m_kernel == null ) 
          {
              final String message = 
                "Kernel has not been initialized.";
              throw new IllegalStateException( message );
          }
          return m_kernel.getRootBlock();
      }
  
     /**
      * Initiate an orderly shutdown of the kernel.
      */
      public void shutdown()
      {
          if( m_kernel == null ) 
          {
              final String message = 
                "Kernel has not been initialized.";
              throw new IllegalStateException( message );
          }
          m_kernel.shutdown();
      }
  
      /**
       * Disposes of container manager and container instance.
       */
      public void destroy()
      {
          if( m_kernel != null )
          { 
              m_kernel.shutdown();
              m_kernel = null;
          }
      }
  
      private String getInitParameter( final String name, final String defaultValue )
      {
          final String value = getInitParameter( name );
          if ( null == value )
          {
              return defaultValue;
          }
          else
          {
              return value;
          }
      }
  }
  </source>
        </subsection>
      </section>
    </body>
  
    <footer>
      <legal>
        Copyright (c) @year@ The Avalon Apache Project All rights reserved.
        $Revision: 1.1 $ $Date: 2003/04/08 08:59:19 $
      </legal>
    </footer>
  
  </document>
  
  
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: cvs-unsubscribe@avalon.apache.org
For additional commands, e-mail: cvs-help@avalon.apache.org


Mime
View raw message