1 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 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 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 filename) { 43 this.filename = filename; 44 } 45 46 public String getFilename() { 47 return filename; 48 } 49 50 public void setLogDateFormat(String format) { 51 requestLog.setLogDateFormat(format); 52 } 53 54 public String getLogDateFormat() { 55 return requestLog.getLogDateFormat(); 56 } 57 58 public void setLogTimeZone(String tz) { 59 requestLog.setLogTimeZone(tz); 60 } 61 62 public String 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 [] ignorePaths) { 91 requestLog.setIgnorePaths(ignorePaths); 92 } 93 94 public String [] 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 { 108 requestLog.setFilename(serverInfo.resolvePath(filename)); 109 container.setRequestLog(requestLog); 110 requestLog.start(); 111 } 112 113 public void doStop() throws Exception { 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 .class, true); 131 infoFactory.addAttribute("logDateFormat", String .class, true); 132 infoFactory.addAttribute("logTimeZone", String .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 [].class, true); 137 infoFactory.addAttribute("preferProxiedForAddress", boolean.class, true); 138 139 infoFactory.setConstructor(new String []{"JettyContainer", "ServerInfo"}); 140 GBEAN_INFO = infoFactory.getBeanInfo(); 141 } 142 143 public static GBeanInfo getGBeanInfo() { 144 return GBEAN_INFO; 145 } 146 } 147 | Popular Tags |