@Override public ClassPathScanner createScanner(ClassLoader classLoader) { return new Scanner(classLoader); } }
private boolean readResourcesForPath(String path) { ClassLoader classLoader = migrationConfig.getClassLoader(); Scanner scanner = new Scanner(classLoader); List<Resource> resourceList = scanner.scanForResources(path, new Match(migrationConfig)); logger.debug("resources: {}", resourceList); for (Resource resource : resourceList) { String filename = resource.getFilename(); if (filename.endsWith(migrationConfig.getApplySuffix())) { versions.add(createScriptMigration(resource, filename)); } else if (migrationConfig.getJdbcMigrationFactory() != null && filename.endsWith(".class")) { versions.add(createJdbcMigration(resource, filename)); } } Collections.sort(versions); return !versions.isEmpty(); }
/** * Scans this location for resources matching the given predicate. * <p> * The location can have a prefix of <code>filesystem:</code> or <code>classpath:</code> to determine * how to scan. If no prefix is used then classpath scan is the default. * </p> * * @param location The location to start searching. Subdirectories are also searched. * @param predicate The predicate used to match resource names. * @return The resources that were found. */ @Override public List<Resource> scanForResources(String location, ResourceFilter predicate) { return scanForResources(new Location(location), predicate); }
/** * Scans the classpath for classes under the specified package matching the given predicate. * * @param location The package in the classpath to start scanning. Subpackages are also scanned. * @param predicate The predicate used to match scanned classes. * @return The classes found matching the predicate */ @Override public List<Class<?>> scanForClasses(String location, ClassFilter predicate) { return scanForClasses(new Location(location), predicate); }