private static void findClasses()

in tajo-core/tajo-core-backend/src/main/java/org/apache/tajo/util/ClassUtil.java [50:98]


  private static void findClasses(Set<Class> matchedClassSet, File root, File file, boolean includeJars, Class type, String packageFilter) {
    if (file.isDirectory()) {
      for (File child : file.listFiles()) {
        findClasses(matchedClassSet, root, child, includeJars, type, packageFilter);
      }
    } else {
      if (file.getName().toLowerCase().endsWith(".jar") && includeJars) {
        JarFile jar = null;
        try {
          jar = new JarFile(file);
        } catch (Exception ex) {
          LOG.error(ex.getMessage(), ex);
          return;
        }
        Enumeration<JarEntry> entries = jar.entries();
        while (entries.hasMoreElements()) {
          JarEntry entry = entries.nextElement();
          String name = entry.getName();
          int extIndex = name.lastIndexOf(".class");
          if (extIndex > 0) {
            String qualifiedClassName = name.substring(0, extIndex).replace("/", ".");
            if (qualifiedClassName.indexOf(packageFilter) >= 0 && !isTestClass(qualifiedClassName)) {
              try {
                Class clazz = Class.forName(qualifiedClassName);

                if (!clazz.isInterface() && isMatch(type, clazz)) {
                  matchedClassSet.add(clazz);
                }
              } catch (ClassNotFoundException e) {
                LOG.error(e.getMessage(), e);
              }
            }
          }
        }
      } else if (file.getName().toLowerCase().endsWith(".class")) {
        String qualifiedClassName = createClassName(root, file);
        if (qualifiedClassName.indexOf(packageFilter) >= 0 && !isTestClass(qualifiedClassName)) {
          try {
            Class clazz = Class.forName(qualifiedClassName);
            if (!clazz.isInterface() && isMatch(type, clazz)) {
              matchedClassSet.add(clazz);
            }
          } catch (ClassNotFoundException e) {
            LOG.error(e.getMessage(), e);
          }
        }
      }
    }
  }