View Javadoc

1   /*
2    * Copyright (c) 2006-2007 Creative Sphere Limited.
3    * All rights reserved. This program and the accompanying materials
4    * are made available under the terms of the Eclipse Public License v1.0
5    * which accompanies this distribution, and is available at
6    * http://www.eclipse.org/legal/epl-v10.html
7    *
8    * Contributors:
9    *
10   *   Creative Sphere - initial API and implementation
11   *
12   */
13  package org.abstracthorizon.danube.http.logging;
14  
15  import org.abstracthorizon.danube.support.logging.AccessLogConnectionHandler;
16  
17  import java.util.List;
18  
19  /**
20   * <p>
21   * Utility class that adds new pattern codes to existing in {@link AccessLogConnectionHandler}
22   * </p>
23   * <ul>
24   * <li><code>%A</code> - local IP address</li>
25   * </ul>
26   * <p>
27   * Those are added through {@link HTTPPatternProcessor}
28   * </p>
29   * <p>
30   * Also it sets default pattern to &quot;%h %l %u %t &quot;%r&quot; %s %b&quot;
31   * </p>
32   * @author Daniel Sendula
33   */
34  public class HTTPAccessLogConnectionHandler extends AccessLogConnectionHandler {
35  
36      /**
37       * <p>Adds lists of predefined processors to the lists of provider classes.</p>
38       * <p>This method adds following:</p>
39       * <ul>
40       * <li>{@link HTTPPatternProcessor}</li>
41       * </ul>
42       * <p>Also it calls super method {@link AccessLogConnectionHandler#addPredefinedProcessors(List)}</p>
43       *
44       * @param providerClasses list of provider classes
45       */
46      protected void addPredefinedProcessors(List<String> providerClasses) {
47          super.addPredefinedProcessors(providerClasses);
48          if (!providerClasses.contains(HTTPPatternProcessor.class.getName())) {
49              providerClasses.add(HTTPPatternProcessor.class.getName());
50          }
51      }
52  
53  
54      /**
55       * Returns default log pattern
56       * @return default log pattern
57       */
58      protected String getDefaultLogPattern() {
59          return "%h %l %u %t \"%r\" %s %b";
60      }
61  
62  
63  }