Пример #1
0
  protected void configureLoaderProperties(
      WebappClassLoader cloader, WebXmlParser webXmlParser, File base) {

    cloader.setUseMyFaces(webXmlParser.isUseBundledJSF());

    File libDir = new File(base, "WEB-INF/lib");
    if (libDir.exists()) {
      int baseFileLen = base.getPath().length();
      final boolean ignoreHiddenJarFiles = webXmlParser.isIgnoreHiddenJarFiles();

      for (File file :
          libDir.listFiles(
              new FileFilter() {
                @Override
                public boolean accept(File pathname) {
                  String fileName = pathname.getName();
                  return ((fileName.endsWith(".jar") || fileName.endsWith(".zip"))
                      && (!ignoreHiddenJarFiles || !fileName.startsWith(".")));
                }
              })) {
        try {
          if (file.isDirectory()) {
            // support exploded jar file
            cloader.addRepository("WEB-INF/lib/" + file.getName() + "/", file);
          } else {
            cloader.addJar(file.getPath().substring(baseFileLen), new JarFile(file), file);
            cloader.closeJARs(true);
          }
        } catch (Exception e) {
          // Catch and ignore any exception in case the JAR file
          // is empty.
        }
      }
    }
  }