KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > geronimo > jetty6 > requestlog > NCSARequestLog


1 /**
2  * Licensed to the Apache Software Foundation (ASF) under one or more
3  * contributor license agreements. See the NOTICE file distributed with
4  * this work for additional information regarding copyright ownership.
5  * The ASF licenses this file to You under the Apache License, Version 2.0
6  * (the "License"); you may not use this file except in compliance with
7  * the License. You may obtain a copy of the License at
8  *
9  * http://www.apache.org/licenses/LICENSE-2.0
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  */

17 package org.apache.geronimo.jetty6.requestlog;
18
19 import org.apache.geronimo.gbean.GBeanInfo;
20 import org.apache.geronimo.gbean.GBeanInfoBuilder;
21 import org.apache.geronimo.gbean.GBeanLifecycle;
22 import org.apache.geronimo.j2ee.j2eeobjectnames.NameFactory;
23 import org.apache.geronimo.jetty6.JettyContainer;
24 import org.apache.geronimo.system.serverinfo.ServerInfo;
25 import org.mortbay.jetty.RequestLog;
26
27 /**
28  * @version $Rev: 482336 $ $Date: 2006-12-04 15:12:19 -0500 (Mon, 04 Dec 2006) $
29  */

30 public class NCSARequestLog implements GBeanLifecycle, JettyRequestLog {
31     private final JettyContainer container;
32     private final ServerInfo serverInfo;
33     private final RequestLog requestLog;
34     private boolean preferProxiedForAddress;
35     private String JavaDoc filename;
36
37     public NCSARequestLog(JettyContainer container, ServerInfo serverInfo) {
38         this.container = container;
39         this.serverInfo = serverInfo;
40         requestLog = new org.mortbay.jetty.NCSARequestLog();
41     }
42
43     public void setFilename(String JavaDoc filename) {
44         this.filename = filename;
45     }
46
47     public String JavaDoc getFilename() {
48         return filename;
49     }
50
51     public void setLogDateFormat(String JavaDoc format) {
52         ((org.mortbay.jetty.NCSARequestLog)requestLog).setLogDateFormat(format);
53     }
54
55     public String JavaDoc getLogDateFormat() {
56         return ((org.mortbay.jetty.NCSARequestLog)requestLog).getLogDateFormat();
57     }
58
59     public void setLogTimeZone(String JavaDoc tz) {
60         ((org.mortbay.jetty.NCSARequestLog)requestLog).setLogTimeZone(tz);
61     }
62
63     public String JavaDoc getLogTimeZone() {
64         return ((org.mortbay.jetty.NCSARequestLog)requestLog).getLogTimeZone();
65     }
66
67     public int getRetainDays() {
68         return ((org.mortbay.jetty.NCSARequestLog)requestLog).getRetainDays();
69     }
70
71     public void setRetainDays(int retainDays) {
72         ((org.mortbay.jetty.NCSARequestLog)requestLog).setRetainDays(retainDays);
73     }
74
75     public boolean isExtended() {
76         return ((org.mortbay.jetty.NCSARequestLog)requestLog).isExtended();
77     }
78
79     public void setExtended(boolean e) {
80         ((org.mortbay.jetty.NCSARequestLog)requestLog).setExtended(e);
81     }
82
83     public boolean isAppend() {
84         return ((org.mortbay.jetty.NCSARequestLog)requestLog).isAppend();
85     }
86
87     public void setAppend(boolean a) {
88         ((org.mortbay.jetty.NCSARequestLog)requestLog).setAppend(a);
89     }
90
91     public void setIgnorePaths(String JavaDoc[] ignorePaths) {
92         ((org.mortbay.jetty.NCSARequestLog)requestLog).setIgnorePaths(ignorePaths);
93     }
94
95     public String JavaDoc[] getIgnorePaths() {
96         return ((org.mortbay.jetty.NCSARequestLog)requestLog).getIgnorePaths();
97     }
98
99     public void setPreferProxiedForAddress(boolean value) {
100         this.preferProxiedForAddress = value;
101         ((org.mortbay.jetty.NCSARequestLog)requestLog).setPreferProxiedForAddress(value);
102     }
103
104     public boolean isPreferProxiedForAddress() {
105         return preferProxiedForAddress;
106     }
107
108     public String JavaDoc getAbsoluteFilePath() {
109         return requestLog == null ? null : ((org.mortbay.jetty.NCSARequestLog)requestLog).getDatedFilename();
110     }
111
112     public void doStart() throws Exception JavaDoc {
113         ((org.mortbay.jetty.NCSARequestLog)requestLog).setFilename(serverInfo.resolveServerPath(filename));
114         container.setRequestLog(requestLog);
115         requestLog.start();
116     }
117
118     public void doStop() throws Exception JavaDoc {
119         container.setRequestLog(null);
120     }
121
122     public void doFail() {
123         container.setRequestLog(null);
124     }
125
126     public static final GBeanInfo GBEAN_INFO;
127
128     static {
129         GBeanInfoBuilder infoFactory = GBeanInfoBuilder.createStatic("NCSA Request Log", NCSARequestLog.class);
130         infoFactory.addReference("JettyContainer", JettyContainer.class, NameFactory.GERONIMO_SERVICE);
131         infoFactory.addReference("ServerInfo", ServerInfo.class, NameFactory.GERONIMO_SERVICE);
132
133         infoFactory.addInterface(JettyRequestLog.class, new String JavaDoc[]{"filename", "logDateFormat", "logTimeZone",
134                 "retainDays", "extended", "append", "ignorePaths", "preferProxiedForAddress", });
135
136         infoFactory.setConstructor(new String JavaDoc[]{"JettyContainer", "ServerInfo"});
137         GBEAN_INFO = infoFactory.getBeanInfo();
138     }
139
140     public static GBeanInfo getGBeanInfo() {
141         return GBEAN_INFO;
142     }
143 }
144
Popular Tags