final class JarFileResourceLoader extends AbstractResourceLoader implements IterableResourceLoader
Modifier and Type | Class and Description |
---|---|
(package private) static class |
JarFileResourceLoader.CodeSigners |
Modifier and Type | Field and Description |
---|---|
private java.util.Map<JarFileResourceLoader.CodeSigners,java.security.CodeSource> |
codeSources |
private static JarFileResourceLoader.CodeSigners |
EMPTY_CODE_SIGNERS |
private java.io.File |
fileOfJar |
private static java.lang.String |
INDEX_FILE |
private java.util.jar.JarFile |
jarFile |
private java.lang.String |
relativePath |
private java.lang.String |
rootName |
private java.net.URL |
rootUrl |
Constructor and Description |
---|
JarFileResourceLoader(java.lang.String rootName,
java.util.jar.JarFile jarFile) |
JarFileResourceLoader(java.lang.String rootName,
java.util.jar.JarFile jarFile,
java.lang.String relativePath) |
Modifier and Type | Method and Description |
---|---|
(package private) static void |
addInternalIndex(java.io.File file,
boolean modify) |
void |
close()
Closes this resource, relinquishing any underlying resources.
|
private java.security.CodeSource |
createCodeSource(java.util.jar.JarEntry entry) |
(package private) static void |
extractJarPaths(java.util.jar.JarFile jarFile,
java.lang.String relativePath,
java.util.Collection<java.lang.String> index) |
ClassSpec |
getClassSpec(java.lang.String fileName)
Get the class specification for the given class name.
|
private java.util.jar.JarEntry |
getJarEntry(java.lang.String fileName) |
private static java.net.URI |
getJarURI(java.net.URI original,
java.lang.String nestedPath) |
java.lang.String |
getLibrary(java.lang.String name)
Get the absolute physical filesystem path for a library with the given name.
|
java.net.URI |
getLocation()
Get the base location of the resources in this loader (if any).
|
PackageSpec |
getPackageSpec(java.lang.String name)
Get the package specification for the given directory name.
|
java.util.Collection<java.lang.String> |
getPaths()
Get the collection of resource paths.
|
Resource |
getResource(java.lang.String name)
Get a resource with the given name.
|
java.lang.String |
getRootName()
Get the name of the root represented by this resource loader.
|
java.util.Iterator<Resource> |
iterateResources(java.lang.String startPath,
boolean recursive)
Enumerate all the resources under the given path.
|
(package private) static java.util.Collection<java.lang.String> |
readIndex(java.io.InputStream stream,
java.util.Collection<java.lang.String> index,
java.lang.String relativePath) |
(package private) static void |
writeExternalIndex(java.io.File indexFile,
java.util.Collection<java.lang.String> index) |
getPackageSpec
private static final java.lang.String INDEX_FILE
private final java.util.jar.JarFile jarFile
private final java.lang.String rootName
private final java.net.URL rootUrl
private final java.lang.String relativePath
private final java.io.File fileOfJar
private final java.util.Map<JarFileResourceLoader.CodeSigners,java.security.CodeSource> codeSources
private static final JarFileResourceLoader.CodeSigners EMPTY_CODE_SIGNERS
JarFileResourceLoader(java.lang.String rootName, java.util.jar.JarFile jarFile)
JarFileResourceLoader(java.lang.String rootName, java.util.jar.JarFile jarFile, java.lang.String relativePath)
private static java.net.URI getJarURI(java.net.URI original, java.lang.String nestedPath) throws java.net.URISyntaxException
java.net.URISyntaxException
public java.lang.String getRootName()
ResourceLoader
getRootName
in interface ResourceLoader
getRootName
in class AbstractResourceLoader
public ClassSpec getClassSpec(java.lang.String fileName) throws java.io.IOException
ResourceLoader
null
is returned.getClassSpec
in interface ResourceLoader
getClassSpec
in class AbstractResourceLoader
fileName
- the fileName of the class, e.g. for the class org.jboss.modules.ResourceLoader
the fileName will be org/jboss/modules/ResourceLoader.class
null
if the named class is not foundjava.io.IOException
- if an I/O error occursprivate java.security.CodeSource createCodeSource(java.util.jar.JarEntry entry)
private java.util.jar.JarEntry getJarEntry(java.lang.String fileName)
public PackageSpec getPackageSpec(java.lang.String name) throws java.io.IOException
ResourceLoader
/
" separators.getPackageSpec
in interface ResourceLoader
getPackageSpec
in class AbstractResourceLoader
name
- the directory namejava.io.IOException
- if an I/O error occurspublic java.lang.String getLibrary(java.lang.String name)
ResourceLoader
/
" characters.getLibrary
in interface ResourceLoader
getLibrary
in class AbstractResourceLoader
name
- the namenull
if the library is not presentpublic Resource getResource(java.lang.String name)
ResourceLoader
null
is returned.
The resource name will always be specified using "/
" separators for the directory segments.getResource
in interface ResourceLoader
getResource
in class AbstractResourceLoader
name
- the resource namenull
if it is not availablepublic java.util.Iterator<Resource> iterateResources(java.lang.String startPath, boolean recursive)
IterableResourceLoader
..
, such segments will be consumed.
If the path is absolute, it will be converted to a relative path by dropping the leading /
.iterateResources
in interface IterableResourceLoader
startPath
- the path to search underrecursive
- true
to recursively descend into subdirectories, false
to only read this pathpublic java.util.Collection<java.lang.String> getPaths()
ResourceLoader
/
" characters to separate the path segments.getPaths
in interface ResourceLoader
getPaths
in class AbstractResourceLoader
public void close()
ResourceLoader
try
-with-resources statement.close
in interface java.lang.AutoCloseable
close
in interface ResourceLoader
public java.net.URI getLocation()
ResourceLoader
null
is returned.getLocation
in interface ResourceLoader
null
if not availablestatic void extractJarPaths(java.util.jar.JarFile jarFile, java.lang.String relativePath, java.util.Collection<java.lang.String> index)
static void writeExternalIndex(java.io.File indexFile, java.util.Collection<java.lang.String> index)
static java.util.Collection<java.lang.String> readIndex(java.io.InputStream stream, java.util.Collection<java.lang.String> index, java.lang.String relativePath) throws java.io.IOException
java.io.IOException
static void addInternalIndex(java.io.File file, boolean modify) throws java.io.IOException
java.io.IOException