Пример #1
0
 public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain)
     throws IOException, ServletException {
   AbstractConfiguration conf = WebConfig.getConfig();
   for (Iterator<String> it = conf.getKeys(); it.hasNext(); ) {
     String key = it.next();
     String value = conf.getString(key);
     request.setAttribute(key, value);
   }
   chain.doFilter(request, response);
 }
Пример #2
0
 public void init(FilterConfig filterConfig) throws ServletException {
   String f = filterConfig.getInitParameter("configFile");
   if (StringUtils.isBlank(f)) {
     f = "classpath:webconfig.xml";
     System.err.println("com.unicom.mini.filter.WebConfig使用默认配置" + f); // NOSONAR 为了避免在容器启动时无法输出日志
   }
   final String configFile = f;
   int refreshInterval = DEFAULT_REFRESH_INTERVAL;
   String refreshIntervalStr = filterConfig.getInitParameter("refreshInterval");
   if (refreshIntervalStr != null && refreshIntervalStr.trim().length() > 0) {
     try {
       refreshInterval = Integer.valueOf(refreshIntervalStr);
     } catch (Exception ex) {
       System.err.println("refreshInterval参数必须为int类型数字."); // NOSONAR 为了避免在容器启动时无法输出日志
     }
   }
   WebConfig.loadConfig(configFile, refreshInterval);
 }
Пример #3
0
 public static void loadConfig(String configFile, int refreshInterval) {
   XMLPropertiesConfiguration conf =
       ConfigLoader.loadXMLPropertiesConfiguration(configFile, refreshInterval);
   WebConfig.setConfig(conf);
 }