geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jboy...@apache.org
Subject svn commit: rev 55987 - in geronimo/trunk/modules: assembly/src/plan jetty/src/java/org/apache/geronimo/jetty jetty/src/java/org/apache/geronimo/jetty/requestlog
Date Fri, 29 Oct 2004 19:11:46 GMT
Author: jboynes
Date: Fri Oct 29 12:11:45 2004
New Revision: 55987

Added:
   geronimo/trunk/modules/jetty/src/java/org/apache/geronimo/jetty/requestlog/
   geronimo/trunk/modules/jetty/src/java/org/apache/geronimo/jetty/requestlog/NCSARequestLog.java
Modified:
   geronimo/trunk/modules/assembly/src/plan/j2ee-server-plan.xml
   geronimo/trunk/modules/jetty/src/java/org/apache/geronimo/jetty/JettyContainer.java
   geronimo/trunk/modules/jetty/src/java/org/apache/geronimo/jetty/JettyContainerImpl.java
Log:
add request log for jetty

Modified: geronimo/trunk/modules/assembly/src/plan/j2ee-server-plan.xml
==============================================================================
--- geronimo/trunk/modules/assembly/src/plan/j2ee-server-plan.xml	(original)
+++ geronimo/trunk/modules/assembly/src/plan/j2ee-server-plan.xml	Fri Oct 29 12:11:45 2004
@@ -186,7 +186,11 @@
 
 
     <!-- default WAR container using Jetty -->
-    <gbean name="geronimo.server:type=WebContainer,container=Jetty" class="org.apache.geronimo.jetty.JettyContainerImpl">
+    <gbean name="geronimo.server:type=WebContainer,container=Jetty" class="org.apache.geronimo.jetty.JettyContainerImpl"/>
+    <gbean name="geronimo.server:type=RequestLog,container=Jetty" class="org.apache.geronimo.jetty.requestlog.NCSARequestLog">
+        <reference name="JettyContainer">geronimo.server:type=WebContainer,container=Jetty</reference>
+        <reference name="ServerInfo">geronimo.system:role=ServerInfo</reference>
+        <attribute name="filename">var/log/jetty_yyyy_mm_dd.log</attribute>
     </gbean>
 
     <gbean name="geronimo.server:type=WebConnector,container=Jetty,port=8080" class="org.apache.geronimo.jetty.connector.HTTPConnector">

Modified: geronimo/trunk/modules/jetty/src/java/org/apache/geronimo/jetty/JettyContainer.java
==============================================================================
--- geronimo/trunk/modules/jetty/src/java/org/apache/geronimo/jetty/JettyContainer.java	(original)
+++ geronimo/trunk/modules/jetty/src/java/org/apache/geronimo/jetty/JettyContainer.java	Fri
Oct 29 12:11:45 2004
@@ -20,6 +20,7 @@
 import org.mortbay.http.HttpContext;
 import org.mortbay.http.HttpListener;
 import org.mortbay.http.UserRealm;
+import org.mortbay.http.RequestLog;
 
 /**
  * @version $Rev$ $Date$
@@ -70,4 +71,9 @@
     long getRequestsDurationAve();
 
     long getRequestsDurationMax();
+
+    void setRequestLog(RequestLog log);
+
+    /* ------------------------------------------------------------ */
+    RequestLog getRequestLog();
 }

Modified: geronimo/trunk/modules/jetty/src/java/org/apache/geronimo/jetty/JettyContainerImpl.java
==============================================================================
--- geronimo/trunk/modules/jetty/src/java/org/apache/geronimo/jetty/JettyContainerImpl.java
(original)
+++ geronimo/trunk/modules/jetty/src/java/org/apache/geronimo/jetty/JettyContainerImpl.java
Fri Oct 29 12:11:45 2004
@@ -19,6 +19,7 @@
 
 import org.mortbay.http.HttpContext;
 import org.mortbay.http.HttpListener;
+import org.mortbay.http.RequestLog;
 import org.mortbay.http.UserRealm;
 import org.mortbay.jetty.Server;
 
@@ -129,6 +130,15 @@
         server.removeRealm(realm.getName());
     }
 
+    public void setRequestLog(RequestLog log) {
+        server.setRequestLog(log);
+    }
+
+    /* ------------------------------------------------------------ */
+    public RequestLog getRequestLog() {
+        return server.getRequestLog();
+    }
+
     public void doStart() throws WaitingException, Exception {
         server.start();
     }
@@ -168,6 +178,8 @@
         infoFactory.addAttribute("requestsDurationAve", Long.TYPE, false);
         infoFactory.addAttribute("requestsDurationMax", Long.TYPE, false);
         infoFactory.addOperation("resetStatistics");
+
+        infoFactory.addAttribute("requestLog", RequestLog.class, false);
 
         infoFactory.addOperation("addListener", new Class[]{HttpListener.class});
         infoFactory.addOperation("removeListener", new Class[]{HttpListener.class});

Added: geronimo/trunk/modules/jetty/src/java/org/apache/geronimo/jetty/requestlog/NCSARequestLog.java
==============================================================================
--- (empty file)
+++ geronimo/trunk/modules/jetty/src/java/org/apache/geronimo/jetty/requestlog/NCSARequestLog.java
Fri Oct 29 12:11:45 2004
@@ -0,0 +1,155 @@
+/**
+ *
+ * Copyright 2004 The Apache Software Foundation
+ *
+ *  Licensed under the Apache License, Version 2.0 (the "License");
+ *  you may not use this file except in compliance with the License.
+ *  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+package org.apache.geronimo.jetty.requestlog;
+
+import org.apache.geronimo.gbean.GBeanInfo;
+import org.apache.geronimo.gbean.GBeanInfoFactory;
+import org.apache.geronimo.gbean.GBeanLifecycle;
+import org.apache.geronimo.gbean.WaitingException;
+import org.apache.geronimo.jetty.JettyContainer;
+import org.apache.geronimo.system.serverinfo.ServerInfo;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class NCSARequestLog implements GBeanLifecycle {
+    private final JettyContainer container;
+    private final ServerInfo serverInfo;
+    private final org.mortbay.http.NCSARequestLog requestLog;
+    private boolean preferProxiedForAddress;
+    private String filename;
+
+    public NCSARequestLog(JettyContainer container, ServerInfo serverInfo) {
+        this.container = container;
+        this.serverInfo = serverInfo;
+        requestLog = new org.mortbay.http.NCSARequestLog();
+    }
+
+    public boolean isBuffered() {
+        return requestLog.isBuffered();
+    }
+
+    public void setBuffered(boolean buffered) {
+        requestLog.setBuffered(buffered);
+    }
+
+    public void setFilename(String filename) {
+        this.filename = filename;
+    }
+
+    public String getFilename() {
+        return filename;
+    }
+
+    public void setLogDateFormat(String format) {
+        requestLog.setLogDateFormat(format);
+    }
+
+    public String getLogDateFormat() {
+        return requestLog.getLogDateFormat();
+    }
+
+    public void setLogTimeZone(String tz) {
+        requestLog.setLogTimeZone(tz);
+    }
+
+    public String getLogTimeZone() {
+        return requestLog.getLogTimeZone();
+    }
+
+    public int getRetainDays() {
+        return requestLog.getRetainDays();
+    }
+
+    public void setRetainDays(int retainDays) {
+        requestLog.setRetainDays(retainDays);
+    }
+
+    public boolean isExtended() {
+        return requestLog.isExtended();
+    }
+
+    public void setExtended(boolean e) {
+        requestLog.setExtended(e);
+    }
+
+    public boolean isAppend() {
+        return requestLog.isAppend();
+    }
+
+    public void setAppend(boolean a) {
+        requestLog.setAppend(a);
+    }
+
+    public void setIgnorePaths(String[] ignorePaths) {
+        requestLog.setIgnorePaths(ignorePaths);
+    }
+
+    public String[] getIgnorePaths() {
+        return requestLog.getIgnorePaths();
+    }
+
+    public void setPreferProxiedForAddress(boolean value) {
+        this.preferProxiedForAddress = value;
+        requestLog.setPreferProxiedForAddress(value);
+    }
+
+    public boolean isPreferProxiedForAddress() {
+        return preferProxiedForAddress;
+    }
+
+    public void doStart() throws WaitingException, Exception {
+        requestLog.setFilename(serverInfo.resolvePath(filename));
+        container.setRequestLog(requestLog);
+        requestLog.start();
+    }
+
+    public void doStop() throws WaitingException, Exception {
+        requestLog.stop();
+        container.setRequestLog(null);
+    }
+
+    public void doFail() {
+        container.setRequestLog(null);
+        requestLog.stop();
+    }
+
+    public static final GBeanInfo GBEAN_INFO;
+
+    static {
+        GBeanInfoFactory infoFactory = new GBeanInfoFactory("NCSA Request Log", NCSARequestLog.class);
+        infoFactory.addReference("JettyContainer", JettyContainer.class);
+        infoFactory.addReference("ServerInfo", ServerInfo.class);
+
+        infoFactory.addAttribute("filename", String.class, true);
+        infoFactory.addAttribute("logDateFormat", String.class, true);
+        infoFactory.addAttribute("logTimeZone", String.class, true);
+        infoFactory.addAttribute("retainDays", int.class, true);
+        infoFactory.addAttribute("extended", boolean.class, true);
+        infoFactory.addAttribute("append", boolean.class, true);
+        infoFactory.addAttribute("buffered", boolean.class, true);
+        infoFactory.addAttribute("ingorePaths", String[].class, true);
+        infoFactory.addAttribute("preferProxiedForAddress", boolean.class, true);
+
+        infoFactory.setConstructor(new String[]{"JettyContainer", "ServerInfo"});
+        GBEAN_INFO = infoFactory.getBeanInfo();
+    }
+
+    public static GBeanInfo getGBeanInfo() {
+        return GBEAN_INFO;
+    }
+}

Mime
View raw message