public class PackageNamesScanner extends java.lang.Object implements Scanner
The URIs for a package name are obtained, by default, by invoking
ClassLoader.getResources(java.lang.String)
with the parameter that
is the package name with "." replaced by "/". The obtaining of the resources
with a given name may be overridden by registering an implementation of
PackageNamesScanner.ResourcesProvider
using the method
setResourcesProvider(com.sun.jersey.core.spi.scanning.PackageNamesScanner.ResourcesProvider)
.
Each URI is then scanned using a registered UriSchemeScanner
that
supports the URI scheme.
The following are registered by default.
The FileSchemeScanner
for "file" URI schemes.
The JarZipSchemeScanner
for "jar" or "zip" URI schemes to jar
resources.
The VfsSchemeScanner
for the JBoss-based "vfsfile" and "vfszip"
URI schemes.
Further schemes may be registered by registering an implementation of
UriSchemeScanner
in the META-INF/services file whose name is the
the fully qualified class name of UriSchemeScanner
.
If a URI scheme is not supported a ScannerException
will be thrown
and package scanning deployment will fail.
Modifier and Type | Class and Description |
---|---|
static class |
PackageNamesScanner.ResourcesProvider
Find resources with a given name and class loader.
|
Constructor and Description |
---|
PackageNamesScanner(java.lang.ClassLoader classloader,
java.lang.String[] packages)
Scan from a set of packages using declared class loader.
|
PackageNamesScanner(java.lang.String[] packages)
Scan from a set of packages using the context class loader.
|
Modifier and Type | Method and Description |
---|---|
void |
scan(ScannerListener cfl)
Perform a scan and report resources to a scanning listener.
|
static void |
setResourcesProvider(PackageNamesScanner.ResourcesProvider provider)
Set the
PackageNamesScanner.ResourcesProvider implementation to find resources. |
public PackageNamesScanner(java.lang.String[] packages)
packages
- an array of package names.public PackageNamesScanner(java.lang.ClassLoader classloader, java.lang.String[] packages)
classloader
- the class loader to load classes from.packages
- an array of package names.public void scan(ScannerListener cfl)
Scanner
public static void setResourcesProvider(PackageNamesScanner.ResourcesProvider provider) throws java.lang.SecurityException
PackageNamesScanner.ResourcesProvider
implementation to find resources.
This method should be invoked before any package scanning is performed otherwise the functionality method will be utilized.
provider
- the resources provider.java.lang.SecurityException
- if the resources provider cannot be set.Copyright © 2016 Oracle Corporation. All Rights Reserved.