/** * Make the name of this filter available to subclasses. * Analogous to GenericServlet's {@code getServletName()}. * <p>Takes the FilterConfig's filter name by default. * If initialized as bean in a Spring application context, * it falls back to the bean name as defined in the bean factory. * @return the filter name, or {@code null} if none available * @see javax.servlet.GenericServlet#getServletName() * @see javax.servlet.FilterConfig#getFilterName() * @see #setBeanName */ @Nullable protected String getFilterName() { return (this.filterConfig != null ? this.filterConfig.getFilterName() : this.beanName); }
@Override public String getServletName() { return filterConfig.getFilterName(); }
@Override public String getName() { return filterConfig.getFilterName(); }
@Override public String getFilterName() { return wrapped.getFilterName(); }
@Override public String getName() { return filterConfig.getFilterName(); }
public String getAppName() { return config.getFilterName(); }
/** * Make the name of this filter available to subclasses. * Analogous to GenericServlet's {@code getServletName()}. * <p>Takes the FilterConfig's filter name by default. * If initialized as bean in a Spring application context, * it falls back to the bean name as defined in the bean factory. * @return the filter name, or {@code null} if none available * @see javax.servlet.GenericServlet#getServletName() * @see javax.servlet.FilterConfig#getFilterName() * @see #setBeanName */ @Nullable protected String getFilterName() { return (this.filterConfig != null ? this.filterConfig.getFilterName() : this.beanName); }
public void init(FilterConfig filterConfig) throws ServletException { this.filterConfig = filterConfig; this.beanName = filterConfig.getInitParameter("beanName"); if (Strings.isBlank(beanName)) beanName = filterConfig.getFilterName(); }
/** * Create new FilterConfigPropertyValues. * @param config the FilterConfig we'll use to take PropertyValues from * @param requiredProperties set of property names we need, where * we can't accept default values * @throws ServletException if any required properties are missing */ public FilterConfigPropertyValues(FilterConfig config, Set<String> requiredProperties) throws ServletException { Set<String> missingProps = (!CollectionUtils.isEmpty(requiredProperties) ? new HashSet<>(requiredProperties) : null); Enumeration<String> paramNames = config.getInitParameterNames(); while (paramNames.hasMoreElements()) { String property = paramNames.nextElement(); Object value = config.getInitParameter(property); addPropertyValue(new PropertyValue(property, value)); if (missingProps != null) { missingProps.remove(property); } } // Fail if we are still missing properties. if (!CollectionUtils.isEmpty(missingProps)) { throw new ServletException( "Initialization from FilterConfig for filter '" + config.getFilterName() + "' failed; the following required properties were missing: " + StringUtils.collectionToDelimitedString(missingProps, ", ")); } } }
protected void log(HttpServletRequest httpRequest, String requestName, long duration, boolean systemError, int responseSize) { if (!logEnabled) { return; } final String filterName = filterConfig.getFilterName(); LOG.logHttpRequest(httpRequest, requestName, duration, systemError, responseSize, filterName); }
@Override public List<String> getFilterUrlMappings(FilterConfig filterConfig) { FilterRegistration filterRegistration = filterConfig.getServletContext().getFilterRegistration(filterConfig.getFilterName()); Collection<String> urlPatternMappings = filterRegistration.getUrlPatternMappings(); List<String> result = new ArrayList<>(); for (String pattern : urlPatternMappings) { result.add(pattern.endsWith("*") ? pattern.substring(0, pattern.length() - 1) : pattern); } return result; } }
@Override public List<String> getFilterUrlMappings(FilterConfig filterConfig) { FilterRegistration filterRegistration = filterConfig.getServletContext().getFilterRegistration(filterConfig.getFilterName()); Collection<String> urlPatternMappings = filterRegistration.getUrlPatternMappings(); List<String> result = new ArrayList<>(); for (String pattern : urlPatternMappings) { result.add(pattern.endsWith("*") ? pattern.substring(0, pattern.length() - 1) : pattern); } return result; } }
/** * Returns the filter's name. * <p/> * Unless overridden by calling the {@link #setName(String) setName(String)} method, this value defaults to the * filter name as specified by the servlet container at start-up: * <pre> * this.name = {@link #getFilterConfig() getFilterConfig()}.{@link javax.servlet.FilterConfig#getFilterName() getName()};</pre> * * @return the filter name, or {@code null} if none available * @see javax.servlet.GenericServlet#getServletName() * @see javax.servlet.FilterConfig#getFilterName() */ protected String getName() { if (this.name == null) { FilterConfig config = getFilterConfig(); if (config != null) { this.name = config.getFilterName(); } } return this.name; }
/** * Create new FilterConfigPropertyValues. * @param config the FilterConfig we'll use to take PropertyValues from * @param requiredProperties set of property names we need, where * we can't accept default values * @throws ServletException if any required properties are missing */ public FilterConfigPropertyValues(FilterConfig config, Set<String> requiredProperties) throws ServletException { Set<String> missingProps = (!CollectionUtils.isEmpty(requiredProperties) ? new HashSet<>(requiredProperties) : null); Enumeration<String> paramNames = config.getInitParameterNames(); while (paramNames.hasMoreElements()) { String property = paramNames.nextElement(); Object value = config.getInitParameter(property); addPropertyValue(new PropertyValue(property, value)); if (missingProps != null) { missingProps.remove(property); } } // Fail if we are still missing properties. if (!CollectionUtils.isEmpty(missingProps)) { throw new ServletException( "Initialization from FilterConfig for filter '" + config.getFilterName() + "' failed; the following required properties were missing: " + StringUtils.collectionToDelimitedString(missingProps, ", ")); } } }
filterConfig.getFilterName() + "': " + ex.getMessage(); logger.error(msg, ex); throw new NestedServletException(msg, ex); logger.debug("Filter '" + filterConfig.getFilterName() + "' configured for use");
Mvcs.setServletContext(sc); if ("true".equals(Strings.sNull(conf.getInitParameter("skip-mode"), "false").toLowerCase())) { log.infof("NutFilter[%s] run as skip-mode", conf.getFilterName()); proxyFilter = new NutFilter2(); return; log.infof("NutFilter[%s] starting ...", conf.getFilterName()); this.selfName = conf.getFilterName(); Mvcs.set(selfName, null, null);
filterConfig.getFilterName() + "': " + ex.getMessage(); logger.error(msg, ex); throw new NestedServletException(msg, ex); logger.debug("Filter '" + filterConfig.getFilterName() + "' configured for use");
/** * Returns the filter-name of this filter as defined in the deployment * descriptor. * * @return the filter-name * @see FilterConfig#getFilterName */ public String getFilterName() { return filterConfig.getFilterName(); }
public FilterConfigPropertyValues(FilterConfig config, Set<String> requiredProperties) throws ServletException { Set<String> missingProps = createTreeSet(requiredProperties); for (Enumeration<?> e = config.getInitParameterNames(); e.hasMoreElements(); ) { String key = (String) e.nextElement(); String value = config.getInitParameter(key); addPropertyValue(new PropertyValue(key, value)); missingProps.remove(key); } assertTrue(missingProps.isEmpty(), "Initialization for filter %s failed. " + "The following required properties were missing: %s", config.getFilterName(), missingProps); } }
public FilterConfigPropertyValues(FilterConfig config, Set<String> requiredProperties) throws ServletException { Set<String> missingProps = createTreeSet(requiredProperties); for (Enumeration<?> e = config.getInitParameterNames(); e.hasMoreElements(); ) { String key = (String) e.nextElement(); String value = config.getInitParameter(key); addPropertyValue(new PropertyValue(key, value)); missingProps.remove(key); } assertTrue(missingProps.isEmpty(), "Initialization for filter %s failed. " + "The following required properties were missing: %s", config.getFilterName(), missingProps); } }