/** * Return the application Filter we are configured for. * * @exception ClassCastException if the specified class does not implement the <code> * javax.servlet.Filter</code> interface * @exception ClassNotFoundException if the filter class cannot be found * @exception IllegalAccessException if the filter class cannot be publicly instantiated * @exception InstantiationException if an exception occurs while instantiating the filter object * @exception ServletException if thrown by the filter's init() method */ Filter getFilter() throws ClassCastException, ClassNotFoundException, IllegalAccessException, InstantiationException, ServletException { // Return the existing filter instance, if any if (this.filter != null) return (this.filter); // Identify the class loader we will be using String filterClass = filterDef.getFilterClass(); ClassLoader classLoader = null; if (filterClass.startsWith("org.apache.catalina.")) classLoader = this.getClass().getClassLoader(); else classLoader = context.getLoader().getClassLoader(); ClassLoader oldCtxClassLoader = Thread.currentThread().getContextClassLoader(); // Instantiate a new instance of this filter and return it Class clazz = classLoader.loadClass(filterClass); this.filter = (Filter) clazz.newInstance(); if (context instanceof StandardContext && ((StandardContext) context).getSwallowOutput()) { try { SystemLogHandler.startCapture(); filter.init(this); } finally { String log = SystemLogHandler.stopCapture(); if (log != null && log.length() > 0) { getServletContext().log(log); } } } else { filter.init(this); } return (this.filter); }
private static FilterInfo getFilterInfo(FilterDef fd) { FilterInfo fi = new FilterInfo(); fi.setFilterName(fd.getFilterName()); fi.setFilterClass(fd.getFilterClass()); fi.setFilterDesc(fd.getDescription()); return fi; }
/** Return a String representation of this object. */ public String toString() { StringBuffer sb = new StringBuffer("ApplicationFilterConfig["); sb.append("name="); sb.append(filterDef.getFilterName()); sb.append(", filterClass="); sb.append(filterDef.getFilterClass()); sb.append("]"); return (sb.toString()); }
/** * Return the application Filter we are configured for. * * @exception ClassCastException if the specified class does not implement the <code> * javax.servlet.Filter</code> interface * @exception ClassNotFoundException if the filter class cannot be found * @exception IllegalAccessException if the filter class cannot be publicly instantiated * @exception InstantiationException if an exception occurs while instantiating the filter object * @exception ServletException if thrown by the filter's init() method * @throws NamingException * @throws InvocationTargetException */ Filter getFilter() throws ClassCastException, ClassNotFoundException, IllegalAccessException, InstantiationException, ServletException, InvocationTargetException, NamingException { // Return the existing filter instance, if any if (this.filter != null) return (this.filter); // Identify the class loader we will be using String filterClass = filterDef.getFilterClass(); this.filter = (Filter) getInstanceManager().newInstance(filterClass); initFilter(); return (this.filter); }
/** Return the class of the filter we are configuring. */ public String getFilterClass() { return filterDef.getFilterClass(); }