proyal      2003/02/06 08:43:46

  Modified:    sevak/src/java/org/apache/avalon/apps/sevak/blocks/jetty
                        JettySevak.java
  Added:       sevak/src/java/org/apache/avalon/apps/sevak/blocks/jetty
                        JettyRequestLogAdapter.java JettySevak-schema.xml
                        NCSARequestLogger.java NullRequestLogger.java
                        RequestLogger.java
  Log:
  * Patch from Greg Steuck to add request logging for Sevak/Jetty
  * Add configuration schema for Sevak/Jetty
  
  Revision  Changes    Path
  1.14      +117 -66   
avalon-apps/sevak/src/java/org/apache/avalon/apps/sevak/blocks/jetty/JettySevak.java
  
  Index: JettySevak.java
  ===================================================================
  RCS file: 
/home/cvs/avalon-apps/sevak/src/java/org/apache/avalon/apps/sevak/blocks/jetty/JettySevak.java,v
  retrieving revision 1.13
  retrieving revision 1.14
  diff -u -r1.13 -r1.14
  --- JettySevak.java   20 Jan 2003 23:50:21 -0000      1.13
  +++ JettySevak.java   6 Feb 2003 16:43:46 -0000       1.14
  @@ -1,37 +1,78 @@
   /*
  - * Copyright (C) The Apache Software Foundation. All rights reserved.
  - *
  - * This software is published under the terms of the Apache Software License
  - * version 1.1, a copy of which has been included with this distribution in
  - * the LICENSE file.
  - */
  +
  + ============================================================================
  +                   The Apache Software License, Version 1.1
  + ============================================================================
  +
  + Copyright (C) @year@ 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.apache.avalon.apps.sevak.blocks.jetty;
   
  -import org.apache.avalon.framework.activity.Startable;
  +import java.io.File;
  +import java.util.HashMap;
  +
  +import org.apache.avalon.apps.sevak.Sevak;
  +import org.apache.avalon.apps.sevak.SevakException;
  +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.Contextualizable;
   import org.apache.avalon.framework.logger.AbstractLogEnabled;
  -import org.apache.avalon.framework.CascadingRuntimeException;
  -import org.apache.avalon.framework.service.Serviceable;
  -import org.apache.avalon.framework.service.ServiceManager;
   import org.apache.avalon.framework.service.ServiceException;
  -import org.apache.avalon.apps.sevak.Sevak;
  -import org.apache.avalon.apps.sevak.SevakException;
  +import org.apache.avalon.framework.service.ServiceManager;
  +import org.apache.avalon.framework.service.Serviceable;
   import org.apache.avalon.phoenix.BlockContext;
   
  -import java.io.File;
  -import java.util.HashMap;
  -
  +import org.mortbay.http.SocketListener;
   import org.mortbay.jetty.Server;
   import org.mortbay.jetty.servlet.WebApplicationContext;
  -import org.mortbay.util.MultiException;
   import org.mortbay.util.Log;
  -import org.mortbay.http.SocketListener;
  -
  +import org.mortbay.util.MultiException;
   
   
   /**
  @@ -47,8 +88,8 @@
    * @author  Ulrich Mayring
    * @version 1.0
    */
  -public class JettySevak extends AbstractLogEnabled implements Sevak, Startable, 
Contextualizable,
  -        Configurable, Initializable, Serviceable
  +public class JettySevak extends AbstractLogEnabled
  +    implements Sevak, Startable, Contextualizable, Configurable, Initializable, 
Serviceable
   {
   
       private Server m_server;
  @@ -63,19 +104,13 @@
       private File m_sarRootDir;
       private ServiceManager m_serviceManager;
   
  -
  -    /**
  -     * Contruct a Jetty block
  -     */
  -    public JettySevak()
  -    {
  -    }
  -
       /**
        * @param serviceManager
        * @throws ServiceException
  +     *
  +     * @phoenix:dependency 
name="org.apache.avalon.apps.sevak.blocks.jetty.RequestLogger"
        */
  -    public void service(ServiceManager serviceManager) throws ServiceException
  +    public void service( ServiceManager serviceManager ) throws ServiceException
       {
           m_serviceManager = serviceManager;
       }
  @@ -84,23 +119,29 @@
        * Contextualize
        * @param context the context
        */
  -
  -    public void contextualize(final Context context)
  +    public void contextualize( final Context context )
       {
  -        m_sarRootDir = ((BlockContext) context).getBaseDirectory();
  +        m_sarRootDir = ( ( BlockContext ) context ).getBaseDirectory();
       }
   
       /**
        * 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
  +    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_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 );
  +
  +        if( m_maxThreads < m_minThreads )
  +        {
  +            throw new ConfigurationException( "maxthreads must be greater than 
minthreads" );
  +        }
       }
   
       /**
  @@ -111,13 +152,17 @@
       {
           m_server = new Server();
           SocketListener listener = new SocketListener();
  -        listener.setPort(m_port);
  -        listener.setMinThreads(m_minThreads);
  -        listener.setMaxThreads(m_maxThreads);
  -        m_server.addListener(listener);
  +        listener.setPort( m_port );
  +        listener.setMinThreads( m_minThreads );
  +        listener.setMaxThreads( m_maxThreads );
  +        m_server.addListener( listener );
           PhoenixLogSink phoenixLogSink = new PhoenixLogSink();
  -        phoenixLogSink.enableLogging(getLogger());
  -        Log.instance().add(phoenixLogSink);
  +        phoenixLogSink.enableLogging( getLogger() );
  +        Log.instance().add( phoenixLogSink );
  +
  +        RequestLogger logger = ( RequestLogger )
  +            m_serviceManager.lookup( RequestLogger.ROLE );
  +        m_server.setRequestLog( new JettyRequestLogAdapter( logger ) );
       }
   
       /**
  @@ -129,9 +174,9 @@
           {
               m_server.start();
           }
  -        catch (MultiException e)
  +        catch( MultiException e )
           {
  -            throw new CascadingRuntimeException("Some problem starting Jetty", e);
  +            throw new CascadingRuntimeException( "Some problem starting Jetty", e );
           }
       }
   
  @@ -144,9 +189,9 @@
           {
               m_server.stop();
           }
  -        catch (InterruptedException e)
  +        catch( InterruptedException e )
           {
  -            throw new CascadingRuntimeException("Some problem stopping Jetty", e);
  +            throw new CascadingRuntimeException( "Some problem stopping Jetty", e );
           }
       }
   
  @@ -156,9 +201,9 @@
        * @param pathToWebAppFolder the path to it
        * @throws SevakException if a problem
        */
  -    public void deploy(String context, File pathToWebAppFolder) throws 
SevakException
  +    public void deploy( String context, File pathToWebAppFolder ) throws 
SevakException
       {
  -        deploy(context, pathToWebAppFolder, m_serviceManager);
  +        deploy( context, pathToWebAppFolder, m_serviceManager );
       }
   
       /**
  @@ -168,7 +213,8 @@
        * @param serviceManager The service manager to use for (optional) Serviceable 
servlets.
        * @throws SevakException if a problem
        */
  -    public void deploy(String context, File pathToWebAppFolder, ServiceManager 
serviceManager) throws SevakException
  +    public void deploy( String context, File pathToWebAppFolder, ServiceManager 
serviceManager )
  +        throws SevakException
       {
           String webAppURL = null;
   
  @@ -178,20 +224,23 @@
               // This still does not work.
   
               WebApplicationContext ctx =
  -                new SevakWebApplicationContext(serviceManager, m_sarRootDir, 
webAppURL);
  -            ctx.setContextPath(context);
  -            m_server.addContext(m_hostName,ctx);
  -
  -            System.out.println("deploying context=" + context + ", webapp=" + 
webAppURL
  -                + " to host=" + ( m_hostName == null ? "(All Hosts)" : m_hostName ) 
);
  +                new SevakWebApplicationContext( serviceManager, m_sarRootDir, 
webAppURL );
  +            ctx.setContextPath( context );
  +            m_server.addContext( m_hostName, ctx );
  +
  +            if( getLogger().isInfoEnabled() )
  +                getLogger().info( "deploying context=" + context + ", webapp=" + 
webAppURL
  +                                  + " to host=" + ( m_hostName == null ? "(All 
Hosts)" : m_hostName ) );
   
  -            ctx.setExtractWAR(true);
  -            m_webapps.put(context, ctx);
  +            ctx.setExtractWAR( true );
  +            m_webapps.put( context, ctx );
               ctx.start();
           }
  -        catch (Exception e)
  +        catch( Exception e )
           {
  -            throw new SevakException("Problem deploying web application (" + 
webAppURL + ") in Jetty", e);
  +            final String msg = "Problem deploying web application (" + webAppURL + 
") in Jetty";
  +
  +            throw new SevakException( msg, e );
           }
       }
   
  @@ -200,20 +249,22 @@
        * @param context the context
        * @throws SevakException if a problem
        */
  -    public void undeploy(String context) throws SevakException
  +    public void undeploy( String context ) throws SevakException
       {
  -        WebApplicationContext ctx = (WebApplicationContext) m_webapps.get(context);
  +        WebApplicationContext ctx = ( WebApplicationContext ) m_webapps.get( 
context );
  +
           try
           {
               ctx.stop();
           }
  -        catch (InterruptedException e)
  +        catch( InterruptedException e )
           {
  -            throw new SevakException("Problem stopping web application in Jetty", 
e);
  +            throw new SevakException( "Problem stopping web application in Jetty", 
e );
           }
  -        m_server.removeContext(ctx);
  +
  +        m_server.removeContext( ctx );
           ctx.destroy();
  -        m_webapps.remove(context);
  +        m_webapps.remove( context );
       }
   
   }
  
  
  
  1.1                  
avalon-apps/sevak/src/java/org/apache/avalon/apps/sevak/blocks/jetty/JettyRequestLogAdapter.java
  
  Index: JettyRequestLogAdapter.java
  ===================================================================
  /*
  
   ============================================================================
                     The Apache Software License, Version 1.1
   ============================================================================
  
   Copyright (C) @year@ 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.apache.avalon.apps.sevak.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                  
avalon-apps/sevak/src/java/org/apache/avalon/apps/sevak/blocks/jetty/JettySevak-schema.xml
  
  Index: JettySevak-schema.xml
  ===================================================================
  <?xml version="1.0"?>
  <element
      name="root"
      xmlns="http://relaxng.org/ns/structure/1.0";
      datatypeLibrary="http://www.w3.org/2001/XMLSchema-datatypes";
  >
      <interleave>
          <optional>
              <element name="hostname"><text/></element>
          </optional>
          <optional>
              <element name="port"><data type="integer"/></element>
          </optional>
          <optional>
              <element name="minthreads"><data type="integer"/></element>
          </optional>
          <optional>
              <element name="maxthreads"><data type="integer"/></element>
          </optional>
      </interleave>
  </element>
  
  
  
  1.1                  
avalon-apps/sevak/src/java/org/apache/avalon/apps/sevak/blocks/jetty/NCSARequestLogger.java
  
  Index: NCSARequestLogger.java
  ===================================================================
  /*
  
   ============================================================================
                     The Apache Software License, Version 1.1
   ============================================================================
  
   Copyright (C) @year@ 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.apache.avalon.apps.sevak.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.apache.avalon.apps.sevak.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                  
avalon-apps/sevak/src/java/org/apache/avalon/apps/sevak/blocks/jetty/NullRequestLogger.java
  
  Index: NullRequestLogger.java
  ===================================================================
  /*
  
   ============================================================================
                     The Apache Software License, Version 1.1
   ============================================================================
  
   Copyright (C) @year@ 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.apache.avalon.apps.sevak.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.
   */
  public class NullRequestLogger implements RequestLogger
  {
      public void log( HttpRequest request, HttpResponse response, int responseLength )
      {
      }
  }
  
  
  
  1.1                  
avalon-apps/sevak/src/java/org/apache/avalon/apps/sevak/blocks/jetty/RequestLogger.java
  
  Index: RequestLogger.java
  ===================================================================
  /*
  
   ============================================================================
                     The Apache Software License, Version 1.1
   ============================================================================
  
   Copyright (C) @year@ 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.apache.avalon.apps.sevak.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 );
  }
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to