|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.glassfish.jersey.server.internal.scanning.PackageNamesScanner
public class PackageNamesScanner
A scanner that recursively scans URI-based resources present in a set of package names, and nested package names of that set. (Recursive scanning of nested packages can be disabled using a proper constructor.)
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 "/".
Each URI is then scanned using a registered UriSchemeResourceFinderFactory
that
supports the URI scheme.
The following are registered by default.
The FileSchemeResourceFinderFactory
for "file" URI schemes.
The JarZipSchemeResourceFinderFactory
for "jar" or "zip" URI schemes to jar
resources.
The VfsSchemeResourceFinderFactory
for the JBoss-based "vfsfile" and "vfszip"
URI schemes.
Further schemes may be registered by registering an implementation of
UriSchemeResourceFinderFactory
in the META-INF/services file whose name is the
the fully qualified class name of UriSchemeResourceFinderFactory
.
If a URI scheme is not supported a ResourceFinderException
will be thrown
and package scanning deployment will fail.
Nested Class Summary | |
---|---|
static class |
PackageNamesScanner.ResourcesProvider
Find resources with a given name and class loader. |
Constructor Summary | |
---|---|
PackageNamesScanner(ClassLoader classLoader,
String[] packages,
boolean recursive)
Scan a set of packages using the provided ClassLoader . |
|
PackageNamesScanner(String[] packages,
boolean recursive)
Scan a set of packages using a context ClassLoader . |
Method Summary | |
---|---|
boolean |
hasNext()
|
String |
next()
|
InputStream |
open()
Open current resource. |
void |
remove()
This operation is not supported by ResourceFinder & throws UnsupportedOperationException
when invoked. |
void |
reset()
Reset the ResourceFinder instance. |
static void |
setResourcesProvider(PackageNamesScanner.ResourcesProvider provider)
Set the PackageNamesScanner.ResourcesProvider implementation to find resources. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public PackageNamesScanner(String[] packages, boolean recursive)
ClassLoader
.
The recursive
flag determines whether the packages will be scanned recursively
together with their nested packages (true
) or if only the specified packages
shall be scanned (false
).
packages
- an array of package names.recursive
- if (true
the packages will be scanned recursively together with
any nested packages, if false
only the explicitly listed packages
will be scanned.public PackageNamesScanner(ClassLoader classLoader, String[] packages, boolean recursive)
ClassLoader
.
The recursive
flag determines whether the packages will be scanned recursively
together with their nested packages (true
) or if only the specified packages
shall be scanned (false
).
classLoader
- the ClassLoader
to load classes from.packages
- an array of package names.recursive
- if (true
the packages will be scanned recursively together with
any nested packages, if false
only the explicitly listed packages
will be scanned.Method Detail |
---|
public boolean hasNext()
hasNext
in interface Iterator<String>
public String next()
next
in interface Iterator<String>
public void remove()
ResourceFinder
ResourceFinder
& throws UnsupportedOperationException
when invoked.
remove
in interface Iterator<String>
remove
in interface ResourceFinder
public InputStream open()
ResourceFinder
open
in interface ResourceFinder
public void reset()
ResourceFinder
ResourceFinder
instance.
Upon calling this method the implementing class MUST reset its internal state to the initial state.
reset
in interface ResourceFinder
public static void setResourcesProvider(PackageNamesScanner.ResourcesProvider provider) throws 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.
SecurityException
- if the resources provider cannot be set.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |