001: /**
002: * Licensed to the Apache Software Foundation (ASF) under one or more
003: * contributor license agreements. See the NOTICE file distributed with
004: * this work for additional information regarding copyright ownership.
005: * The ASF licenses this file to You under the Apache License, Version 2.0
006: * (the "License"); you may not use this file except in compliance with
007: * the License. You may obtain a copy of the License at
008: *
009: * http://www.apache.org/licenses/LICENSE-2.0
010: *
011: * Unless required by applicable law or agreed to in writing, software
012: * distributed under the License is distributed on an "AS IS" BASIS,
013: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014: * See the License for the specific language governing permissions and
015: * limitations under the License.
016: */package org.apache.geronimo.jetty6.requestlog;
017:
018: import org.apache.geronimo.gbean.GBeanInfo;
019: import org.apache.geronimo.gbean.GBeanInfoBuilder;
020: import org.apache.geronimo.gbean.GBeanLifecycle;
021: import org.apache.geronimo.j2ee.j2eeobjectnames.NameFactory;
022: import org.apache.geronimo.jetty6.JettyContainer;
023: import org.apache.geronimo.system.serverinfo.ServerInfo;
024: import org.mortbay.jetty.RequestLog;
025:
026: /**
027: * @version $Rev: 482336 $ $Date: 2006-12-04 12:12:19 -0800 (Mon, 04 Dec 2006) $
028: */
029: public class NCSARequestLog implements GBeanLifecycle, JettyRequestLog {
030: private final JettyContainer container;
031: private final ServerInfo serverInfo;
032: private final RequestLog requestLog;
033: private boolean preferProxiedForAddress;
034: private String filename;
035:
036: public NCSARequestLog(JettyContainer container,
037: ServerInfo serverInfo) {
038: this .container = container;
039: this .serverInfo = serverInfo;
040: requestLog = new org.mortbay.jetty.NCSARequestLog();
041: }
042:
043: public void setFilename(String filename) {
044: this .filename = filename;
045: }
046:
047: public String getFilename() {
048: return filename;
049: }
050:
051: public void setLogDateFormat(String format) {
052: ((org.mortbay.jetty.NCSARequestLog) requestLog)
053: .setLogDateFormat(format);
054: }
055:
056: public String getLogDateFormat() {
057: return ((org.mortbay.jetty.NCSARequestLog) requestLog)
058: .getLogDateFormat();
059: }
060:
061: public void setLogTimeZone(String tz) {
062: ((org.mortbay.jetty.NCSARequestLog) requestLog)
063: .setLogTimeZone(tz);
064: }
065:
066: public String getLogTimeZone() {
067: return ((org.mortbay.jetty.NCSARequestLog) requestLog)
068: .getLogTimeZone();
069: }
070:
071: public int getRetainDays() {
072: return ((org.mortbay.jetty.NCSARequestLog) requestLog)
073: .getRetainDays();
074: }
075:
076: public void setRetainDays(int retainDays) {
077: ((org.mortbay.jetty.NCSARequestLog) requestLog)
078: .setRetainDays(retainDays);
079: }
080:
081: public boolean isExtended() {
082: return ((org.mortbay.jetty.NCSARequestLog) requestLog)
083: .isExtended();
084: }
085:
086: public void setExtended(boolean e) {
087: ((org.mortbay.jetty.NCSARequestLog) requestLog).setExtended(e);
088: }
089:
090: public boolean isAppend() {
091: return ((org.mortbay.jetty.NCSARequestLog) requestLog)
092: .isAppend();
093: }
094:
095: public void setAppend(boolean a) {
096: ((org.mortbay.jetty.NCSARequestLog) requestLog).setAppend(a);
097: }
098:
099: public void setIgnorePaths(String[] ignorePaths) {
100: ((org.mortbay.jetty.NCSARequestLog) requestLog)
101: .setIgnorePaths(ignorePaths);
102: }
103:
104: public String[] getIgnorePaths() {
105: return ((org.mortbay.jetty.NCSARequestLog) requestLog)
106: .getIgnorePaths();
107: }
108:
109: public void setPreferProxiedForAddress(boolean value) {
110: this .preferProxiedForAddress = value;
111: ((org.mortbay.jetty.NCSARequestLog) requestLog)
112: .setPreferProxiedForAddress(value);
113: }
114:
115: public boolean isPreferProxiedForAddress() {
116: return preferProxiedForAddress;
117: }
118:
119: public String getAbsoluteFilePath() {
120: return requestLog == null ? null
121: : ((org.mortbay.jetty.NCSARequestLog) requestLog)
122: .getDatedFilename();
123: }
124:
125: public void doStart() throws Exception {
126: ((org.mortbay.jetty.NCSARequestLog) requestLog)
127: .setFilename(serverInfo.resolveServerPath(filename));
128: container.setRequestLog(requestLog);
129: requestLog.start();
130: }
131:
132: public void doStop() throws Exception {
133: container.setRequestLog(null);
134: }
135:
136: public void doFail() {
137: container.setRequestLog(null);
138: }
139:
140: public static final GBeanInfo GBEAN_INFO;
141:
142: static {
143: GBeanInfoBuilder infoFactory = GBeanInfoBuilder.createStatic(
144: "NCSA Request Log", NCSARequestLog.class);
145: infoFactory.addReference("JettyContainer",
146: JettyContainer.class, NameFactory.GERONIMO_SERVICE);
147: infoFactory.addReference("ServerInfo", ServerInfo.class,
148: NameFactory.GERONIMO_SERVICE);
149:
150: infoFactory.addInterface(JettyRequestLog.class, new String[] {
151: "filename", "logDateFormat", "logTimeZone",
152: "retainDays", "extended", "append", "ignorePaths",
153: "preferProxiedForAddress", });
154:
155: infoFactory.setConstructor(new String[] { "JettyContainer",
156: "ServerInfo" });
157: GBEAN_INFO = infoFactory.getBeanInfo();
158: }
159:
160: public static GBeanInfo getGBeanInfo() {
161: return GBEAN_INFO;
162: }
163: }
|