コード例 #1
0
ファイル: ConfigKit.java プロジェクト: qinggp/jfinal-ext
  /**
   * @param includeResources
   * @param excludeResources
   * @param reload
   */
  static void init(List<String> includeResources, List<String> excludeResources, boolean reload) {
    ConfigKit.includeResources = includeResources;
    ConfigKit.excludeResources = excludeResources;
    ConfigKit.reload = reload;
    for (final String resource : includeResources) {
      LOG.debug("include :" + resource);
      File[] propertiesFiles = null;
      propertiesFiles =
          new File(PathKit.getRootClassPath())
              .listFiles(
                  new FileFilter() {

                    @Override
                    public boolean accept(File pathname) {
                      return Pattern.compile(resource).matcher(pathname.getName()).matches();
                    }
                  });
      for (File file : propertiesFiles) {
        String fileName = file.getAbsolutePath();
        LOG.debug("fileName:" + fileName);
        if (fileName.endsWith("-test." + ConfigPlugin.getSuffix())) {
          continue;
        }
        boolean excluded = false;
        for (String exclude : excludeResources) {
          if (Pattern.compile(exclude).matcher(file.getName()).matches()) {
            excluded = true;
          }
        }
        if (excluded) {
          continue;
        }
        lastmodifies.put(fileName, new File(fileName).lastModified());
        map = ResourceKit.readProperties(fileName);
        testMap = ResourceKit.readProperties(testFileName(fileName));
      }
    }
    LOG.debug("map" + map);
    LOG.debug("testMap" + testMap);
    LOG.info("config init success!");
  }
コード例 #2
0
ファイル: ConfigKit.java プロジェクト: qinggp/jfinal-ext
 private static String testFileName(String fileName) {
   return fileName.substring(0, fileName.indexOf("." + ConfigPlugin.getSuffix()))
       + "-test."
       + ConfigPlugin.getSuffix();
 }