KickJava   Java API By Example, From Geeks To Geeks.

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


1 /**
2  *
3  * Copyright 2004 The Apache Software Foundation
4  *
5  * Licensed under the Apache License, Version 2.0 (the "License");
6  * you may not use this file except in compliance with the License.
7  * 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.jetty.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.jetty.JettyContainer;
23 import org.apache.geronimo.system.serverinfo.ServerInfo;
24 import org.apache.geronimo.j2ee.j2eeobjectnames.NameFactory;
25
26 /**
27  * @version $Rev$ $Date$
28  */

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