1 25 package org.objectweb.jonas.web.jetty50; 26 27 import org.mortbay.jetty.servlet.Dispatcher; 28 import org.mortbay.jetty.servlet.FilterHolder; 29 import org.mortbay.jetty.servlet.ServletHolder; 30 import org.mortbay.jetty.servlet.WebApplicationContext; 31 import org.mortbay.jetty.servlet.WebApplicationHandler; 32 import org.mortbay.jetty.servlet.WebApplicationContext.Configuration; 33 import org.mortbay.jetty.servlet.jsr77.Jsr77Filter; 34 35 import org.apache.commons.logging.Log; 36 import org.apache.commons.logging.LogFactory; 37 38 44 public class JSR77Configuration implements Configuration { 45 46 49 public static final String FILTER_PREFIX = "JSR77Filter-"; 50 51 54 private static Log log = LogFactory.getLog(JSR77Configuration.class); 55 56 59 private WebApplicationContext webAppContext = null; 60 61 64 public JSR77Configuration() { 65 super(); 66 } 67 68 71 public void setWebApplicationContext(WebApplicationContext wac) { 72 this.webAppContext = wac; 73 } 74 75 78 public WebApplicationContext getWebApplicationContext() { 79 return this.webAppContext; 80 } 81 82 86 public void configureClassPath() throws Exception { 87 89 } 90 91 95 public void configureDefaults() throws Exception { 96 98 } 99 100 104 public void configureWebApp() throws Exception { 105 if (this.webAppContext.isStarted()) { 106 if (log.isDebugEnabled()) { 107 log.debug("Cannot configure webapp after it is started"); 108 } 109 return; 110 } 111 112 if (this.webAppContext != null) { 116 ServletHolder[] servlets = this.webAppContext.getServletHandler().getServlets(); 117 WebApplicationHandler waHandler = this.webAppContext.getWebApplicationHandler(); 118 119 for (int i = 0; servlets != null && i < servlets.length; i++) { 120 String filterName = FILTER_PREFIX + servlets[i].getName(); 121 FilterHolder holder = waHandler.defineFilter(filterName, Jsr77Filter.class.getName()); 122 waHandler.addFilterServletMapping(servlets[i].getName(), filterName, Dispatcher.__ALL); 123 holder.put("servlet-name", servlets[i].getName()); 124 if (log.isDebugEnabled()) { 125 log.debug("Configured JSR77 filter " + filterName); 126 } 127 } 128 } 129 130 } 131 132 } 133 | Popular Tags |