Package org.jboss.resteasy.core.scanner
Class ResourceScanner
java.lang.Object
org.jboss.resteasy.core.scanner.ResourceScanner
A scanner for locating resources.
- Since:
- 6.1
- Author:
- James R. Perkins
-
Method Summary
Modifier and TypeMethodDescriptionstatic ResourceScannerCreates a new scanner.static ResourceScannerfromClassPath(ClassLoader cl, Predicate<Path> filter) Creates a new scanner.Returns the class names for any applications found.Returns all classes annotated with@Provider.Returns resources that are annotated with@Path.getTypesAnnotatedWith(org.jboss.jandex.DotName annotation) Returns the types with the provided annotation.static ResourceScannerof(org.jboss.jandex.Index index) Creates a new scanner based on the index.
-
Method Details
-
fromClassPath
Creates a new scanner. This first searches forMETA-INF/jandex.idxresources 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 forMETA-INF/jandex.idxresources on the class path ignoring thefilter. 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
*.classfiles 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 onfilter- a filter to exclude paths,nullcan be passed to use no filter- Returns:
- a new resource scanner
- Throws:
IOException- if there is an error reading the index
-
of
Creates a new scanner based on the index.- Parameters:
index- the index to search resources on- Returns:
- a new resource scanner
-
getApplications
Returns the class names for any applications found. This includes applications annotated with@ApplicationPathor subclasses ofApplication.- Returns:
- applications found in the index
-
getProviders
Returns all classes annotated with@Provider.- Returns:
- all providers found
-
getResources
Returns resources that are annotated with@Path.- Returns:
- all the resources found
-
getTypesAnnotatedWith
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
-