/** * Instantiates the given Filter class and performs any required resource injection into the new * Filter instance before returning it. */ @Override @SuppressWarnings("unchecked") // doPrivileged() returns the correct type public <T extends Filter> T createFilter(Class<T> clazz) throws ServletException { if (SecurityUtil.isPackageProtectionEnabled()) { return (T) doPrivileged("createFilter", new Object[] {clazz}); } else { return context.createFilter(clazz); } }
@Override @SuppressWarnings("unchecked") // doPrivileged() returns the correct type public <T extends Filter> T createFilter(Class<T> c) throws ServletException { if (SecurityUtil.isPackageProtectionEnabled()) { try { return (T) invokeMethod(context, "createFilter", new Object[] {c}); } catch (Throwable t) { ExceptionUtils.handleThrowable(t); if (t instanceof ServletException) { throw (ServletException) t; } return null; } } else { return context.createFilter(c); } }