Package org.jboss.modules
Class JarFileResourceLoader
- java.lang.Object
-
- org.jboss.modules.AbstractResourceLoader
-
- org.jboss.modules.JarFileResourceLoader
-
- All Implemented Interfaces:
java.lang.AutoCloseable,IterableResourceLoader,ResourceLoader
final class JarFileResourceLoader extends AbstractResourceLoader implements IterableResourceLoader
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description (package private) static classJarFileResourceLoader.CodeSigners
-
Field Summary
Fields Modifier and Type Field Description private java.util.Map<JarFileResourceLoader.CodeSigners,java.security.CodeSource>codeSourcesprivate static JarFileResourceLoader.CodeSignersEMPTY_CODE_SIGNERSprivate java.io.FilefileOfJarprivate static java.lang.StringINDEX_FILEprivate java.util.jar.JarFilejarFileprivate java.lang.StringrelativePathprivate java.lang.StringrootNameprivate java.net.URLrootUrl
-
Constructor Summary
Constructors Constructor 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)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description (package private) static voidaddInternalIndex(java.io.File file, boolean modify)voidclose()Closes this resource, relinquishing any underlying resources.private java.security.CodeSourcecreateCodeSource(java.util.jar.JarEntry entry)(package private) static voidextractJarPaths(java.util.jar.JarFile jarFile, java.lang.String relativePath, java.util.Collection<java.lang.String> index)ClassSpecgetClassSpec(java.lang.String fileName)Get the class specification for the given class name.private java.util.jar.JarEntrygetJarEntry(java.lang.String fileName)private static java.net.URIgetJarURI(java.net.URI original, java.lang.String nestedPath)java.lang.StringgetLibrary(java.lang.String name)Get the absolute physical filesystem path for a library with the given name.java.net.URIgetLocation()Get the base location of the resources in this loader (if any).PackageSpecgetPackageSpec(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.ResourcegetResource(java.lang.String name)Get a resource with the given name.java.lang.StringgetRootName()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 voidwriteExternalIndex(java.io.File indexFile, java.util.Collection<java.lang.String> index)-
Methods inherited from class org.jboss.modules.AbstractResourceLoader
getPackageSpec
-
-
-
-
Field Detail
-
INDEX_FILE
private static final java.lang.String INDEX_FILE
- See Also:
- Constant Field Values
-
jarFile
private final java.util.jar.JarFile jarFile
-
rootName
private final java.lang.String rootName
-
rootUrl
private final java.net.URL rootUrl
-
relativePath
private final java.lang.String relativePath
-
fileOfJar
private final java.io.File fileOfJar
-
codeSources
private final java.util.Map<JarFileResourceLoader.CodeSigners,java.security.CodeSource> codeSources
-
EMPTY_CODE_SIGNERS
private static final JarFileResourceLoader.CodeSigners EMPTY_CODE_SIGNERS
-
-
Method Detail
-
getJarURI
private static java.net.URI getJarURI(java.net.URI original, java.lang.String nestedPath) throws java.net.URISyntaxException- Throws:
java.net.URISyntaxException
-
getRootName
public java.lang.String getRootName()
Description copied from interface:ResourceLoaderGet the name of the root represented by this resource loader.- Specified by:
getRootNamein interfaceResourceLoader- Overrides:
getRootNamein classAbstractResourceLoader- Returns:
- the name of the root
-
getClassSpec
public ClassSpec getClassSpec(java.lang.String fileName) throws java.io.IOException
Description copied from interface:ResourceLoaderGet the class specification for the given class name. If no matching class is found,nullis returned.- Specified by:
getClassSpecin interfaceResourceLoader- Overrides:
getClassSpecin classAbstractResourceLoader- Parameters:
fileName- the fileName of the class, e.g. for the classorg.jboss.modules.ResourceLoaderthe fileName will beorg/jboss/modules/ResourceLoader.class- Returns:
- the class specification, or
nullif the named class is not found - Throws:
java.io.IOException- if an I/O error occurs
-
createCodeSource
private java.security.CodeSource createCodeSource(java.util.jar.JarEntry entry)
-
getJarEntry
private java.util.jar.JarEntry getJarEntry(java.lang.String fileName)
-
getPackageSpec
public PackageSpec getPackageSpec(java.lang.String name) throws java.io.IOException
Description copied from interface:ResourceLoaderGet 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:
getPackageSpecin interfaceResourceLoader- Overrides:
getPackageSpecin classAbstractResourceLoader- Parameters:
name- the directory name- Returns:
- the package specification
- Throws:
java.io.IOException- if an I/O error occurs
-
getLibrary
public java.lang.String getLibrary(java.lang.String name)
Description copied from interface:ResourceLoaderGet the absolute physical filesystem path for a library with the given name. The resultant path should be path-separated using "/" characters.- Specified by:
getLibraryin interfaceResourceLoader- Overrides:
getLibraryin classAbstractResourceLoader- Parameters:
name- the name- Returns:
- the path or
nullif the library is not present
-
getResource
public Resource getResource(java.lang.String name)
Description copied from interface:ResourceLoaderGet a resource with the given name. If no such resource is available,nullis returned. The resource name will always be specified using "/" separators for the directory segments.- Specified by:
getResourcein interfaceResourceLoader- Overrides:
getResourcein classAbstractResourceLoader- Parameters:
name- the resource name- Returns:
- the resource, or
nullif it is not available
-
iterateResources
public java.util.Iterator<Resource> iterateResources(java.lang.String startPath, boolean recursive)
Description copied from interface:IterableResourceLoaderEnumerate 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:
iterateResourcesin interfaceIterableResourceLoader- Parameters:
startPath- the path to search underrecursive-trueto recursively descend into subdirectories,falseto only read this path- Returns:
- the resource iterator (possibly empty)
-
getPaths
public java.util.Collection<java.lang.String> getPaths()
Description copied from interface:ResourceLoaderGet 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:
getPathsin interfaceResourceLoader- Overrides:
getPathsin classAbstractResourceLoader- Returns:
- the resource paths
-
close
public void close()
Description copied from interface:ResourceLoaderCloses this resource, relinquishing any underlying resources. This method is invoked automatically on objects managed by thetry-with-resources statement.- Specified by:
closein interfacejava.lang.AutoCloseable- Specified by:
closein interfaceResourceLoader
-
getLocation
public java.net.URI getLocation()
Description copied from interface:ResourceLoaderGet 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,nullis returned.- Specified by:
getLocationin interfaceResourceLoader- Returns:
- the base location of the resources in this loader, or
nullif not available
-
extractJarPaths
static void extractJarPaths(java.util.jar.JarFile jarFile, java.lang.String relativePath, java.util.Collection<java.lang.String> index)
-
writeExternalIndex
static void writeExternalIndex(java.io.File indexFile, java.util.Collection<java.lang.String> index)
-
readIndex
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- Throws:
java.io.IOException
-
addInternalIndex
static void addInternalIndex(java.io.File file, boolean modify) throws java.io.IOException- Throws:
java.io.IOException
-
-