예제 #1
0
  protected void scan(URL url) {
    Vfs.Dir dir = Vfs.fromURL(url);

    try {
      for (final Vfs.File file : dir.getFiles()) {
        // scan if inputs filter accepts file relative path or fqn
        Predicate<String> inputsFilter = configuration.getInputsFilter();
        String path = file.getRelativePath();
        String fqn = path.replace('/', '.');
        if (inputsFilter == null || inputsFilter.apply(path) || inputsFilter.apply(fqn)) {
          Object classObject = null;
          for (Scanner scanner : configuration.getScanners()) {
            try {
              if (scanner.acceptsInput(path) || scanner.acceptResult(fqn)) {
                classObject = scanner.scan(file, classObject);
              }
            } catch (Exception e) {
              if (log != null && log.isDebugEnabled())
                log.debug(
                    "could not scan file "
                        + file.getRelativePath()
                        + " in url "
                        + url.toExternalForm()
                        + " with scanner "
                        + scanner.getClass().getSimpleName(),
                    e);
            }
          }
        }
      }
    } finally {
      dir.close();
    }
  }
예제 #2
0
 public void index() {
   for (URL url : configuration.getUrls()) {
     try {
       for (final Vfs.File file : Vfs.fromURL(url).getFiles()) {
         String input = file.getRelativePath().replace('/', '.');
         if (configuration.acceptsInput(input)) {
           for (Scanner scanner : configuration.getScanners()) {
             try {
               if (scanner.acceptsInput(input)) {
                 scanner.scan(file);
               }
             } catch (Exception e) {
             }
           }
         }
       }
     } catch (ReflectionsException e) {
     }
   }
 }