1 17 package org.apache.geronimo.jetty6; 18 19 import java.util.Map ; 20 21 import org.apache.geronimo.gbean.GBeanInfo; 22 import org.apache.geronimo.gbean.GBeanInfoBuilder; 23 import org.apache.geronimo.gbean.GBeanLifecycle; 24 import org.apache.geronimo.j2ee.j2eeobjectnames.NameFactory; 25 import org.mortbay.jetty.servlet.FilterHolder; 26 27 30 public class JettyFilterHolder implements GBeanLifecycle { 31 32 private final FilterHolder filterHolder; 33 34 public JettyFilterHolder() { 36 filterHolder = null; 37 } 38 39 public JettyFilterHolder(String filterName, String filterClass, Map initParams, JettyServletRegistration jettyServletRegistration) throws Exception { 40 filterHolder = new FilterHolder(); 41 if (jettyServletRegistration != null) { 42 filterHolder.setName(filterName); 43 filterHolder.setClassName(filterClass); 44 filterHolder.setInitParameters(initParams); 45 (jettyServletRegistration.getServletHandler()).addFilter(filterHolder); 46 47 } 56 } 57 58 public String getFilterName() { 59 return filterHolder.getName(); 60 } 61 62 public void doStart() throws Exception { 63 filterHolder.start(); 64 } 65 66 public void doStop() throws Exception { 67 filterHolder.stop(); 68 } 69 70 public void doFail() { 71 try { 72 filterHolder.stop(); 73 } catch (Exception e) { 74 } 76 } 77 78 public static final GBeanInfo GBEAN_INFO; 79 80 static { 81 GBeanInfoBuilder infoBuilder = GBeanInfoBuilder.createStatic(JettyFilterHolder.class, NameFactory.WEB_FILTER); 82 infoBuilder.addAttribute("filterName", String .class, true); 83 infoBuilder.addAttribute("filterClass", String .class, true); 84 infoBuilder.addAttribute("initParams", Map .class, true); 85 86 infoBuilder.addReference("JettyServletRegistration", JettyServletRegistration.class, NameFactory.WEB_MODULE); 87 88 infoBuilder.setConstructor(new String [] {"filterName", "filterClass", "initParams", "JettyServletRegistration"}); 89 90 GBEAN_INFO = infoBuilder.getBeanInfo(); 91 92 } 93 94 public static GBeanInfo getGBeanInfo() { 95 return GBEAN_INFO; 96 } 97 98 } 99 | Popular Tags |