hoju        2003/08/26 08:42:12

  Modified:    .        build.xml
               src/java/org/apache/log4j/selector
                        ContextClassLoaderSelector.java
                        ContextJNDISelector.java
               src/java/org/apache/log4j/servlet ConfigurationServlet.java
                        InitContextListener.java InitServlet.java
  Added:       src/java/org/apache/log4j/selector package.html
               src/java/org/apache/log4j/servlet
                        ServletContextLogAppender.java
                        ServletContextLogAppenderListener.java package.html
               docs     overview.html
               src/java/org/apache/log4j/filter package.html
  Log:
  Committing servlet.ServletContextLogAppender and 
servlet.ServletContextLogAppenderListener submitted by Aleksei Valikov to the 
log4j-dev list.  I modified these classes to key upon the servlet context path (eg... 
"/MyContext") rather than the servlet context name which not only can be null, but 
also may not even be unique in the server.  Added Javadoc documentation to these and 
corrected javadoc in a few other classes.  Also added package.html files to keep 
checkstyle from complaining.  Added overview.html so that the one specified in the 
<javadoc> task will actually exist.  Upated the build.xml file to exclude the jdbc 
package which doesn't currently compile.  Added JDK detection to determine whether to 
add the -breakiterator flag for JDK1.4+ to output javadoc without all the warnings.
  
  jalopy'ed and checkstyled everything.  All except the unimplemented hashcode() 
method in ConfigurationServlet passes checkstyle-3.1.
  
  Jake
  
  Revision  Changes    Path
  1.11      +13 -31    jakarta-log4j-sandbox/build.xml
  
  Index: build.xml
  ===================================================================
  RCS file: /home/cvs/jakarta-log4j-sandbox/build.xml,v
  retrieving revision 1.10
  retrieving revision 1.11
  diff -u -r1.10 -r1.11
  --- build.xml 14 Jun 2003 21:30:45 -0000      1.10
  +++ build.xml 26 Aug 2003 15:42:11 -0000      1.11
  @@ -40,8 +40,6 @@
   
     <!-- The jar file that the jar task will generate -->
     <property name="log4j-sandbox.jar" value="log4j-sandbox-${version}.jar"/>
  -  <property name="log4j-sandbox-selector.jar" 
value="log4j-sandbox-selector-${version}.jar"/>
  -  <property name="log4j-sandbox-servlet.jar" 
value="log4j-sandbox-servlet-${version}.jar"/>
   
     <!-- Construct compile classpath -->
     <path id="compile.classpath">
  @@ -100,6 +98,7 @@
         <exclude name="**/servlet/**/*.java"/>
         <!--build excludes below via chainsaw-build.xml-->
         <exclude name="**/chainsaw/**/*.java"/>
  +      <exclude name="**/jdbc/**/*.java"/>
         <exclude name="**/net/**/*.java"/>
         <exclude name="**/spi/**/*.java"/>
         <exclude name="**/xml/**/*.java"/>
  @@ -226,34 +225,6 @@
                                        </section>
         </manifest>
       </jar>
  -
  -    <jar jarfile="${jar.dest}/${log4j-sandbox-selector.jar}"
  -         basedir="${javac.dest}"
  -         includes="**/selector/*.class">
  -                     <manifest>
  -                             <attribute name="Manifest-version" value="1.0"/>
  -                                     <section name="org/apache/log4j/selector">
  -                                       <attribute name="Comment" value="Log4j 
Sandbox Selector Packages"/>
  -                                       <attribute name="Implementation-Title" 
value="org.apache.log4j.selector"/>
  -                                       <attribute name="Implementation-Version" 
value="${version}"/>
  -                                       <attribute name="Implementation-Vendor" 
value="Apache Software Foundation"/>
  -                                     </section>
  -      </manifest>
  -    </jar>
  -
  -    <jar jarfile="${jar.dest}/${log4j-sandbox-servlet.jar}"
  -         basedir="${javac.dest}"
  -         includes="**/servlet/*.class">
  -                     <manifest>
  -                             <attribute name="Manifest-version" value="1.0"/>
  -                                     <section name="org/apache/log4j/servlet">
  -                                       <attribute name="Comment" value="Log4j 
Sandbox Servlet Packages"/>
  -                                       <attribute name="Implementation-Title" 
value="org.apache.log4j.servlet"/>
  -                                       <attribute name="Implementation-Version" 
value="${version}"/>
  -                                       <attribute name="Implementation-Vendor" 
value="Apache Software Foundation"/>
  -                                     </section>
  -      </manifest>
  -    </jar>
     </target>
   
   
  @@ -263,6 +234,17 @@
     <target name="javadoc" depends="init" unless="env.NO_JAVADOC">
   
       <mkdir dir="${javadoc.dest}" />
  +    <copy todir="${docs.dest}">
  +      <fileset dir="./docs" />
  +    </copy>
  +
  +    <condition property="javadoc.breakiterator" value="-breakiterator" >
  +      <or>
  +        <equals arg1="${ant.java.version}" arg2="1.4" />
  +        <equals arg1="${ant.java.version}" arg2="1.5" />
  +      </or>
  +    </condition>
  +    <property name="javadoc.breakiterator" value="" />
   
       <javadoc sourcepath="${java.source.dir}"
                                                 destdir="${javadoc.dest}"
  @@ -270,7 +252,6 @@
                                                 org.apache.log4j.chainsaw,
                                                 org.apache.log4j.filter,
                                                 org.apache.log4j.helpers,
  -                                              org.apache.log4j.jdbc,
                                                 org.apache.log4j.net,
                                                 org.apache.log4j.plugins,
                                 org.apache.log4j.selector,
  @@ -280,6 +261,7 @@
                                                 protected="true"
                                                 author="true"
                                                 use="true"
  +                                              
additionalparam="${javadoc.breakiterator}"
                                                 overview="${docs.dest}/overview.html"
                                                 doctitle="log4j version 
${version}&lt;br&gt;API Specification"
                                                 windowtitle="Log4j-sandbox Version 
${version}"
  
  
  
  1.6       +2 -2      
jakarta-log4j-sandbox/src/java/org/apache/log4j/selector/ContextClassLoaderSelector.java
  
  Index: ContextClassLoaderSelector.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-log4j-sandbox/src/java/org/apache/log4j/selector/ContextClassLoaderSelector.java,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- ContextClassLoaderSelector.java   28 Feb 2003 05:09:29 -0000      1.5
  +++ ContextClassLoaderSelector.java   26 Aug 2003 15:42:12 -0000      1.6
  @@ -89,8 +89,8 @@
    * probably a multitude of others.  However, Tomcat 4.x.x and 5.x.x are the only
    * containers currently tested.</p>
    *
  - * @author  Jacob Kjome
  - * @since 1.3
  + * @author <a href="mailto:[EMAIL PROTECTED]">Jacob Kjome</a>
  + * @since  1.3
    */
   public class ContextClassLoaderSelector implements RepositorySelector {
     /**
  
  
  
  1.5       +2 -2      
jakarta-log4j-sandbox/src/java/org/apache/log4j/selector/ContextJNDISelector.java
  
  Index: ContextJNDISelector.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-log4j-sandbox/src/java/org/apache/log4j/selector/ContextJNDISelector.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- ContextJNDISelector.java  13 Apr 2003 06:46:32 -0000      1.4
  +++ ContextJNDISelector.java  26 Aug 2003 15:42:12 -0000      1.5
  @@ -119,8 +119,8 @@
    * [EMAIL PROTECTED] ContextClassLoaderSelector} in containers in which it is 
compatible
    * (such as Tomcat 4/5)</p>
    *
  - * @author  Jacob Kjome
  - * @since 1.3
  + * @author <a href="mailto:[EMAIL PROTECTED]">Jacob Kjome</a>
  + * @since  1.3
    */
   public class ContextJNDISelector implements RepositorySelector {
     /**
  
  
  
  1.1                  
jakarta-log4j-sandbox/src/java/org/apache/log4j/selector/package.html
  
  Index: package.html
  ===================================================================
  <!DOCTYPE html 
    PUBLIC "-//W3C//DTD HTML 4.01//EN" 
    "http://www.w3.org/TR/html401/strict.dtd";>
  <html lang="en-US">
  <head>
    <title>org.apache.log4j.selector package</title>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
  </head>
  <body>
    <h1>org.apache.log4j.selector</h1>
    <p>This package contains classes useful for working with Log4j in a container
      environment where many applications need to share Log4j without stepping
      on each other's logging configuration.  Each of these classes implements
      the <code>RepositorySelector</code> interface.  Only one class may be used
      per instance of Log4j.  The container normally sets the repository selector,
      but one may assign the selector themselves using the InitContextListener in
      the <code>org.apache.log4j.serlvet</code> package as well.</p>
  </body>
  </html>
  
  
  
  1.9       +7 -7      
jakarta-log4j-sandbox/src/java/org/apache/log4j/servlet/ConfigurationServlet.java
  
  Index: ConfigurationServlet.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-log4j-sandbox/src/java/org/apache/log4j/servlet/ConfigurationServlet.java,v
  retrieving revision 1.8
  retrieving revision 1.9
  diff -u -r1.8 -r1.9
  --- ConfigurationServlet.java 29 Jul 2003 00:36:14 -0000      1.8
  +++ ConfigurationServlet.java 26 Aug 2003 15:42:12 -0000      1.9
  @@ -92,7 +92,7 @@
    *   <url-pattern>/Log4jAdmin</url-pattern><br>
    * </servlet-mapping><br>
    * <br>
  - * This servlet will then be accessible via 
  + * This servlet will then be accessible via
    * http://yourhost:yourport/yourwebapp/Log4jAdmin
    *
    * @author <a href="mailto:[EMAIL PROTECTED]">Luther E. Birdzell</a>
  @@ -304,16 +304,16 @@
      * Prints the page header.
      *
      * @param out The output writer
  -   * @paam request The request
  +   * @param request The request
      */
     private void printHeader(PrintWriter out, HttpServletRequest request) {
  -      out.println(
  -        "<html><head><title>Log4J Control Console</title></head>"
  -        + "<body><H3>Log4J Control Console</H3>");
  -      out.println("<A href=\"" + request.getRequestURI() + "\">Refresh</A><HR>");
  +    out.println(
  +      "<html><head><title>Log4J Control Console</title></head>"
  +      + "<body><H3>Log4J Control Console</H3>");
  +    out.println("<A href=\"" + request.getRequestURI() + "\">Refresh</A><HR>");
     }
   
  -  /** 
  +  /**
      * Prints the Level select HTML.
      *
      * @param out The output writer
  
  
  
  1.8       +22 -3     
jakarta-log4j-sandbox/src/java/org/apache/log4j/servlet/InitContextListener.java
  
  Index: InitContextListener.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-log4j-sandbox/src/java/org/apache/log4j/servlet/InitContextListener.java,v
  retrieving revision 1.7
  retrieving revision 1.8
  diff -u -r1.7 -r1.8
  --- InitContextListener.java  13 Apr 2003 06:46:33 -0000      1.7
  +++ InitContextListener.java  26 Aug 2003 15:42:12 -0000      1.8
  @@ -241,8 +241,8 @@
    * </dd>
    * </dl>
    *
  - * @author  Jacob Kjome <[EMAIL PROTECTED]>
  - * @since   1.3
  + * @author <a href="mailto:[EMAIL PROTECTED]">Jacob Kjome</a>
  + * @since  1.3
    */
   public class InitContextListener implements ServletContextListener {
     /**
  @@ -506,13 +506,32 @@
         File logHomeDir = new File(logHome);
   
         if (logHomeDir.exists() || logHomeDir.mkdirs()) {
  -        String tempdir =
  +        /*String tempdir =
             "" + context.getAttribute("javax.servlet.context.tempdir");
           int lastSlash = tempdir.lastIndexOf(File.separator);
   
           if ((tempdir.length() - 1) > lastSlash) {
             logHomePropName = tempdir.substring(lastSlash + 1) + ".log.home";
  +        }*/
  +        String contextPath = "";
  +
  +        try {
  +          //use a more standard way to obtain the context path name
  +          //which should work across all servers.  The tmpdir technique
  +          //(above) depends upon the naming scheme that Tomcat uses.
  +          String path = context.getResource("/").getPath();
  +
  +          //first remove trailing slash, then take what's left over
  +          //which should be the context path less the preceeding
  +          //slash such as "MyContext"
  +          contextPath = path.substring(0, path.lastIndexOf("/"));
  +          contextPath =
  +            contextPath.substring(contextPath.lastIndexOf("/") + 1);
  +        } catch (Exception e) {
  +          ;
           }
  +
  +        logHomePropName = contextPath + ".log.home";
         }
       }
   
  
  
  
  1.8       +2 -2      
jakarta-log4j-sandbox/src/java/org/apache/log4j/servlet/InitServlet.java
  
  Index: InitServlet.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-log4j-sandbox/src/java/org/apache/log4j/servlet/InitServlet.java,v
  retrieving revision 1.7
  retrieving revision 1.8
  diff -u -r1.7 -r1.8
  --- InitServlet.java  13 Apr 2003 06:46:33 -0000      1.7
  +++ InitServlet.java  26 Aug 2003 15:42:12 -0000      1.8
  @@ -124,8 +124,8 @@
    * parameters.
    * </p>
    *
  - * @author  Jacob Kjome <[EMAIL PROTECTED]>
  - * @since   1.3
  + * @author <a href="mailto:[EMAIL PROTECTED]">Jacob Kjome</a>
  + * @since  1.3
    */
   public class InitServlet extends HttpServlet {
     /**
  
  
  
  1.1                  
jakarta-log4j-sandbox/src/java/org/apache/log4j/servlet/ServletContextLogAppender.java
  
  Index: ServletContextLogAppender.java
  ===================================================================
  /*
   * ============================================================================
   *                   The Apache Software License, Version 1.1
   * ============================================================================
   *
   *    Copyright (C) 1999 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 "log4j" 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.log4j.servlet;
  
  import org.apache.log4j.AppenderSkeleton;
  import org.apache.log4j.spi.LoggingEvent;
  
  import java.util.Collections;
  import java.util.HashMap;
  import java.util.Map;
  
  import javax.servlet.ServletContext;
  
  
  /**
   * Appends log messages to the servlet context log.
   * <p>This class is set up by first registering your application's
   * <code>ServletContext</code> object by following instructions
   * in the <code>[EMAIL PROTECTED] ServletContextLogAppenderListener}</code> 
class.</p>
   * <p>After providing the above configuration setup, the following
   * configuration is required to set up this appender in Log4j.xml...
   * <pre>
   * &lt;appender name=&quot;ServletContext&quot; 
class=&quot;org.apache.log4j.servlet.ServletContextLogAppender&quot;&gt;
   *   &lt;param name=&quot;servletContextPath&quot; value=&quot;/MyContext&quot; /&gt;
   *   &lt;layout.../&gt;
   * &lt;/appender&gt;
   * </pre>
   * Replace &quot;/MyContext&quot; with your own context path.</p>
   * <p>After that, you can use this appender like any other.  Check the
   * servlet context log for the specified servlet context path to view
   * the log output.</p>
   *
   * @author Aleksei Valikov
   * @author <a href="mailto:[EMAIL PROTECTED]">Jacob Kjome</a>
   * @since  1.3
   */
  public class ServletContextLogAppender extends AppenderSkeleton {
    /** Map of servlet contexts. */
    private static Map servletContexts =
      Collections.synchronizedMap(new HashMap());
  
    /** Path of the servlet context of this appender instance. */
    protected String servletContextPath;
  
    /** Servlet context of this appender. */
    protected ServletContext servletContext;
  
    /**
     * Provides access to the statically stored servlet context map
     *
     * @return the cached map servlet contexts
     */
    public static Map servletContexts() {
      return servletContexts;
    }
  
    /**
     * Returns servlet context path of this appender.
     *
     * @return Servlet context path of this appender.
     */
    public String getServletContextPath() {
      return servletContextPath;
    }
  
    /**
     * Sets servlet context path of this appender.
     *
     * @param servletContextPath path of the servlet context of this appender.
     */
    public void setServletContextPath(final String servletContextPath) {
      this.servletContextPath = servletContextPath;
    }
  
    /**
     * Activates configured options.
     */
    public void activateOptions() {
      servletContext = (ServletContext) servletContexts.get(servletContextPath);
  
      if (servletContext == null) {
        errorHandler.error(
          "Servlet context [" + servletContextPath + "] could not be found.");
      }
    }
  
    /**
     * Appends a logging event through the servlet context logger.
     *
     * @param event logging event to append;
     */
    protected void append(final LoggingEvent event) {
      // If servlet context is undefined
      // Try loading servlet context
      if (servletContext == null) {
        servletContext =
          (ServletContext) servletContexts.get(servletContextPath);
      }
  
      // If servlet context is not found, signal an error
      if (servletContext == null) {
        errorHandler.error(
          "Servlet context [" + servletContextPath + "] could not be found.");
  
        return;
      }
  
      // Output log message
      servletContext.log(layout.format(event));
  
      return;
    }
  
    /**
     * Flags that layout is required.
     *
     * @return <code>true</code>.
     */
    public boolean requiresLayout() {
      return true;
    }
  
    /**
     * Should close the appender - does nothing.
     */
    public void close() {
    }
  }
  
  
  
  1.1                  
jakarta-log4j-sandbox/src/java/org/apache/log4j/servlet/ServletContextLogAppenderListener.java
  
  Index: ServletContextLogAppenderListener.java
  ===================================================================
  /*
   * ============================================================================
   *                   The Apache Software License, Version 1.1
   * ============================================================================
   *
   *    Copyright (C) 1999 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 "log4j" 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.log4j.servlet;
  
  import javax.servlet.ServletContext;
  import javax.servlet.ServletContextEvent;
  import javax.servlet.ServletContextListener;
  
  
  /**
   * This class maintains list of contexts in [EMAIL PROTECTED] 
ServletContextLogAppender}.
   * <p>A container-managed registration of contexts would obviate the need
   * for this class, but since there is no container-management at this time,
   * this class is the only way to register the servlet context for your
   * application in order for the <code>ServletContextLogAppender</code>
   * to be able to log to your application's context log.</p>
   * <p>To use this class, the following must be added to the web.xml (and
   * make sure that it is added before the
   * <code>[EMAIL PROTECTED] InitContextListener}</code> if you use that class for 
Log4j
   * initialization)...
   * <pre>
   * &lt;listener&gt;
   *   &lt;listener-class&gt;
   *   org.apache.log4j.servlet.ServletContextLogAppenderListener
   *   &lt;/listener-class&gt;
   * &lt;/listener&gt;
   * </pre></p>
   * <p>See the <code>ServletContextLogAppender</code> for further required
   * configuration information.</p>
   *
   * @author Aleksei Valikov
   * @author <a href="mailto:[EMAIL PROTECTED]">Jacob Kjome</a>
   * @since  1.3
   */
  public class ServletContextLogAppenderListener
    implements ServletContextListener {
    /**
     * Receives a notification of the context initialization event.
     * @param event context event.
     */
    public void contextInitialized(final ServletContextEvent event) {
      // Add context to map of servlet contexts
      final ServletContext servletContext = event.getServletContext();
      ServletContextLogAppender.servletContexts().put(
        contextPath(servletContext), servletContext);
    }
  
    /**
     * Receives a notification of the context destruction event.
     * @param event context event.
     */
    public void contextDestroyed(final ServletContextEvent event) {
      // Removes context from the map of servlet contexts
      final ServletContext servletContext = event.getServletContext();
      ServletContextLogAppender.servletContexts().remove(
        contextPath(servletContext));
    }
  
    /**
     * utility method to obtain the servlet context path such as
     * &quot;/MyContext&quot;.
     *
     * @param servletContext a servlet context object
     * @return a string representing the servlet context path
     */
    private static String contextPath(ServletContext servletContext) {
      String contextPath = "";
  
      try {
        String path = servletContext.getResource("/").getPath();
  
        //first remove trailing slash, then take what's left over
        //which should be the context path such as "/MyContext"
        contextPath = path.substring(0, path.lastIndexOf("/"));
        contextPath = contextPath.substring(contextPath.lastIndexOf("/"));
      } catch (Exception e) {
        ;
      }
  
      return contextPath;
    }
  }
  
  
  
  1.1                  
jakarta-log4j-sandbox/src/java/org/apache/log4j/servlet/package.html
  
  Index: package.html
  ===================================================================
  <!DOCTYPE html 
    PUBLIC "-//W3C//DTD HTML 4.01//EN" 
    "http://www.w3.org/TR/html401/strict.dtd";>
  <html lang="en-US">
  <head>
    <title>org.apache.log4j.servlet package</title>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
  </head>
  <body>
    <h1>org.apache.log4j.servlet</h1>
    <p>This package contains classes useful for working with Log4j in a servlet
      environment</p>
  </body>
  </html>
  
  
  
  1.1                  jakarta-log4j-sandbox/docs/overview.html
  
  Index: overview.html
  ===================================================================
  <!DOCTYPE html 
    PUBLIC "-//W3C//DTD HTML 4.01//EN" 
    "http://www.w3.org/TR/html401/strict.dtd";>
  <html lang="en-US">
  <head>
    <title>overview of the Log4j-sandbox project</title>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
  </head>
  <body>
    <h1>The Log4j-sandbox project</h1>
    <p>The Log4j-sandbox project provides a home for contributions to the Log4j
      project that are deemed as useful, but not quite ready for prime-time.
      This is a place for experimentation and testing.  Code deemed to be of
      high quality after it has been knocked around a bit may be voted on to be
      admitted to Log4j proper.</p>
  </body>
  </html>
  
  
  
  1.1                  
jakarta-log4j-sandbox/src/java/org/apache/log4j/filter/package.html
  
  Index: package.html
  ===================================================================
  <!DOCTYPE html 
    PUBLIC "-//W3C//DTD HTML 4.01//EN" 
    "http://www.w3.org/TR/html401/strict.dtd";>
  <html lang="en-US">
  <head>
    <title>org.apache.log4j.filter package</title>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
  </head>
  <body>
    <h1>org.apache.log4j.filter</h1>
    <p>This package contains classes useful for filtering Log4j loggers in various
      ways.</p>
  </body>
  </html>
  
  
  

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

Reply via email to