1 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 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 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 filename) { 44 this.filename = filename; 45 } 46 47 public String getFilename() { 48 return filename; 49 } 50 51 public void setLogDateFormat(String format) { 52 ((org.mortbay.jetty.NCSARequestLog)requestLog).setLogDateFormat(format); 53 } 54 55 public String getLogDateFormat() { 56 return ((org.mortbay.jetty.NCSARequestLog)requestLog).getLogDateFormat(); 57 } 58 59 public void setLogTimeZone(String tz) { 60 ((org.mortbay.jetty.NCSARequestLog)requestLog).setLogTimeZone(tz); 61 } 62 63 public String 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 [] ignorePaths) { 92 ((org.mortbay.jetty.NCSARequestLog)requestLog).setIgnorePaths(ignorePaths); 93 } 94 95 public String [] 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 getAbsoluteFilePath() { 109 return requestLog == null ? null : ((org.mortbay.jetty.NCSARequestLog)requestLog).getDatedFilename(); 110 } 111 112 public void doStart() throws Exception { 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 { 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 []{"filename", "logDateFormat", "logTimeZone", 134 "retainDays", "extended", "append", "ignorePaths", "preferProxiedForAddress", }); 135 136 infoFactory.setConstructor(new String []{"JettyContainer", "ServerInfo"}); 137 GBEAN_INFO = infoFactory.getBeanInfo(); 138 } 139 140 public static GBeanInfo getGBeanInfo() { 141 return GBEAN_INFO; 142 } 143 } 144 | Popular Tags |