Package org.jboss.modules
Class FileResourceLoader
- java.lang.Object
-
- org.jboss.modules.AbstractResourceLoader
-
- org.jboss.modules.NativeLibraryResourceLoader
-
- org.jboss.modules.FileResourceLoader
-
- All Implemented Interfaces:
java.lang.AutoCloseable
,IterableResourceLoader
,ResourceLoader
final class FileResourceLoader extends NativeLibraryResourceLoader implements IterableResourceLoader
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description (package private) class
FileResourceLoader.Itr
-
Nested classes/interfaces inherited from class org.jboss.modules.NativeLibraryResourceLoader
NativeLibraryResourceLoader.Identification
-
-
Field Summary
Fields Modifier and Type Field Description private java.security.CodeSource
codeSource
private java.security.AccessControlContext
context
private java.util.jar.Manifest
manifest
private java.lang.String
rootName
-
Constructor Summary
Constructors Constructor Description FileResourceLoader(java.lang.String rootName, java.io.File root, java.security.AccessControlContext context)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description private void
buildIndex(java.util.List<java.lang.String> index, java.io.File root, java.lang.String pathBase)
private ClassSpec
doGetClassSpec(java.lang.String fileName)
ClassSpec
getClassSpec(java.lang.String fileName)
Get the class specification for the given class 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.private static java.util.jar.Manifest
readManifestFile(java.io.File manifestFile)
-
Methods inherited from class org.jboss.modules.NativeLibraryResourceLoader
getArchName, getLibrary, getRoot
-
Methods inherited from class org.jboss.modules.AbstractResourceLoader
getPackageSpec
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.jboss.modules.ResourceLoader
close, getLibrary
-
-
-
-
Method Detail
-
readManifestFile
private static java.util.jar.Manifest readManifestFile(java.io.File manifestFile)
-
getRootName
public java.lang.String 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
public ClassSpec getClassSpec(java.lang.String fileName) throws java.io.IOException
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:
java.io.IOException
- if an I/O error occurs
-
doGetClassSpec
private ClassSpec doGetClassSpec(java.lang.String fileName) throws java.io.IOException
- Throws:
java.io.IOException
-
getPackageSpec
public PackageSpec getPackageSpec(java.lang.String name) throws java.io.IOException
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:
java.io.IOException
- if an I/O error occurs
-
getResource
public Resource getResource(java.lang.String name)
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
public java.util.Iterator<Resource> iterateResources(java.lang.String startPath, boolean recursive)
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
public java.util.Collection<java.lang.String> 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
-
getLocation
public java.net.URI 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
- Overrides:
getLocation
in classNativeLibraryResourceLoader
- Returns:
- the base location of the resources in this loader, or
null
if not available
-
buildIndex
private void buildIndex(java.util.List<java.lang.String> index, java.io.File root, java.lang.String pathBase)
-
-