Class ResourceScanner

java.lang.Object
org.jboss.resteasy.core.scanner.ResourceScanner

public class ResourceScanner extends Object
A scanner for locating resources.
Since:
6.1
Author:
James R. Perkins
  • Method Details

    • fromClassPath

      public static ResourceScanner fromClassPath(ClassLoader cl) throws IOException
      Creates a new scanner. This first searches for META-INF/jandex.idx resources on the class path. If no index resources are found, the class path itself is indexed. Note that scanning the class path could have significant performance impacts.
      Parameters:
      cl - the class loader to find the indexes on
      Returns:
      a new resource scanner
      Throws:
      IOException - if there is an error reading the index
    • fromClassPath

      public static ResourceScanner fromClassPath(ClassLoader cl, Predicate<Path> filter) throws IOException
      Creates a new scanner. This first searches for META-INF/jandex.idx resources on the class path ignoring the filter. If no index resources are found, the class path itself is indexed. Note that scanning the class path could have significant performance impacts.

      A filter can be used to exclude certain paths from being processed. For example if you want only *.class files to be processed you could add a filter like:

      final ResourceScanner.fromClassPath(Thread.currentThread().getContextClassLoader(),
                        (path) -> path.getFileName().toString().endsWith(".class"));

      Parameters:
      cl - the class loader to find the indexes on
      filter - a filter to exclude paths, null can be passed to use no filter
      Returns:
      a new resource scanner
      Throws:
      IOException - if there is an error reading the index
    • of

      public static ResourceScanner of(org.jboss.jandex.Index index)
      Creates a new scanner based on the index.
      Parameters:
      index - the index to search resources on
      Returns:
      a new resource scanner
    • getApplications

      public Set<String> getApplications()
      Returns the class names for any applications found. This includes applications annotated with @ApplicationPath or subclasses of Application.
      Returns:
      applications found in the index
    • getProviders

      public Set<String> getProviders()
      Returns all classes annotated with @Provider.
      Returns:
      all providers found
    • getResources

      public Set<String> getResources()
      Returns resources that are annotated with @Path.
      Returns:
      all the resources found
    • getTypesAnnotatedWith

      public Set<String> getTypesAnnotatedWith(org.jboss.jandex.DotName annotation)
      Returns the types with the provided annotation.
      Parameters:
      annotation - the annotation used to scan fort the types
      Returns:
      all the types found for the annotation