Package org.jboss.modules
Class JarFileResourceLoader
java.lang.Object
org.jboss.modules.AbstractResourceLoader
org.jboss.modules.JarFileResourceLoader
- All Implemented Interfaces:
AutoCloseable
,IterableResourceLoader
,ResourceLoader
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescription(package private) static final class
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final Map
<JarFileResourceLoader.CodeSigners, CodeSource> private static final JarFileResourceLoader.CodeSigners
private final File
private static final String
private final JarFile
private final String
private final String
private final URL
-
Constructor Summary
ConstructorsConstructorDescriptionJarFileResourceLoader
(String rootName, JarFile jarFile) JarFileResourceLoader
(String rootName, JarFile jarFile, String relativePath) -
Method Summary
Modifier and TypeMethodDescription(package private) static void
addInternalIndex
(File file, boolean modify) void
close()
Closes this resource, relinquishing any underlying resources.private CodeSource
createCodeSource
(JarEntry entry) (package private) static void
extractJarPaths
(JarFile jarFile, String relativePath, Collection<String> index) getClassSpec
(String fileName) Get the class specification for the given class name.private JarEntry
getJarEntry
(String fileName) private static URI
getLibrary
(String name) Get the absolute physical filesystem path for a library with the given name.Get the base location of the resources in this loader (if any).getPackageSpec
(String name) Get the package specification for the given directory name.getPaths()
Get the collection of resource paths.getResource
(String name) Get a resource with the given name.Get the name of the root represented by this resource loader.iterateResources
(String startPath, boolean recursive) Enumerate all the resources under the given path.(package private) static Collection
<String> readIndex
(InputStream stream, Collection<String> index, String relativePath) (package private) static void
writeExternalIndex
(File indexFile, Collection<String> index) Methods inherited from class org.jboss.modules.AbstractResourceLoader
getPackageSpec
-
Field Details
-
INDEX_FILE
- See Also:
-
jarFile
-
rootName
-
rootUrl
-
relativePath
-
fileOfJar
-
codeSources
-
EMPTY_CODE_SIGNERS
-
-
Constructor Details
-
JarFileResourceLoader
-
JarFileResourceLoader
-
-
Method Details
-
getJarURI
- Throws:
URISyntaxException
-
getRootName
Description copied from interface:ResourceLoader
Get the name of the root represented by this resource loader.- Specified by:
getRootName
in interfaceResourceLoader
- Overrides:
getRootName
in classAbstractResourceLoader
- Returns:
- the name of the root
-
getClassSpec
Description copied from interface:ResourceLoader
Get the class specification for the given class name. If no matching class is found,null
is returned.- Specified by:
getClassSpec
in interfaceResourceLoader
- Overrides:
getClassSpec
in classAbstractResourceLoader
- Parameters:
fileName
- the fileName of the class, e.g. for the classorg.jboss.modules.ResourceLoader
the fileName will beorg/jboss/modules/ResourceLoader.class
- Returns:
- the class specification, or
null
if the named class is not found - Throws:
IOException
- if an I/O error occurs
-
createCodeSource
-
getJarEntry
-
getPackageSpec
Description copied from interface:ResourceLoader
Get the package specification for the given directory name. Always returns a package specification; this method cannot be used to test for the existence of a package. A package spec should always be acquired from the same resource loader which provided the class specification. The directory name will always be specified using "/
" separators.- Specified by:
getPackageSpec
in interfaceResourceLoader
- Overrides:
getPackageSpec
in classAbstractResourceLoader
- Parameters:
name
- the directory name- Returns:
- the package specification
- Throws:
IOException
- if an I/O error occurs
-
getLibrary
Description copied from interface:ResourceLoader
Get the absolute physical filesystem path for a library with the given name. The resultant path should be path-separated using "/
" characters.- Specified by:
getLibrary
in interfaceResourceLoader
- Overrides:
getLibrary
in classAbstractResourceLoader
- Parameters:
name
- the name- Returns:
- the path or
null
if the library is not present
-
getResource
Description copied from interface:ResourceLoader
Get a resource with the given name. If no such resource is available,null
is returned. The resource name will always be specified using "/
" separators for the directory segments.- Specified by:
getResource
in interfaceResourceLoader
- Overrides:
getResource
in classAbstractResourceLoader
- Parameters:
name
- the resource name- Returns:
- the resource, or
null
if it is not available
-
iterateResources
Description copied from interface:IterableResourceLoader
Enumerate all the resources under the given path. The given path name is relative to the root of the resource loader. If the path "escapes" the root via..
, such segments will be consumed. If the path is absolute, it will be converted to a relative path by dropping the leading/
.- Specified by:
iterateResources
in interfaceIterableResourceLoader
- Parameters:
startPath
- the path to search underrecursive
-true
to recursively descend into subdirectories,false
to only read this path- Returns:
- the resource iterator (possibly empty)
-
getPaths
Description copied from interface:ResourceLoader
Get the collection of resource paths. Called one time only when the resource loader is initialized. The paths should use "/
" characters to separate the path segments.- Specified by:
getPaths
in interfaceResourceLoader
- Overrides:
getPaths
in classAbstractResourceLoader
- Returns:
- the resource paths
-
close
public void close()Description copied from interface:ResourceLoader
Closes this resource, relinquishing any underlying resources. This method is invoked automatically on objects managed by thetry
-with-resources statement.- Specified by:
close
in interfaceAutoCloseable
- Specified by:
close
in interfaceResourceLoader
-
getLocation
Description copied from interface:ResourceLoader
Get the base location of the resources in this loader (if any). If the location is not known, or the resource loader does not support locations, or the resource loader does not support this method,null
is returned.- Specified by:
getLocation
in interfaceResourceLoader
- Returns:
- the base location of the resources in this loader, or
null
if not available
-
extractJarPaths
-
writeExternalIndex
-
readIndex
static Collection<String> readIndex(InputStream stream, Collection<String> index, String relativePath) throws IOException - Throws:
IOException
-
addInternalIndex
- Throws:
IOException
-