cvs commit: spice/sandbox/jervlet/jervlet-jetty/src/java/org/jcomponent/jervlet/blocks/jetty JettyJervlet.java NullRequestLogger.java JervletServletHolder.java JettyRequestLogAdapter.java PhoenixLogSink.java JervletWebApplicationHandler.java NCSARequestLogger.java WebApplicationContextHolder.java RequestLogger.java JervletWebApplicationContext.java

Ryan Hoegg <[email protected]>
Newsgroups gmane.comp.java.spice.cvs
Message-ID <[email protected]>
rhoegg      03/10/27 21:07:35

  Added:       sandbox/jervlet/jervlet-jetty/src/java/org/jcomponent/jervlet/blocks/jetty
                        JettyJervlet.java NullRequestLogger.java
                        JervletServletHolder.java
                        JettyRequestLogAdapter.java PhoenixLogSink.java
                        JervletWebApplicationHandler.java
                        NCSARequestLogger.java
                        WebApplicationContextHolder.java RequestLogger.java
                        JervletWebApplicationContext.java
  Log:
  Initial commit.
  
  Revision  Changes    Path
  1.1                  spice/sandbox/jervlet/jervlet-jetty/src/java/org/jcomponent/jervlet/blocks/jetty/JettyJervlet.java
  
  Index: JettyJervlet.java
  ===================================================================
  /*
  
   ============================================================================
                     The Apache Software License, Version 1.1
   ============================================================================
  
   Copyright (C) 2002,2003 The Apache Software Foundation. All rights reserved.
  
   Redistribution and use in source and binary forms, with or without modifica-
   tion, are permitted provided that the following conditions are met:
  
   1. Redistributions of  source code must  retain the above copyright  notice,
      this list of conditions and the following disclaimer.
  
   2. Redistributions in binary form must reproduce the above copyright notice,
      this list of conditions and the following disclaimer in the documentation
      and/or other materials provided with the distribution.
  
   3. The end-user documentation included with the redistribution, if any, must
      include  the following  acknowledgment:  "This product includes  software
      developed  by the  Apache Software Foundation  (http://www.apache.org/)."
      Alternately, this  acknowledgment may  appear in the software itself,  if
      and wherever such third-party acknowledgments normally appear.
  
   4. The names "Jakarta", "Avalon", "Excalibur" and "Apache Software Foundation"
      must not be used to endorse or promote products derived from this  software
      without  prior written permission. For written permission, please contact
      [email protected]
  
   5. Products  derived from this software may not  be called "Apache", nor may
      "Apache" appear  in their name,  without prior written permission  of the
      Apache Software Foundation.
  
   THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
   INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
   FITNESS  FOR A PARTICULAR  PURPOSE ARE  DISCLAIMED.  IN NO  EVENT SHALL  THE
   APACHE SOFTWARE  FOUNDATION  OR ITS CONTRIBUTORS  BE LIABLE FOR  ANY DIRECT,
   INDIRECT, INCIDENTAL, SPECIAL,  EXEMPLARY, OR CONSEQUENTIAL  DAMAGES (INCLU-
   DING, BUT NOT LIMITED TO, PROCUREMENT  OF SUBSTITUTE GOODS OR SERVICES; LOSS
   OF USE, DATA, OR  PROFITS; OR BUSINESS  INTERRUPTION)  HOWEVER CAUSED AND ON
   ANY  THEORY OF LIABILITY,  WHETHER  IN CONTRACT,  STRICT LIABILITY,  OR TORT
   (INCLUDING  NEGLIGENCE OR  OTHERWISE) ARISING IN  ANY WAY OUT OF THE  USE OF
   THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  
   This software  consists of voluntary contributions made  by many individuals
   on  behalf of the Apache Software  Foundation. For more  information on the
   Apache Software Foundation, please see <http://www.apache.org/>.
  
  */
  package org.jcomponent.jervlet.blocks.jetty;
  
  import java.io.File;
  import java.util.HashMap;
  import java.util.Set;
  import java.util.Collections;
  import java.net.UnknownHostException;
  
  import org.jcomponent.jervlet.Jervlet;
  import org.jcomponent.jervlet.JervletContext;
  import org.jcomponent.jervlet.JervletException;
  import org.apache.avalon.framework.CascadingRuntimeException;
  import org.apache.avalon.framework.activity.Initializable;
  import org.apache.avalon.framework.activity.Startable;
  import org.apache.avalon.framework.configuration.Configurable;
  import org.apache.avalon.framework.configuration.Configuration;
  import org.apache.avalon.framework.configuration.ConfigurationException;
  import org.apache.avalon.framework.context.Context;
  import org.apache.avalon.framework.context.ContextException;
  import org.apache.avalon.framework.context.Contextualizable;
  import org.apache.avalon.framework.logger.AbstractLogEnabled;
  import org.apache.avalon.framework.service.ServiceException;
  import org.apache.avalon.framework.service.ServiceManager;
  import org.apache.avalon.framework.service.Serviceable;
  
  import org.mortbay.http.SocketListener;
  import org.mortbay.jetty.Server;
  import org.mortbay.util.Log;
  import org.mortbay.util.MultiException;
  
  /**
   * @phoenix:block
   * @phoenix:service name="org.jcomponent.jervlet.Jervlet"
   * @phoenix:mx-topic name="ServletContainer"
   *
   * Jetty Wrapper.
   *
   *
   * @see <a href="http://jetty.mortbay.com/">Jetty Project Page</a>
   *
   * @author  Paul Hammant
   * @author  Ulrich Mayring
   * @author  Peter Royal
   * @author  Ryan Hoegg
   * @version 1.0
   */
  public class JettyJervlet extends AbstractLogEnabled
      implements Jervlet, Startable, Contextualizable, Configurable, Initializable, Serviceable
  {
      private Server m_server;
  
      /** Virtual host to bind the Jetty to.  null implies all hosts are in context. */
      private String m_hostName;
  
      private HashMap m_webcontexts = new HashMap();
      private int m_port;
      private int m_minThreads;
      private int m_maxThreads;
      private boolean m_extractWebArchive;
      private File m_sarRootDir;
      private JervletContext m_jervletContext;
      private Context m_context;
  
      /**
       * @param serviceManager
       * @throws ServiceException
       *
       * @phoenix:dependency name="org.jcomponent.jervlet.blocks.jetty.RequestLogger"
       */
      public void service( ServiceManager serviceManager ) throws ServiceException
      {
          m_jervletContext = new JervletContext( m_context, serviceManager, getLogger() );
      }
  
      /**
       * Contextualize
       * @param context the context
       */
      public void contextualize( final Context context ) throws ContextException
      {
          m_context = context;
          m_sarRootDir = (File)context.get( "app.home" );
      }
  
      /**
       * Configure
       * @param configuration the configuration
       * @throws ConfigurationException if a problem
       *
       * @phoenix:configuration-schema type="http://relaxng.org/ns/structure/1.0"
       */
      public void configure( final Configuration configuration ) throws ConfigurationException
      {
          m_hostName = configuration.getChild( "hostname" ).getValue( null );
          m_port = configuration.getChild( "port" ).getValueAsInteger( 8080 );
          m_minThreads = configuration.getChild( "minthreads" ).getValueAsInteger( 5 );
          m_maxThreads = configuration.getChild( "maxthreads" ).getValueAsInteger( 250 );
          m_extractWebArchive = configuration.getChild( "extract-war" ).getValueAsBoolean( true );
  
          if( m_maxThreads < m_minThreads )
          {
              throw new ConfigurationException( "maxthreads must be greater than minthreads" );
          }
      }
  
      /**
       * Initialize
       * @throws Exception if a problem
       */
      public void initialize() throws Exception
      {
          m_server = createHttpServer();
          m_server.addListener( createSocketListener() );
  
          PhoenixLogSink phoenixLogSink = new PhoenixLogSink();
          phoenixLogSink.enableLogging( getLogger() );
          Log.instance().add( phoenixLogSink );
  
          RequestLogger logger = (RequestLogger)
              m_jervletContext.getServiceManager().lookup( RequestLogger.ROLE );
          m_server.setRequestLog( new JettyRequestLogAdapter( logger ) );
      }
  
      protected Server createHttpServer()
      {
          return new Server();
      }
  
      private SocketListener createSocketListener() throws UnknownHostException
      {
          SocketListener listener = new SocketListener();
  
          if( null != m_hostName )
          {
              listener.setHost( m_hostName );
          }
  
          listener.setPort( m_port );
          listener.setMinThreads( m_minThreads );
          listener.setMaxThreads( m_maxThreads );
          return listener;
      }
  
      /**
       * Start
       */
      public final void start()
      {
          try
          {
              m_server.start();
          }
          catch( MultiException e )
          {
              throw new CascadingRuntimeException( "Some problem starting Jetty", e );
          }
      }
  
      /**
       * Stop
       */
      public void stop()
      {
          try
          {
              m_server.stop();
          }
          catch( InterruptedException e )
          {
              throw new CascadingRuntimeException( "Some problem stopping Jetty", e );
          }
      }
  
      /**
       * Deploy a webapp
       * @param context the contxct for the webapp
       * @param pathToWebAppFolder the path to it
       * @throws JervletException if a problem
       */
      public void deploy( String context, File pathToWebAppFolder ) throws JervletException
      {
          deploy( context, pathToWebAppFolder, m_jervletContext );
      }
  
      /**
       * Deploy a webapp
       * @param context the contxct for the webapp
       * @param pathToWebAppFolder the path to it
       * @param jervletContext The optional context to apply to servlets (LogEnabled, Serviceable).
       * @throws JervletException if a problem
       */
      public void deploy( String context, File pathToWebAppFolder, JervletContext jervletContext )
          throws JervletException
      {
          if( m_webcontexts.containsKey( context ) )
          {
              throw new JervletException( "Context '" + context + "' has already been deployed" );
          }
  
          WebApplicationContextHolder holder;
  
          try
          {
              holder = new WebApplicationContextHolder( context,
                                                        pathToWebAppFolder,
                                                        jervletContext,
                                                        m_sarRootDir,
                                                        m_extractWebArchive );
              m_webcontexts.put( context, holder );
          }
          catch( Exception e )
          {
              final String msg = "Problem deploying web application (" + pathToWebAppFolder
                  + ") in Jetty";
  
              throw new JervletException( msg, e );
          }
  
          deploy( context );
      }
  
      /**
       * Get a list of all webapps currently installed with the container
       *
       * @phoenix:mx-attribute
       *
       * @return The list of all contexts installed in the container
       */
      public Set getContextList()
      {
          return Collections.unmodifiableSet( m_webcontexts.keySet() );
      }
  
      /**
       * Get the status of an installed webapp
       *
       * @phoenix:mx-operation
       *
       * @param context webapp to get status of
       * @return status of webapp
       * @throws JervletException if any problems occur
       */
      public String getStatus( String context ) throws JervletException
      {
          final WebApplicationContextHolder holder = getWebApplicationContextHolder( context );
  
          return holder.getStatus();
      }
  
      /**
       * Start a stopped webapp
       *
       * @phoenix:mx-operation
       *
       * @param context webapp to start
       * @throws JervletException if any problems occur
       */
      public void start( String context ) throws JervletException
      {
          final WebApplicationContextHolder holder = getWebApplicationContextHolder( context );
  
          try
          {
              holder.start();
          }
          catch( Exception e )
          {
              final String msg = "Unable to start '" + context + "' : " + e.getMessage();
              getLogger().error( msg, e );
              throw new JervletException( msg, e );
          }
      }
  
      /**
       * Stop a running webapp
       *
       * @phoenix:mx-operation
       *
       * @param context webapp to stop
       * @throws JervletException if any problems occur
       */
      public void stop( String context ) throws JervletException
      {
          final WebApplicationContextHolder holder = getWebApplicationContextHolder( context );
  
          try
          {
              holder.stop();
          }
          catch( Exception e )
          {
              final String msg = "Unable to stop '" + context + "' : " + e.getMessage();
              getLogger().error( msg, e );
              throw new JervletException( msg, e );
          }
      }
  
      /**
       * Redeploy a webapp. This operation fully reloads the webapp, and is equivalent to
       * doing undeploy() followed by deploy()
       *
       * @phoenix:mx-operation
       *
       * @param context webapp to reload
       * @throws JervletException if any problems occur
       */
      public void redeploy( String context ) throws JervletException
      {
          try
          {
              undeploy( context );
              deploy( context );
          }
          catch( JervletException e )
          {
              getLogger().error( "Exception restarting: " + context, e );
  
              throw e;
          }
      }
  
      /**
       * Deploy a webapp
       *
       * @phoenix:mx-operation
       *
       * @param context webapp to deploy
       * @throws JervletException if any problems occur
       */
      public void deploy( String context ) throws JervletException
      {
          final WebApplicationContextHolder holder = getWebApplicationContextHolder( context );
  
          //Set the context classloader because the current classloader will be that of the
          Thread.currentThread().setContextClassLoader( getClass().getClassLoader() );
  
          try
          {
              m_server.addContext( m_hostName, holder.create() );
  
              if( getLogger().isInfoEnabled() )
                  getLogger().info( "deploying context=" + context + ", webapp="
                                    + holder.getWebappUrl() + " to host="
                                    + ( m_hostName == null ? "(All Hosts)" : m_hostName ) );
  
              holder.start();
          }
          catch( Exception e )
          {
              final String msg = "Unable to deploy '" + context + "' : " + e.getMessage();
  
              getLogger().error( msg, e );
              throw new JervletException( msg, e );
          }
      }
  
      private WebApplicationContextHolder getWebApplicationContextHolder( String context )
          throws JervletException
      {
          WebApplicationContextHolder holder =
              (WebApplicationContextHolder)m_webcontexts.get( context );
  
          if( null == holder )
          {
              throw new JervletException( "Unknown context: " + context );
          }
  
          return holder;
      }
  
      /**
       * Start a stopped webapp
       *
       * @phoenix:mx-operation
       *
       * @param context webapp to start
       * @throws JervletException if any problems occur
       */
      public void undeploy( String context ) throws JervletException
      {
          final WebApplicationContextHolder holder = getWebApplicationContextHolder( context );
  
          try
          {
              holder.stop();
          }
          catch( InterruptedException e )
          {
              final String msg = "Problem stopping web application in Jetty";
  
              getLogger().error( msg, e );
  
              throw new JervletException( msg, e );
          }
  
          if( !m_server.removeContext( holder.getWebApplicationContext() ) )
          {
              getLogger().warn( "Potential problems removing context" );
          }
  
          try
          {
              holder.destroy();
          }
          catch( Exception e )
          {
              final String msg = "Problem destroying web application in Jetty";
  
              getLogger().error( msg, e );
  
              throw new JervletException( msg, e );
          }
      }
  }
  
  
  
  
  
  
  1.1                  spice/sandbox/jervlet/jervlet-jetty/src/java/org/jcomponent/jervlet/blocks/jetty/NullRequestLogger.java
  
  Index: NullRequestLogger.java
  ===================================================================
  /*
  
   ============================================================================
                     The Apache Software License, Version 1.1
   ============================================================================
  
   Copyright (C) 2002,2003 The Apache Software Foundation. All rights reserved.
  
   Redistribution and use in source and binary forms, with or without modifica-
   tion, are permitted provided that the following conditions are met:
  
   1. Redistributions of  source code must  retain the above copyright  notice,
      this list of conditions and the following disclaimer.
  
   2. Redistributions in binary form must reproduce the above copyright notice,
      this list of conditions and the following disclaimer in the documentation
      and/or other materials provided with the distribution.
  
   3. The end-user documentation included with the redistribution, if any, must
      include  the following  acknowledgment:  "This product includes  software
      developed  by the  Apache Software Foundation  (http://www.apache.org/)."
      Alternately, this  acknowledgment may  appear in the software itself,  if
      and wherever such third-party acknowledgments normally appear.
  
   4. The names "Jakarta", "Avalon", "Excalibur" and "Apache Software Foundation"
      must not be used to endorse or promote products derived from this  software
      without  prior written permission. For written permission, please contact
      [email protected]
  
   5. Products  derived from this software may not  be called "Apache", nor may
      "Apache" appear  in their name,  without prior written permission  of the
      Apache Software Foundation.
  
   THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
   INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
   FITNESS  FOR A PARTICULAR  PURPOSE ARE  DISCLAIMED.  IN NO  EVENT SHALL  THE
   APACHE SOFTWARE  FOUNDATION  OR ITS CONTRIBUTORS  BE LIABLE FOR  ANY DIRECT,
   INDIRECT, INCIDENTAL, SPECIAL,  EXEMPLARY, OR CONSEQUENTIAL  DAMAGES (INCLU-
   DING, BUT NOT LIMITED TO, PROCUREMENT  OF SUBSTITUTE GOODS OR SERVICES; LOSS
   OF USE, DATA, OR  PROFITS; OR BUSINESS  INTERRUPTION)  HOWEVER CAUSED AND ON
   ANY  THEORY OF LIABILITY,  WHETHER  IN CONTRACT,  STRICT LIABILITY,  OR TORT
   (INCLUDING  NEGLIGENCE OR  OTHERWISE) ARISING IN  ANY WAY OUT OF THE  USE OF
   THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  
   This software  consists of voluntary contributions made  by many individuals
   on  behalf of the Apache Software  Foundation. For more  information on the
   Apache Software Foundation, please see <http://www.apache.org/>.
  
  */
  package org.jcomponent.jervlet.blocks.jetty;
  
  import org.mortbay.http.HttpRequest;
  import org.mortbay.http.HttpResponse;
  
  /**
   * Ignores logging requests. To be used when request logging is not
   * necessary or performance is so critical that request logging is in
   * the way.
   *
   * @phoenix:block
   * @phoenix:service name="org.jcomponent.jervlet.blocks.jetty.RequestLogger"
   */
  public class NullRequestLogger implements RequestLogger
  {
      public void log( HttpRequest request, HttpResponse response, int responseLength )
      {
      }
  }
  
  
  
  1.1                  spice/sandbox/jervlet/jervlet-jetty/src/java/org/jcomponent/jervlet/blocks/jetty/JervletServletHolder.java
  
  Index: JervletServletHolder.java
  ===================================================================
  /*
  
   ============================================================================
                     The Apache Software License, Version 1.1
   ============================================================================
  
   Copyright (C) 2002,2003 The Apache Software Foundation. All rights reserved.
  
   Redistribution and use in source and binary forms, with or without modifica-
   tion, are permitted provided that the following conditions are met:
  
   1. Redistributions of  source code must  retain the above copyright  notice,
      this list of conditions and the following disclaimer.
  
   2. Redistributions in binary form must reproduce the above copyright notice,
      this list of conditions and the following disclaimer in the documentation
      and/or other materials provided with the distribution.
  
   3. The end-user documentation included with the redistribution, if any, must
      include  the following  acknowledgment:  "This product includes  software
      developed  by the  Apache Software Foundation  (http://www.apache.org/)."
      Alternately, this  acknowledgment may  appear in the software itself,  if
      and wherever such third-party acknowledgments normally appear.
  
   4. The names "Jakarta", "Avalon", "Excalibur" and "Apache Software Foundation"
      must not be used to endorse or promote products derived from this  software
      without  prior written permission. For written permission, please contact
      [email protected]
  
   5. Products  derived from this software may not  be called "Apache", nor may
      "Apache" appear  in their name,  without prior written permission  of the
      Apache Software Foundation.
  
   THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
   INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
   FITNESS  FOR A PARTICULAR  PURPOSE ARE  DISCLAIMED.  IN NO  EVENT SHALL  THE
   APACHE SOFTWARE  FOUNDATION  OR ITS CONTRIBUTORS  BE LIABLE FOR  ANY DIRECT,
   INDIRECT, INCIDENTAL, SPECIAL,  EXEMPLARY, OR CONSEQUENTIAL  DAMAGES (INCLU-
   DING, BUT NOT LIMITED TO, PROCUREMENT  OF SUBSTITUTE GOODS OR SERVICES; LOSS
   OF USE, DATA, OR  PROFITS; OR BUSINESS  INTERRUPTION)  HOWEVER CAUSED AND ON
   ANY  THEORY OF LIABILITY,  WHETHER  IN CONTRACT,  STRICT LIABILITY,  OR TORT
   (INCLUDING  NEGLIGENCE OR  OTHERWISE) ARISING IN  ANY WAY OUT OF THE  USE OF
   THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  
   This software  consists of voluntary contributions made  by many individuals
   on  behalf of the Apache Software  Foundation. For more  information on the
   Apache Software Foundation, please see <http://www.apache.org/>.
  
  */
  package org.jcomponent.jervlet.blocks.jetty;
  
  import org.jcomponent.jervlet.JervletContext;
  import org.apache.avalon.framework.container.ContainerUtil;
  import org.apache.avalon.framework.logger.Logger;
  import org.apache.avalon.framework.service.ServiceManager;
  import org.mortbay.jetty.servlet.ServletHolder;
  
  /**
   *
   * Override for Jetty's ServletHolder allow custom servlet handling
   *
   *
   * @see <a href="http://jetty.mortbay.com/">Jetty Project Page</a>
   *
   * @author  Paul Hammant
   * @version 1.0
   */
  class JervletServletHolder extends ServletHolder
  {
      private JervletContext m_jervletContext;
  
      /**
       * Construct a Servlet Holder
       * @param jervletContext the context that is applied to the servlet on instantiation.
       * @param handler the handler
       * @param name the name
       * @param className the class name
       * @param forcedPath the forced path
       */
      public JervletServletHolder( JervletContext jervletContext,
                                 JervletWebApplicationHandler handler,
                                 String name,
                                 String className,
                                 String forcedPath )
      {
          // this constructor public or protected...
          super( handler, name, className, forcedPath );
          m_jervletContext = jervletContext;
      }
  
      /**
       * Create a new instance of a servlet, currently applying the following lifecycle:
       * If a servlet is Servicable then the serviceManager is set on the servlet.
       * If a servlet is LogEnabled then the logger is set on the servlet.
       * If a servlet is Initializable then the initialize method is invoked.
       * @return the instance
       * @throws InstantiationException if a prob
       * @throws IllegalAccessException if a prob
       */
      public synchronized Object newInstance() throws InstantiationException, IllegalAccessException
      {
          if( _class == null )
          {
              throw new InstantiationException( "No class for " + this );
          }
          else
          {
              final Logger logger = m_jervletContext.getLogger();
              Object instance = _class.newInstance();
  
              try
              {
                  ContainerUtil.enableLogging( instance, logger );
                  ContainerUtil.contextualize( instance, m_jervletContext.getContext() );
  
                  final ServiceManager manager = m_jervletContext.getServiceManager();
                  if( null != manager )
                  {
                      ContainerUtil.service( instance, manager );
                  }
  
                  ContainerUtil.initialize( instance );
              }
              catch( Exception e )
              {
                  final String msg = "Exception during lifecycle processing for servlet "
                      + _class.getName() + ":" + e.getMessage();
  
                  logger.error( msg, e );
  
                  throw new InstantiationException( msg );
              }
  
              return instance;
          }
      }
  }
  
  
  
  1.1                  spice/sandbox/jervlet/jervlet-jetty/src/java/org/jcomponent/jervlet/blocks/jetty/JettyRequestLogAdapter.java
  
  Index: JettyRequestLogAdapter.java
  ===================================================================
  /*
  
   ============================================================================
                     The Apache Software License, Version 1.1
   ============================================================================
  
   Copyright (C) 2002,2003 The Apache Software Foundation. All rights reserved.
  
   Redistribution and use in source and binary forms, with or without modifica-
   tion, are permitted provided that the following conditions are met:
  
   1. Redistributions of  source code must  retain the above copyright  notice,
      this list of conditions and the following disclaimer.
  
   2. Redistributions in binary form must reproduce the above copyright notice,
      this list of conditions and the following disclaimer in the documentation
      and/or other materials provided with the distribution.
  
   3. The end-user documentation included with the redistribution, if any, must
      include  the following  acknowledgment:  "This product includes  software
      developed  by the  Apache Software Foundation  (http://www.apache.org/)."
      Alternately, this  acknowledgment may  appear in the software itself,  if
      and wherever such third-party acknowledgments normally appear.
  
   4. The names "Jakarta", "Avalon", "Excalibur" and "Apache Software Foundation"
      must not be used to endorse or promote products derived from this  software
      without  prior written permission. For written permission, please contact
      [email protected]
  
   5. Products  derived from this software may not  be called "Apache", nor may
      "Apache" appear  in their name,  without prior written permission  of the
      Apache Software Foundation.
  
   THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
   INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
   FITNESS  FOR A PARTICULAR  PURPOSE ARE  DISCLAIMED.  IN NO  EVENT SHALL  THE
   APACHE SOFTWARE  FOUNDATION  OR ITS CONTRIBUTORS  BE LIABLE FOR  ANY DIRECT,
   INDIRECT, INCIDENTAL, SPECIAL,  EXEMPLARY, OR CONSEQUENTIAL  DAMAGES (INCLU-
   DING, BUT NOT LIMITED TO, PROCUREMENT  OF SUBSTITUTE GOODS OR SERVICES; LOSS
   OF USE, DATA, OR  PROFITS; OR BUSINESS  INTERRUPTION)  HOWEVER CAUSED AND ON
   ANY  THEORY OF LIABILITY,  WHETHER  IN CONTRACT,  STRICT LIABILITY,  OR TORT
   (INCLUDING  NEGLIGENCE OR  OTHERWISE) ARISING IN  ANY WAY OUT OF THE  USE OF
   THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  
   This software  consists of voluntary contributions made  by many individuals
   on  behalf of the Apache Software  Foundation. For more  information on the
   Apache Software Foundation, please see <http://www.apache.org/>.
  
  */
  package org.jcomponent.jervlet.blocks.jetty;
  
  import org.mortbay.http.HttpRequest;
  import org.mortbay.http.HttpResponse;
  import org.mortbay.http.RequestLog;
  
  /**
   * Adapts RequestLogger to Jetty RequestLog. Adapter provides empty
   * implementations of org.mortbay.util.LifeCycle methods. They are not
   * needed for our component that has its lifecycle managed in Avalon
   * container.
   */
  public class JettyRequestLogAdapter implements RequestLog
  {
      private final RequestLogger m_logger;
  
      public JettyRequestLogAdapter( RequestLogger logger )
      {
          m_logger = logger;
      }
  
      public final void log( HttpRequest request, HttpResponse response,
                             int responseLength )
      {
          m_logger.log( request, response, responseLength );
      }
  
      public void start()
      {
      }
  
      public void stop()
      {
      }
  
      public boolean isStarted()
      {
          return true;
      }
  }
  
  
  
  1.1                  spice/sandbox/jervlet/jervlet-jetty/src/java/org/jcomponent/jervlet/blocks/jetty/PhoenixLogSink.java
  
  Index: PhoenixLogSink.java
  ===================================================================
  /*
  
   ============================================================================
                     The Apache Software License, Version 1.1
   ============================================================================
  
   Copyright (C) 2002,2003 The Apache Software Foundation. All rights reserved.
  
   Redistribution and use in source and binary forms, with or without modifica-
   tion, are permitted provided that the following conditions are met:
  
   1. Redistributions of  source code must  retain the above copyright  notice,
      this list of conditions and the following disclaimer.
  
   2. Redistributions in binary form must reproduce the above copyright notice,
      this list of conditions and the following disclaimer in the documentation
      and/or other materials provided with the distribution.
  
   3. The end-user documentation included with the redistribution, if any, must
      include  the following  acknowledgment:  "This product includes  software
      developed  by the  Apache Software Foundation  (http://www.apache.org/)."
      Alternately, this  acknowledgment may  appear in the software itself,  if
      and wherever such third-party acknowledgments normally appear.
  
   4. The names "Jakarta", "Avalon", "Excalibur" and "Apache Software Foundation"
      must not be used to endorse or promote products derived from this  software
      without  prior written permission. For written permission, please contact
      [email protected]
  
   5. Products  derived from this software may not  be called "Apache", nor may
      "Apache" appear  in their name,  without prior written permission  of the
      Apache Software Foundation.
  
   THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
   INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
   FITNESS  FOR A PARTICULAR  PURPOSE ARE  DISCLAIMED.  IN NO  EVENT SHALL  THE
   APACHE SOFTWARE  FOUNDATION  OR ITS CONTRIBUTORS  BE LIABLE FOR  ANY DIRECT,
   INDIRECT, INCIDENTAL, SPECIAL,  EXEMPLARY, OR CONSEQUENTIAL  DAMAGES (INCLU-
   DING, BUT NOT LIMITED TO, PROCUREMENT  OF SUBSTITUTE GOODS OR SERVICES; LOSS
   OF USE, DATA, OR  PROFITS; OR BUSINESS  INTERRUPTION)  HOWEVER CAUSED AND ON
   ANY  THEORY OF LIABILITY,  WHETHER  IN CONTRACT,  STRICT LIABILITY,  OR TORT
   (INCLUDING  NEGLIGENCE OR  OTHERWISE) ARISING IN  ANY WAY OUT OF THE  USE OF
   THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  
   This software  consists of voluntary contributions made  by many individuals
   on  behalf of the Apache Software  Foundation. For more  information on the
   Apache Software Foundation, please see <http://www.apache.org/>.
  
  */
  package org.jcomponent.jervlet.blocks.jetty;
  
  import org.apache.avalon.framework.logger.AbstractLogEnabled;
  import org.mortbay.util.Frame;
  import org.mortbay.util.Log;
  import org.mortbay.util.LogSink;
  
  /**
   * Jetty Log redirection
   *
   *
   * @see <a href="http://jetty.mortbay.com/">Jetty Project Page</a>
   *
   * @author  Bruno Dumon & Paul Hammant
   * @version 1.0
   */
  public class PhoenixLogSink extends AbstractLogEnabled implements LogSink
  {
      /**
       * Stop (unimpled)
       * @throws InterruptedException
       */
      public void stop() throws InterruptedException
      {
      }
  
      /**
       * Is this started (always)
       * @return
       */
      public boolean isStarted()
      {
          return true;
      }
  
      /**
       * Set Options (un implemented)
       * @param s the options
       */
      public void setOptions( String s )
      {
      }
  
      /**
       * Get Option (unimplemented)
       * @return the options
       */
      public String getOptions()
      {
          return "";
      }
  
      /**
       * Log something
       * @param type the type of message
       * @param message the message
       * @param frame the frame
       * @param time the time
       */
      public void log( String type, Object message, Frame frame, long time )
      {
          if( type.equals( Log.DEBUG ) )
          {
              if( getLogger().isDebugEnabled() )
                  getLogger().debug( "time=" + time + " message=" + message + " frame=" + frame );
          }
          else if( type.equals( Log.FAIL ) )
          {
              if( getLogger().isErrorEnabled() )
                  getLogger().error( "time=" + time + " message=" + message + " frame=" + frame );
          }
          else if( type.equals( Log.WARN ) )
          {
              if( getLogger().isWarnEnabled() )
                  getLogger().warn( "time=" + time + " message=" + message + " frame=" + frame );
          }
          else if( type.equals( Log.ASSERT ) )
          {
              if( getLogger().isInfoEnabled() )
                  getLogger().info( "ASSERT time=" + time + " message=" + message + " frame=" + frame );
          }
          else
          {
              getLogger().info( "time=" + time + " message=" + message + " frame=" + frame );
          }
      }
  
      /**
       * Log a message
       * @param message the Message
       */
      public void log( String message )
      {
          getLogger().info( message );
      }
  
      /**
       * Start a logger (unimpled)
       * @throws Exception
       */
      public void start() throws Exception
      {
      }
  }
  
  
  
  1.1                  spice/sandbox/jervlet/jervlet-jetty/src/java/org/jcomponent/jervlet/blocks/jetty/JervletWebApplicationHandler.java
  
  Index: JervletWebApplicationHandler.java
  ===================================================================
  /*
  
   ============================================================================
                     The Apache Software License, Version 1.1
   ============================================================================
  
   Copyright (C) 2002,2003 The Apache Software Foundation. All rights reserved.
  
   Redistribution and use in source and binary forms, with or without modifica-
   tion, are permitted provided that the following conditions are met:
  
   1. Redistributions of  source code must  retain the above copyright  notice,
      this list of conditions and the following disclaimer.
  
   2. Redistributions in binary form must reproduce the above copyright notice,
      this list of conditions and the following disclaimer in the documentation
      and/or other materials provided with the distribution.
  
   3. The end-user documentation included with the redistribution, if any, must
      include  the following  acknowledgment:  "This product includes  software
      developed  by the  Apache Software Foundation  (http://www.apache.org/)."
      Alternately, this  acknowledgment may  appear in the software itself,  if
      and wherever such third-party acknowledgments normally appear.
  
   4. The names "Jakarta", "Avalon", "Excalibur" and "Apache Software Foundation"
      must not be used to endorse or promote products derived from this  software
      without  prior written permission. For written permission, please contact
      [email protected]
  
   5. Products  derived from this software may not  be called "Apache", nor may
      "Apache" appear  in their name,  without prior written permission  of the
      Apache Software Foundation.
  
   THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
   INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
   FITNESS  FOR A PARTICULAR  PURPOSE ARE  DISCLAIMED.  IN NO  EVENT SHALL  THE
   APACHE SOFTWARE  FOUNDATION  OR ITS CONTRIBUTORS  BE LIABLE FOR  ANY DIRECT,
   INDIRECT, INCIDENTAL, SPECIAL,  EXEMPLARY, OR CONSEQUENTIAL  DAMAGES (INCLU-
   DING, BUT NOT LIMITED TO, PROCUREMENT  OF SUBSTITUTE GOODS OR SERVICES; LOSS
   OF USE, DATA, OR  PROFITS; OR BUSINESS  INTERRUPTION)  HOWEVER CAUSED AND ON
   ANY  THEORY OF LIABILITY,  WHETHER  IN CONTRACT,  STRICT LIABILITY,  OR TORT
   (INCLUDING  NEGLIGENCE OR  OTHERWISE) ARISING IN  ANY WAY OUT OF THE  USE OF
   THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  
   This software  consists of voluntary contributions made  by many individuals
   on  behalf of the Apache Software  Foundation. For more  information on the
   Apache Software Foundation, please see <http://www.apache.org/>.
  
  */
  package org.jcomponent.jervlet.blocks.jetty;
  
  import org.jcomponent.jervlet.JervletContext;
  import org.mortbay.jetty.servlet.ServletHolder;
  import org.mortbay.jetty.servlet.WebApplicationHandler;
  
  /**
   *
   * Override for Jetty's WebApplicationHandler allow custom servlet handling
   *
   *
   * @see <a href="http://jetty.mortbay.com/">Jetty Project Page</a>
   *
   * @author  Paul Hammant
   * @version 1.0
   */
  class JervletWebApplicationHandler extends WebApplicationHandler
  {
  
      private JervletContext m_jervletContext;
  
      public JervletWebApplicationHandler( JervletContext jervletContext )
      {
          m_jervletContext = jervletContext;
      }
  
      public ServletHolder newServletHolder( String name, String servletClass, String forcedPath )
      {
          if( _nameMap.containsKey( name ) )
          {
              throw new IllegalArgumentException( "Named servlet already exists: " + name );
          }
          else
          {
              ServletHolder holder = new JervletServletHolder( m_jervletContext, this, name, servletClass, forcedPath );
              _nameMap.put( holder.getName(), holder );
              return holder;
          }
      }
  }
  
  
  
  1.1                  spice/sandbox/jervlet/jervlet-jetty/src/java/org/jcomponent/jervlet/blocks/jetty/NCSARequestLogger.java
  
  Index: NCSARequestLogger.java
  ===================================================================
  /*
  
   ============================================================================
                     The Apache Software License, Version 1.1
   ============================================================================
  
   Copyright (C) 2002,2003 The Apache Software Foundation. All rights reserved.
  
   Redistribution and use in source and binary forms, with or without modifica-
   tion, are permitted provided that the following conditions are met:
  
   1. Redistributions of  source code must  retain the above copyright  notice,
      this list of conditions and the following disclaimer.
  
   2. Redistributions in binary form must reproduce the above copyright notice,
      this list of conditions and the following disclaimer in the documentation
      and/or other materials provided with the distribution.
  
   3. The end-user documentation included with the redistribution, if any, must
      include  the following  acknowledgment:  "This product includes  software
      developed  by the  Apache Software Foundation  (http://www.apache.org/)."
      Alternately, this  acknowledgment may  appear in the software itself,  if
      and wherever such third-party acknowledgments normally appear.
  
   4. The names "Jakarta", "Avalon", "Excalibur" and "Apache Software Foundation"
      must not be used to endorse or promote products derived from this  software
      without  prior written permission. For written permission, please contact
      [email protected]
  
   5. Products  derived from this software may not  be called "Apache", nor may
      "Apache" appear  in their name,  without prior written permission  of the
      Apache Software Foundation.
  
   THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
   INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
   FITNESS  FOR A PARTICULAR  PURPOSE ARE  DISCLAIMED.  IN NO  EVENT SHALL  THE
   APACHE SOFTWARE  FOUNDATION  OR ITS CONTRIBUTORS  BE LIABLE FOR  ANY DIRECT,
   INDIRECT, INCIDENTAL, SPECIAL,  EXEMPLARY, OR CONSEQUENTIAL  DAMAGES (INCLU-
   DING, BUT NOT LIMITED TO, PROCUREMENT  OF SUBSTITUTE GOODS OR SERVICES; LOSS
   OF USE, DATA, OR  PROFITS; OR BUSINESS  INTERRUPTION)  HOWEVER CAUSED AND ON
   ANY  THEORY OF LIABILITY,  WHETHER  IN CONTRACT,  STRICT LIABILITY,  OR TORT
   (INCLUDING  NEGLIGENCE OR  OTHERWISE) ARISING IN  ANY WAY OUT OF THE  USE OF
   THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  
   This software  consists of voluntary contributions made  by many individuals
   on  behalf of the Apache Software  Foundation. For more  information on the
   Apache Software Foundation, please see <http://www.apache.org/>.
  
  */
  package org.jcomponent.jervlet.blocks.jetty;
  
  import java.util.Locale;
  import java.util.TimeZone;
  import org.apache.avalon.framework.activity.Initializable;
  import org.apache.avalon.framework.logger.AbstractLogEnabled;
  import org.mortbay.http.HttpRequest;
  import org.mortbay.http.HttpResponse;
  import org.mortbay.util.DateCache;
  
  /**
   * Logs request information in NCSA (== apache httpd) format. The
   * contents of log() method was copied with permission from
   * org.mortbay.http.NCSARequestLog.log.
   *
   * @phoenix:block
   * @phoenix:service name="org.jcomponent.jervlet.blocks.jetty.RequestLogger"
   */
  public class NCSARequestLogger extends AbstractLogEnabled
      implements Initializable, RequestLogger
  {
      /**
       * Timestamp format used by NCSA log is fixed. So it is not
       * configurable.
       */
      private final static String m_logDateFormat = "dd/MMM/yyyy:HH:mm:ss ZZZ";
      private DateCache m_dateCache;
  
      /**
       * Logs information about a single HTTP transaction after the
       * fact.
       *
       * @param request that was processed
       * @param response that was returned
       * @param responseLength number of octets sent in response
       */
      public void log( HttpRequest request, HttpResponse response, int responseLength )
      {
          if( getLogger().isInfoEnabled() )
          {
              StringBuffer buf = new StringBuffer( 160 );
  
              buf.append( request.getRemoteAddr() );
              buf.append( " - " );
  
              String user = request.getAuthUser();
              buf.append( ( user == null ) ? "-" : user );
              buf.append( " [" );
              buf.append( m_dateCache.format( request.getTimeStamp() ) );
              buf.append( "] \"" );
              buf.append( request.getMethod() );
              buf.append( ' ' );
              buf.append( request.getURI() );
              buf.append( ' ' );
              buf.append( request.getVersion() );
              buf.append( "\" " );
  
              int status = response.getStatus();
              buf.append( (char)( '0' + ( ( status / 100 ) % 10 ) ) );
              buf.append( (char)( '0' + ( ( status / 10 ) % 10 ) ) );
              buf.append( (char)( '0' + ( status % 10 ) ) );
  
              if( responseLength >= 0 )
              {
                  buf.append( ' ' );
  
                  if( responseLength > 99999 )
                  {
                      buf.append( Integer.toString( responseLength ) );
                  }
                  else
                  {
                      if( responseLength > 9999 )
                          buf.append( (char)( '0' + ( ( responseLength / 10000 ) % 10 ) ) );
                      if( responseLength > 999 )
                          buf.append( (char)( '0' + ( ( responseLength / 1000 ) % 10 ) ) );
                      if( responseLength > 99 )
                          buf.append( (char)( '0' + ( ( responseLength / 100 ) % 10 ) ) );
                      if( responseLength > 9 )
                          buf.append( (char)( '0' + ( ( responseLength / 10 ) % 10 ) ) );
                      buf.append( (char)( '0' + ( responseLength % 10 ) ) );
                  }
                  buf.append( ' ' );
              }
              else
              {
                  buf.append( " - " );
              }
  
              getLogger().info( buf.toString() );
          }
      }
  
      public void initialize() throws Exception
      {
          m_dateCache = new DateCache( m_logDateFormat, Locale.US );
          m_dateCache.setTimeZoneID( TimeZone.getDefault().getID() );
      }
  }
  
  
  
  1.1                  spice/sandbox/jervlet/jervlet-jetty/src/java/org/jcomponent/jervlet/blocks/jetty/WebApplicationContextHolder.java
  
  Index: WebApplicationContextHolder.java
  ===================================================================
  /*
  
   ============================================================================
                     The Apache Software License, Version 1.1
   ============================================================================
  
   Copyright (C) 2002,2003 The Apache Software Foundation. All rights reserved.
  
   Redistribution and use in source and binary forms, with or without modifica-
   tion, are permitted provided that the following conditions are met:
  
   1. Redistributions of  source code must  retain the above copyright  notice,
      this list of conditions and the following disclaimer.
  
   2. Redistributions in binary form must reproduce the above copyright notice,
      this list of conditions and the following disclaimer in the documentation
      and/or other materials provided with the distribution.
  
   3. The end-user documentation included with the redistribution, if any, must
      include  the following  acknowledgment:  "This product includes  software
      developed  by the  Apache Software Foundation  (http://www.apache.org/)."
      Alternately, this  acknowledgment may  appear in the software itself,  if
      and wherever such third-party acknowledgments normally appear.
  
   4. The names "Jakarta", "Avalon", "Excalibur" and "Apache Software Foundation"
      must not be used to endorse or promote products derived from this  software
      without  prior written permission. For written permission, please contact
      [email protected]
  
   5. Products  derived from this software may not  be called "Apache", nor may
      "Apache" appear  in their name,  without prior written permission  of the
      Apache Software Foundation.
  
   THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
   INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
   FITNESS  FOR A PARTICULAR  PURPOSE ARE  DISCLAIMED.  IN NO  EVENT SHALL  THE
   APACHE SOFTWARE  FOUNDATION  OR ITS CONTRIBUTORS  BE LIABLE FOR  ANY DIRECT,
   INDIRECT, INCIDENTAL, SPECIAL,  EXEMPLARY, OR CONSEQUENTIAL  DAMAGES (INCLU-
   DING, BUT NOT LIMITED TO, PROCUREMENT  OF SUBSTITUTE GOODS OR SERVICES; LOSS
   OF USE, DATA, OR  PROFITS; OR BUSINESS  INTERRUPTION)  HOWEVER CAUSED AND ON
   ANY  THEORY OF LIABILITY,  WHETHER  IN CONTRACT,  STRICT LIABILITY,  OR TORT
   (INCLUDING  NEGLIGENCE OR  OTHERWISE) ARISING IN  ANY WAY OUT OF THE  USE OF
   THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  
   This software  consists of voluntary contributions made  by many individuals
   on  behalf of the Apache Software  Foundation. For more  information on the
   Apache Software Foundation, please see <http://www.apache.org/>.
  
  */
  package org.jcomponent.jervlet.blocks.jetty;
  
  import java.io.File;
  import java.io.IOException;
  import java.net.MalformedURLException;
  
  import org.jcomponent.jervlet.JervletContext;
  
  import org.mortbay.jetty.servlet.WebApplicationContext;
  
  /**
   * Class to hold a WebApplicationContext in Jetty
   *
   * @author <a href="[email protected]">peter royal</a>
   */
  class WebApplicationContextHolder
  {
      private final String m_context;
      private final String m_webappUrl;
      private final JervletContext m_jervletContext;
      private final File m_rootDirectory;
      private boolean m_extractWebArchive;
  
      private WebApplicationContext m_webApplicationContext;
  
      public WebApplicationContextHolder( String context,
                                    File pathToWebAppFolder,
                                    JervletContext jervletContext,
                                    File rootDirectory,
                                    boolean extractWebArchive )
          throws MalformedURLException
      {
          m_context = context;
          m_webappUrl = pathToWebAppFolder.toURL().toString();
          m_jervletContext = jervletContext;
          m_rootDirectory = rootDirectory;
          m_extractWebArchive = extractWebArchive;
      }
  
      String getWebappUrl()
      {
          return m_webappUrl;
      }
  
      String getContext()
      {
          return m_context;
      }
  
      WebApplicationContext getWebApplicationContext()
      {
          return m_webApplicationContext;
      }
  
      String getStatus()
      {
          if( null == m_webApplicationContext )
          {
              return "Ready to deploy";
          }
          else if( m_webApplicationContext.isStarted() )
          {
              return "Running";
          }
          else
          {
              return "Stopped";
          }
      }
  
      WebApplicationContext create() throws IOException
      {
          if( null != m_webApplicationContext )
          {
              throw new IllegalStateException( "context already exists" );
          }
  
          m_webApplicationContext =
              new JervletWebApplicationContext( m_jervletContext, m_rootDirectory, m_webappUrl );
          m_webApplicationContext.setContextPath( m_context );
          m_webApplicationContext.setExtractWAR( m_extractWebArchive );
  
          return m_webApplicationContext;
      }
  
      void start() throws Exception
      {
          if( m_webApplicationContext == null )
          {
              throw new IllegalStateException( "haven't been created");
          }
          else if ( m_webApplicationContext.isStarted() )
          {
              throw new IllegalStateException( "already started" );
          }
  
          m_webApplicationContext.start();
      }
  
      void stop() throws InterruptedException
      {
          if( m_webApplicationContext == null || !m_webApplicationContext.isStarted() )
          {
              throw new IllegalStateException( "not started");
          }
  
          m_webApplicationContext.stop();
      }
  
      void destroy()
      {
          if( m_webApplicationContext == null )
          {
              throw new IllegalStateException( "already destroyed");
          }
          else if( m_webApplicationContext.isStarted() )
          {
              throw new IllegalStateException( "must stop before destroying ");
          }
  
          m_webApplicationContext.destroy();
          m_webApplicationContext = null;
      }
  }
  
  
  
  1.1                  spice/sandbox/jervlet/jervlet-jetty/src/java/org/jcomponent/jervlet/blocks/jetty/RequestLogger.java
  
  Index: RequestLogger.java
  ===================================================================
  /*
  
   ============================================================================
                     The Apache Software License, Version 1.1
   ============================================================================
  
   Copyright (C) 2002,2003 The Apache Software Foundation. All rights reserved.
  
   Redistribution and use in source and binary forms, with or without modifica-
   tion, are permitted provided that the following conditions are met:
  
   1. Redistributions of  source code must  retain the above copyright  notice,
      this list of conditions and the following disclaimer.
  
   2. Redistributions in binary form must reproduce the above copyright notice,
      this list of conditions and the following disclaimer in the documentation
      and/or other materials provided with the distribution.
  
   3. The end-user documentation included with the redistribution, if any, must
      include  the following  acknowledgment:  "This product includes  software
      developed  by the  Apache Software Foundation  (http://www.apache.org/)."
      Alternately, this  acknowledgment may  appear in the software itself,  if
      and wherever such third-party acknowledgments normally appear.
  
   4. The names "Jakarta", "Avalon", "Excalibur" and "Apache Software Foundation"
      must not be used to endorse or promote products derived from this  software
      without  prior written permission. For written permission, please contact
      [email protected]
  
   5. Products  derived from this software may not  be called "Apache", nor may
      "Apache" appear  in their name,  without prior written permission  of the
      Apache Software Foundation.
  
   THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
   INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
   FITNESS  FOR A PARTICULAR  PURPOSE ARE  DISCLAIMED.  IN NO  EVENT SHALL  THE
   APACHE SOFTWARE  FOUNDATION  OR ITS CONTRIBUTORS  BE LIABLE FOR  ANY DIRECT,
   INDIRECT, INCIDENTAL, SPECIAL,  EXEMPLARY, OR CONSEQUENTIAL  DAMAGES (INCLU-
   DING, BUT NOT LIMITED TO, PROCUREMENT  OF SUBSTITUTE GOODS OR SERVICES; LOSS
   OF USE, DATA, OR  PROFITS; OR BUSINESS  INTERRUPTION)  HOWEVER CAUSED AND ON
   ANY  THEORY OF LIABILITY,  WHETHER  IN CONTRACT,  STRICT LIABILITY,  OR TORT
   (INCLUDING  NEGLIGENCE OR  OTHERWISE) ARISING IN  ANY WAY OUT OF THE  USE OF
   THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  
   This software  consists of voluntary contributions made  by many individuals
   on  behalf of the Apache Software  Foundation. For more  information on the
   Apache Software Foundation, please see <http://www.apache.org/>.
  
  */
  package org.jcomponent.jervlet.blocks.jetty;
  
  import org.mortbay.http.HttpRequest;
  import org.mortbay.http.HttpResponse;
  
  /**
   * Records information about HTTP transaction.
   */
  public interface RequestLogger
  {
      String ROLE = RequestLogger.class.getName();
  
      /**
       * Logs information about a single HTTP transaction after the
       * fact.
       *
       * @param request that was processed
       * @param response that was returned
       * @param responseLength number of octets sent in response
       */
      void log( HttpRequest request, HttpResponse response, int responseLength );
  }
  
  
  
  1.1                  spice/sandbox/jervlet/jervlet-jetty/src/java/org/jcomponent/jervlet/blocks/jetty/JervletWebApplicationContext.java
  
  Index: JervletWebApplicationContext.java
  ===================================================================
  /*
  
   ============================================================================
                     The Apache Software License, Version 1.1
   ============================================================================
  
   Copyright (C) 2002,2003 The Apache Software Foundation. All rights reserved.
  
   Redistribution and use in source and binary forms, with or without modifica-
   tion, are permitted provided that the following conditions are met:
  
   1. Redistributions of  source code must  retain the above copyright  notice,
      this list of conditions and the following disclaimer.
  
   2. Redistributions in binary form must reproduce the above copyright notice,
      this list of conditions and the following disclaimer in the documentation
      and/or other materials provided with the distribution.
  
   3. The end-user documentation included with the redistribution, if any, must
      include  the following  acknowledgment:  "This product includes  software
      developed  by the  Apache Software Foundation  (http://www.apache.org/)."
      Alternately, this  acknowledgment may  appear in the software itself,  if
      and wherever such third-party acknowledgments normally appear.
  
   4. The names "Jakarta", "Avalon", "Excalibur" and "Apache Software Foundation"
      must not be used to endorse or promote products derived from this  software
      without  prior written permission. For written permission, please contact
      [email protected]
  
   5. Products  derived from this software may not  be called "Apache", nor may
      "Apache" appear  in their name,  without prior written permission  of the
      Apache Software Foundation.
  
   THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
   INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
   FITNESS  FOR A PARTICULAR  PURPOSE ARE  DISCLAIMED.  IN NO  EVENT SHALL  THE
   APACHE SOFTWARE  FOUNDATION  OR ITS CONTRIBUTORS  BE LIABLE FOR  ANY DIRECT,
   INDIRECT, INCIDENTAL, SPECIAL,  EXEMPLARY, OR CONSEQUENTIAL  DAMAGES (INCLU-
   DING, BUT NOT LIMITED TO, PROCUREMENT  OF SUBSTITUTE GOODS OR SERVICES; LOSS
   OF USE, DATA, OR  PROFITS; OR BUSINESS  INTERRUPTION)  HOWEVER CAUSED AND ON
   ANY  THEORY OF LIABILITY,  WHETHER  IN CONTRACT,  STRICT LIABILITY,  OR TORT
   (INCLUDING  NEGLIGENCE OR  OTHERWISE) ARISING IN  ANY WAY OUT OF THE  USE OF
   THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  
   This software  consists of voluntary contributions made  by many individuals
   on  behalf of the Apache Software  Foundation. For more  information on the
   Apache Software Foundation, please see <http://www.apache.org/>.
  
  */
  package org.jcomponent.jervlet.blocks.jetty;
  
  import java.io.File;
  import java.io.IOException;
  import org.jcomponent.jervlet.JervletContext;
  import org.mortbay.jetty.servlet.WebApplicationContext;
  
  /**
   *
   * Override for Jetty's WebApplicationContext to kludge Jasper JSP compilation ability.
   *
   *
   * @see <a href="http://jetty.mortbay.com/">Jetty Project Page</a>
   *
   * @author  Paul Hammant
   * @author  Jules Gosnell
   * @version 1.0
   */
  class JervletWebApplicationContext extends WebApplicationContext
  {
      private File m_sarRoot;
      private File m_phoenixLib;
      private JervletContext m_jervletContext;
  
      public JervletWebApplicationContext( JervletContext jervletContext, File sarRoot, String webAppURL )
          throws IOException
      {
          super( webAppURL );
          m_sarRoot = sarRoot;
          m_phoenixLib = new File( sarRoot.getParentFile().getParentFile(), "lib" );
          m_jervletContext = jervletContext;
  
          addHandler( 0, new JervletWebApplicationHandler( m_jervletContext ) );
      }
  
      /**
       * Make a classpath for Jasper to use during compilation. This is minimalist
       * @return the classpath.
       */
      public String getFileClassPath()
      {
          String classpath = "";
          classpath += new File( m_sarRoot, "jsplibs" + File.separator + "jasper-runtime.jar" ) + File.pathSeparator;
          classpath += new File( m_sarRoot, "jsplibs" + File.separator + "jasper-compile.jar" ) + File.pathSeparator;
          classpath += new File( m_sarRoot, "jsplibs" + File.separator + "javax.servlet.jar" ) + File.pathSeparator;
          classpath += new File( m_phoenixLib, "tools.jar" );
          return classpath;
      }
  }
  
  
  


-------------------------------------------------------
This SF.net email is sponsored by: The SF.net Donation Program.
Do you like what SourceForge.net is doing for the Open
Source Community?  Make a contribution, and help us add new
features and functionality. Click here: http://sourceforge.net/donate/
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.