Top Description Fields Constructors Methods
org.jboss.modules

pack-priv Class PathResourceLoader

extends AbstractResourceLoader
implements IterableResourceLoader
Class Inheritance
All Implemented Interfaces
org.jboss.modules.IterableResourceLoader, org.jboss.modules.ResourceLoader, java.lang.AutoCloseable
Imports
java.io.IOException, .InputStream, java.lang.reflect.UndeclaredThrowableException, java.net.MalformedURLException, .URI, .URL, java.nio.file.FileSystems, .FileVisitOption, .Files, .InvalidPathException, .Path, java.security.AccessControlContext, .AccessController, .CodeSigner, .CodeSource, .PrivilegedActionException, .PrivilegedExceptionAction, java.util.Collection, .Collections, .Iterator, java.util.jar.Manifest, java.util.stream.Collectors

Java NIO2 Path-based ResourceLoader
Author
Sergei Egorov

Field Summary

Modifier and TypeField and Description
private final CodeSource
protected final AccessControlContext
context

Deprecated as a consequence of AccessControlContext being deprecated.
private final Manifest
protected final Path
private final String

Constructor Summary

AccessConstructor and Description
pack-priv
PathResourceLoader(final String rootName, final Path root, final AccessControlContext context)

Deprecated as a consequence of AccessControlContext being deprecated.

Method Summary

Modifier and TypeMethod and Description
public ResourceLoader
createSubloader(final String
the relative path
relativePath
,
final String
the name of the subloader's root
rootName
)

Overrides default org.jboss.modules.ResourceLoader.createSubloader.

Create a loader which loads resources under a relative subdirectory relative to this loader.
pack-priv static <T, E extends Throwable> T
doPrivilegedIfNeeded(AccessControlContext context, Class<E> exceptionType, PrivilegedExceptionAction<T> action)

Deprecated as a consequence of AccessControlContext being deprecated.
pack-priv static <T> T
doPrivilegedIfNeeded(AccessControlContext context, PrivilegedExceptionAction<T> action)

Deprecated as a consequence of AccessControlContext being deprecated.
public ClassSpec
getClassSpec(final String
the fileName of the class, e.g. for the class org.jboss.modules.ResourceLoader the fileName will be org/jboss/modules/ResourceLoader.class
fileName
)

Overrides org.jboss.modules.AbstractResourceLoader.getClassSpec.

Implements org.jboss.modules.ResourceLoader.getClassSpec.

Get the class specification for the given class name.
public String
getLibrary(String
the name
name
)

Overrides org.jboss.modules.AbstractResourceLoader.getLibrary.

Implements org.jboss.modules.ResourceLoader.getLibrary.

Get the absolute physical filesystem path for a library with the given name.
public URI
getLocation()

Overrides default org.jboss.modules.ResourceLoader.getLocation.

Get the base location of the resources in this loader (if any).
public PackageSpec
getPackageSpec(final String
the directory name
name
)

Overrides org.jboss.modules.AbstractResourceLoader.getPackageSpec.

Implements org.jboss.modules.ResourceLoader.getPackageSpec.

Get the package specification for the given directory name.
public Collection<String>
public Resource
getResource(final String
the resource name
name
)

Overrides org.jboss.modules.AbstractResourceLoader.getResource.

Implements org.jboss.modules.ResourceLoader.getResource.

Get a resource with the given name.
public String
getRootName()

Overrides org.jboss.modules.AbstractResourceLoader.getRootName.

Overrides default org.jboss.modules.ResourceLoader.getRootName.

Get the name of the root represented by this resource loader.
public Iterator<Resource>
iterateResources(final String
the path to search under
startPath
,
final boolean
true to recursively descend into subdirectories, false to only read this path
recursive
)

Implements org.jboss.modules.IterableResourceLoader.iterateResources.

Enumerate all the resources under the given path.
private Manifest
readManifestFile(final Path manifestFile)

Inherited from org.jboss.modules.AbstractResourceLoader:
getPackageSpec

Field Detail

codeSourceback to summary
private final CodeSource codeSource
contextback to summary
protected final AccessControlContext context

Deprecated

as a consequence of AccessControlContext being deprecated. See corresponding docs for further information.

manifestback to summary
private final Manifest manifest
rootback to summary
protected final Path root
rootNameback to summary
private final String rootName

Constructor Detail

PathResourceLoaderback to summary
pack-priv PathResourceLoader(final String rootName, final Path root, final AccessControlContext context)

Deprecated

as a consequence of AccessControlContext being deprecated. See corresponding docs for further information.

Method Detail

createSubloaderback to summary
public ResourceLoader createSubloader(final String relativePath, final String rootName)

Overrides default org.jboss.modules.ResourceLoader.createSubloader.

Doc from org.jboss.modules.ResourceLoader.createSubloader.

Create a loader which loads resources under a relative subdirectory relative to this loader. If the resource loader does not support subloaders, null is returned.

Parameters
relativePath:String

the relative path

rootName:String

the name of the subloader's root

Returns:ResourceLoader

the resource loader, or null if subloaders are not supported

doPrivilegedIfNeededback to summary
pack-priv static <T, E extends Throwable> T doPrivilegedIfNeeded(AccessControlContext context, Class<E> exceptionType, PrivilegedExceptionAction<T> action) throws PrivilegedExceptionAction-:E

Deprecated

as a consequence of AccessControlContext being deprecated. See corresponding docs for further information.

doPrivilegedIfNeededback to summary
pack-priv static <T> T doPrivilegedIfNeeded(AccessControlContext context, PrivilegedExceptionAction<T> action)

Deprecated

as a consequence of AccessControlContext being deprecated. See corresponding docs for further information.

getClassSpecback to summary
public ClassSpec getClassSpec(final String fileName) throws IOException

Overrides org.jboss.modules.AbstractResourceLoader.getClassSpec.

Implements org.jboss.modules.ResourceLoader.getClassSpec.

Doc from org.jboss.modules.ResourceLoader.getClassSpec.

Get the class specification for the given class name. If no matching class is found, null is returned.

Parameters
fileName:String

the fileName of the class, e.g. for the class org.jboss.modules.ResourceLoader the fileName will be org/jboss/modules/ResourceLoader.class

Returns:ClassSpec

the class specification, or null if the named class is not found

Annotations
@Override
Exceptions
IOException:
if an I/O error occurs
getLibraryback to summary
public String getLibrary(String name)

Overrides org.jboss.modules.AbstractResourceLoader.getLibrary.

Implements org.jboss.modules.ResourceLoader.getLibrary.

Doc from org.jboss.modules.ResourceLoader.getLibrary.

Get the absolute physical filesystem path for a library with the given name. The resultant path should be path-separated using "/" characters.

Parameters
name:String

the name

Returns:String

the path or null if the library is not present

Annotations
@Override
getLocationback to summary
public URI getLocation()

Overrides default org.jboss.modules.ResourceLoader.getLocation.

Doc from org.jboss.modules.ResourceLoader.getLocation.

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.

Returns:URI

the base location of the resources in this loader, or null if not available

Annotations
@Override
getPackageSpecback to summary
public PackageSpec getPackageSpec(final String name) throws IOException

Overrides org.jboss.modules.AbstractResourceLoader.getPackageSpec.

Implements org.jboss.modules.ResourceLoader.getPackageSpec.

Doc from org.jboss.modules.ResourceLoader.getPackageSpec.

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.

Parameters
name:String

the directory name

Returns:PackageSpec

the package specification

Annotations
@Override
Exceptions
IOException:
if an I/O error occurs
getPathsback to summary
public Collection<String> getPaths()

Overrides org.jboss.modules.AbstractResourceLoader.getPaths.

Implements org.jboss.modules.ResourceLoader.getPaths.

Doc from org.jboss.modules.ResourceLoader.getPaths.

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.

Returns:Collection<String>

the resource paths

Annotations
@Override
getResourceback to summary
public Resource getResource(final String name)

Overrides org.jboss.modules.AbstractResourceLoader.getResource.

Implements org.jboss.modules.ResourceLoader.getResource.

Doc from org.jboss.modules.ResourceLoader.getResource.

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.

Parameters
name:String

the resource name

Returns:Resource

the resource, or null if it is not available

Annotations
@Override
getRootNameback to summary
public String getRootName()

Overrides org.jboss.modules.AbstractResourceLoader.getRootName.

Overrides default org.jboss.modules.ResourceLoader.getRootName.

Doc from org.jboss.modules.ResourceLoader.getRootName.

Get the name of the root represented by this resource loader.

Returns:String

the name of the root

Annotations
@Override
iterateResourcesback to summary
public Iterator<Resource> iterateResources(final String startPath, final boolean recursive)

Implements org.jboss.modules.IterableResourceLoader.iterateResources.

Doc from org.jboss.modules.IterableResourceLoader.iterateResources.

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 /.

Parameters
startPath:String

the path to search under

recursive:boolean

true to recursively descend into subdirectories, false to only read this path

Returns:Iterator<Resource>

the resource iterator (possibly empty)

Annotations
@Override
readManifestFileback to summary
private Manifest readManifestFile(final Path manifestFile)