/** Release the Filter instance associated with this FilterConfig, if there is one. */ void release() { unregisterJMX(); if (this.filter != null) { if (Globals.IS_SECURITY_ENABLED) { try { SecurityUtil.doAsPrivilege("destroy", filter); } catch (java.lang.Exception ex) { context.getLogger().error("ApplicationFilterConfig.doAsPrivilege", ex); } SecurityUtil.remove(filter); } else { filter.destroy(); } if (!context.getIgnoreAnnotations()) { try { ((StandardContext) context).getInstanceManager().destroyInstance(this.filter); } catch (Exception e) { Throwable t = ExceptionUtils.unwrapInvocationTargetException(e); ExceptionUtils.handleThrowable(t); context.getLogger().error("ApplicationFilterConfig.preDestroy", t); } } } this.filter = null; }
protected final void handlePojoMethodException(Throwable t) { t = ExceptionUtils.unwrapInvocationTargetException(t); ExceptionUtils.handleThrowable(t); if (t instanceof RuntimeException) { throw (RuntimeException) t; } else { throw new RuntimeException(t); } }
/** * Set the filter definition we are configured for. This has the side effect of instantiating an * instance of the corresponding filter class. * * @param filterDef The new filter definition * @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 */ void setFilterDef(FilterDef filterDef) throws ClassCastException, ClassNotFoundException, IllegalAccessException, InstantiationException, ServletException, InvocationTargetException, NamingException { this.filterDef = filterDef; if (filterDef == null) { // Release any previously allocated filter instance if (this.filter != null) { if (Globals.IS_SECURITY_ENABLED) { try { SecurityUtil.doAsPrivilege("destroy", filter); } catch (java.lang.Exception ex) { context.getLogger().error("ApplicationFilterConfig.doAsPrivilege", ex); } SecurityUtil.remove(filter); } else { filter.destroy(); } if (!context.getIgnoreAnnotations()) { try { ((StandardContext) context).getInstanceManager().destroyInstance(this.filter); } catch (Exception e) { Throwable t = ExceptionUtils.unwrapInvocationTargetException(e); ExceptionUtils.handleThrowable(t); context.getLogger().error("ApplicationFilterConfig.preDestroy", t); } } } this.filter = null; } else { // Allocate a new filter instance if necessary if (filterDef.getFilter() == null) { getFilter(); } } }