Tabnine Logo
org.avaje.classpath.scanner
Code IndexAdd Tabnine to your IDE (free)

How to use org.avaje.classpath.scanner

Best Java code snippets using org.avaje.classpath.scanner (Showing top 20 results out of 315)

origin: ebean-orm/ebean

 /**
  * Read the deployment XML for the given resources.
  */
 public static List<XmEbean> readByResourceList(List<Resource> resourceList){
  try {
   List<XmEbean> mappings = new ArrayList<>();
   for (Resource xmlMappingRes : resourceList) {
    try (InputStream is = new FileInputStream(xmlMappingRes.getLocationOnDisk())) {
     mappings.add(XmlMappingReader.read(is));
    }
   }
   return mappings;
  } catch (IOException e) {
   throw new RuntimeException("Error reading ebean xml mapping", e);
  }
 }
}
origin: ebean-orm/ebean

/**
 * Search the classPath for the classes we are interested in.
 */
private BootupClasses getBootupClasses() {
 try {
  BootupClasses bc = new BootupClasses();
  long st = System.currentTimeMillis();
  for (ClassPathScanner finder : this.scanners) {
   if (packages != null && !packages.isEmpty()) {
    for (String packageName : packages) {
     finder.scanForClasses(packageName, bc);
    }
   } else {
    // scan locally
    finder.scanForClasses("", bc);
   }
  }
  long searchTime = System.currentTimeMillis() - st;
  logger.debug("Classpath search entities[{}] searchTime[{}] in packages[{}]", bc.getEntities().size(), searchTime, packages);
  return bc;
 } catch (Exception ex) {
  throw new RuntimeException("Error in classpath search (looking for entities etc)", ex);
 }
}
origin: ebean-orm/ebean

 /**
  * Return the list of ClassPathScanner services using serverConfig service loader.
  */
 public static List<ClassPathScanner> find(ServerConfig serverConfig) {

  List<ClassPathScanner> scanners = new ArrayList<>();
  for (ClassPathScannerFactory factory : serverConfig.serviceLoad(ClassPathScannerFactory.class)) {
   scanners.add(factory.createScanner(serverConfig.getClassLoadConfig().getClassLoader()));
  }
  return scanners;
 }
}
origin: io.ebean/ebean-dbmigration

/**
 * Read all the migration resources (SQL scripts) returning true if there are versions.
 */
public boolean readResources() {
 String migrationPath = migrationConfig.getMigrationPath();
 ClassLoader classLoader = migrationConfig.getClassLoader();
 Scanner scanner = new Scanner(classLoader);
 List<Resource> resourceList = scanner.scanForResources(migrationPath, new Match(migrationConfig));
 logger.debug("resources: {}", resourceList);
 for (Resource resource : resourceList) {
  String filename = resource.getFilename();
  if (filename.endsWith(migrationConfig.getApplySuffix())) {
   int pos = filename.lastIndexOf(migrationConfig.getApplySuffix());
   String mainName = filename.substring(0, pos);
   MigrationVersion migrationVersion = MigrationVersion.parse(mainName);
   LocalMigrationResource res = new LocalMigrationResource(migrationVersion, resource.getLocation(), resource);
   versions.add(res);
  }
 }
 Collections.sort(versions);
 return !versions.isEmpty();
}
origin: org.avaje/avaje-classpath-scanner

@Override
public List<Class<?>> scanForClasses(Location location, ClassFilter predicate) {
 try {
  List<Class<?>> classes = new ArrayList<Class<?>>();
  Set<String> resourceNames = findResourceNames(location, FilterResource.bySuffix(".class"));
  LOG.debug("scanning for classes at {} found {} resources to check", location, resourceNames.size());
  for (String resourceName : resourceNames) {
   String className = toClassName(resourceName);
   try {
    Class<?> clazz = classLoader.loadClass(className);
    if (predicate.isMatch(clazz)) {
     classes.add(clazz);
     LOG.trace("... matched class: {} ", className);
    }
   } catch (NoClassDefFoundError err) {
    // This happens on class that inherits from an other class which are no longer in the classpath
    // e.g. "public class MyTestRunner extends BlockJUnit4ClassRunner" and junit was in scope "provided" 
    LOG.debug("... class " + className + " could not be loaded and will be ignored.", err);
   } catch (ClassNotFoundException err) {
    // This happens on class that inherits from an other class which are no longer in the classpath
    // e.g. "public class MyTestRunner extends BlockJUnit4ClassRunner" and junit was in scope "provided"
    LOG.debug("... class " + className + " could not be loaded and will be ignored.", err);
   }
  }
  return classes;
 } catch (IOException e) {
  throw new ClassPathScanException(e);
 }
}
origin: org.avaje/avaje-dbmigration

/**
 * Return the content for the migration apply ddl script.
 */
public String getContent() {
 return resource.loadAsString("UTF-8");
}
origin: io.ebean/ebean-migration

/**
 * Return a programmatic JDBC migration.
 */
private LocalMigrationResource createJdbcMigration(Resource resource, String filename) {
 int pos = filename.lastIndexOf(".class");
 String mainName = filename.substring(0, pos);
 MigrationVersion migrationVersion = MigrationVersion.parse(mainName);
 String className = resource.getLocation().replace('/', '.');
 className = className.substring(0, className.length()-6);
 JdbcMigration instance = migrationConfig.getJdbcMigrationFactory().createInstance(className);
 return new LocalJdbcMigrationResource(migrationVersion, resource.getLocation(), instance);
}
origin: org.avaje/avaje-classpath-scanner

 /**
  * Filters this list of resource names to only include the ones whose filename matches this prefix and this suffix.
  */
 private Set<String> filterResourceNames(Set<String> resourceNames, ResourceFilter predicate) {
  Set<String> filteredResourceNames = new TreeSet<String>();
  for (String resourceName : resourceNames) {
   if (predicate.isMatch(resourceName)) {
    filteredResourceNames.add(resourceName);
   }
  }
  return filteredResourceNames;
 }
}
origin: ebean-orm/ebean

private List<Resource> xmlMappingResources() {
 List<ClassPathScanner> scanners = ClassPathScanners.find(serverConfig);
 List<String> mappingLocations = serverConfig.getMappingLocations();
 List<Resource> resourceList = new ArrayList<>();
 long st = System.currentTimeMillis();
 if (mappingLocations != null && !mappingLocations.isEmpty()) {
  for (ClassPathScanner finder : scanners) {
   for (String mappingLocation : mappingLocations) {
    resourceList.addAll(finder.scanForResources(mappingLocation, resourceName -> resourceName.endsWith(".xml")));
   }
  }
 }
 long searchTime = System.currentTimeMillis() - st;
 log.debug("Classpath search mappings[{}] searchTime[{}]", resourceList.size(), searchTime);
 return resourceList;
}
origin: org.avaje/avaje-classpath-scanner-api

/**
 * Return a resource matcher that matches by suffix.
 */
public static ResourceFilter bySuffix(String suffix) {
 return new BySuffix(suffix);
}
origin: org.avaje/avaje-classpath-scanner-api

/**
 * Return a resource matcher that matches by both prefix and suffix.
 */
public static ResourceFilter byPrefixSuffix(String prefix, String suffix) {
 return new ByPrefixSuffix(prefix, suffix);
}
origin: org.avaje/avaje-classpath-scanner-api

/**
 * Return a resource matcher that matches by prefix.
 */
public static ResourceFilter byPrefix(String prefix) {
 return new ByPrefix(prefix);
}
origin: org.avaje/avaje-dbmigration

/**
 * Read all the migration resources (SQL scripts) returning true if there are versions.
 */
public boolean readResources() {
 String migrationPath = migrationConfig.getMigrationPath();
 ClassLoader classLoader = migrationConfig.getClassLoader();
 Scanner scanner = new Scanner(classLoader);
 List<Resource> resourceList = scanner.scanForResources(migrationPath, new Match(migrationConfig));
 logger.debug("resources: {}", resourceList);
 for (Resource resource : resourceList) {
  String filename = resource.getFilename();
  if (filename.endsWith(migrationConfig.getApplySuffix())) {
   int pos = filename.lastIndexOf(migrationConfig.getApplySuffix());
   String mainName = filename.substring(0, pos);
   MigrationVersion migrationVersion = MigrationVersion.parse(mainName);
   LocalMigrationResource res = new LocalMigrationResource(migrationVersion, resource.getLocation(), resource);
   versions.add(res);
  }
 }
 Collections.sort(versions);
 return !versions.isEmpty();
}
origin: io.ebean/ebean-migration

/**
 * Return the content for the migration apply ddl script.
 */
public String getContent() {
 return resource.loadAsString("UTF-8");
}
origin: io.ebean/ebean-migration

/**
 * Create a script based migration.
 */
private LocalMigrationResource createScriptMigration(Resource resource, String filename) {
 int pos = filename.lastIndexOf(migrationConfig.getApplySuffix());
 String mainName = filename.substring(0, pos);
 MigrationVersion migrationVersion = MigrationVersion.parse(mainName);
 return new LocalDdlMigrationResource(migrationVersion, resource.getLocation(), resource);
}
origin: io.ebean/ebean

 /**
  * Return the list of ClassPathScanner services using serverConfig service loader.
  */
 public static List<ClassPathScanner> find(ServerConfig serverConfig) {

  List<ClassPathScanner> scanners = new ArrayList<>();
  for (ClassPathScannerFactory factory : serverConfig.serviceLoad(ClassPathScannerFactory.class)) {
   scanners.add(factory.createScanner(serverConfig.getClassLoadConfig().getClassLoader()));
  }
  return scanners;
 }
}
origin: io.ebean/ebean

 /**
  * Read the deployment XML for the given resources.
  */
 public static List<XmEbean> readByResourceList(List<Resource> resourceList){
  try {
   List<XmEbean> mappings = new ArrayList<>();
   for (Resource xmlMappingRes : resourceList) {
    try (InputStream is = new FileInputStream(xmlMappingRes.getLocationOnDisk())) {
     mappings.add(XmlMappingReader.read(is));
    }
   }
   return mappings;
  } catch (IOException e) {
   throw new RuntimeException("Error reading ebean xml mapping", e);
  }
 }
}
origin: org.avaje/avaje-classpath-scanner

 /**
  * Filters this list of resource names to only include the ones whose filename matches this prefix and this suffix.
  */
 private Set<String> filterResourceNames(Set<String> resourceNames, ResourceFilter predicate) {

  Set<String> filteredResourceNames = new TreeSet<String>();
  for (String resourceName : resourceNames) {
   if (predicate.isMatch(resourceName)) {
    filteredResourceNames.add(resourceName);
   }
  }
  return filteredResourceNames;
 }
}
origin: io.ebean/ebean-dbmigration

/**
 * Return the content for the migration apply ddl script.
 */
public String getContent() {
 return resource.loadAsString("UTF-8");
}
origin: org.avaje.ebean/ebean

 /**
  * Return the list of ClassPathScanner services using serverConfig service loader.
  */
 public static List<ClassPathScanner> find(ServerConfig serverConfig) {

  List<ClassPathScanner> scanners = new ArrayList<>();

  ServiceLoader<ClassPathScannerFactory> scannerLoader = serverConfig.serviceLoad(ClassPathScannerFactory.class);
  for (ClassPathScannerFactory factory : scannerLoader) {
   ClassPathScanner scanner = factory.createScanner(serverConfig.getClassLoadConfig().getClassLoader());
   scanners.add(scanner);
  }

  return scanners;
 }
}
org.avaje.classpath.scanner

Most used classes

  • Resource
    A loadable resource.
  • ClassPathScanner
    Scans the class path for resources or classes.
  • ClassPathScannerFactory
    Factory for the ClassPathScanner service.
  • Scanner
    Scanner for Resources and Classes.
  • Scanner
    Scanner for Resources and Classes.
  • FilterResource$ByPrefix,
  • FilterResource$ByPrefixSuffix,
  • FilterResource$BySuffix,
  • FilterResource,
  • ResourceFilter,
  • ContextHolder,
  • ClassPathScanException,
  • Location,
  • EnvironmentDetection,
  • FileCopyUtils,
  • ResourceAndClassScanner,
  • UrlUtils,
  • ClassPathLocationScanner,
  • ClassPathResource
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now