Top Inners Fields Constructors Methods
org.jboss.modules

pack-priv final Class JarFileResourceLoader

extends AbstractResourceLoader
implements IterableResourceLoader
Class Inheritance
All Implemented Interfaces
org.jboss.modules.IterableResourceLoader, org.jboss.modules.ResourceLoader, java.lang.AutoCloseable
Imports
java.io.ByteArrayOutputStream, .File, .IOException, .InputStream, java.net.MalformedURLException, .URI, .URISyntaxException, .URL, .URLStreamHandler, java.security.CodeSigner, .CodeSource, .PrivilegedActionException, java.util.ArrayList, .Arrays, .Collection, .Enumeration, .HashMap, .HashSet, .Iterator, .List, .Map, .NoSuchElementException, java.util.jar.JarEntry, .JarFile, .Manifest

Authors
David M. Lloyd, [email protected], Richard Opalka

Nested and Inner Type Summary

Modifier and TypeClass and Description
pack-priv static class

Field Summary

Modifier and TypeField and Description
private final Map<JarFileResourceLoader.CodeSigners, CodeSource>
private volatile List<String>
private static final JarFileResourceLoader.CodeSigners
private final File
private final JarFile
private final String
private final String
private final URL

Constructor Summary

AccessConstructor and Description
pack-priv
JarFileResourceLoader(final String rootName, final JarFile jarFile)

pack-priv
JarFileResourceLoader(final String rootName, final JarFile jarFile, final String relativePath)

Method Summary

Modifier and TypeMethod and Description
public void
close()

Overrides default org.jboss.modules.ResourceLoader.close.

Closes this resource, relinquishing any underlying resources.
private CodeSource
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 void
extractJarPaths(final JarFile jarFile, String relativePath, final Collection<String> index)

public synchronized 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.
private JarEntry
getJarEntry(final String fileName)

private static URI
getJarURI(final URI original, final String nestedPath)

public String
getLibrary(final 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(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(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.
Inherited from org.jboss.modules.AbstractResourceLoader:
getPackageSpec

Field Detail

codeSourcesback to summary
private final Map<JarFileResourceLoader.CodeSigners, CodeSource> codeSources
directoryback to summary
private volatile List<String> directory
EMPTY_CODE_SIGNERSback to summary
private static final JarFileResourceLoader.CodeSigners EMPTY_CODE_SIGNERS
fileOfJarback to summary
private final File fileOfJar
jarFileback to summary
private final JarFile jarFile
relativePathback to summary
private final String relativePath
rootNameback to summary
private final String rootName
rootUrlback to summary
private final URL rootUrl

Constructor Detail

JarFileResourceLoaderback to summary
pack-priv JarFileResourceLoader(final String rootName, final JarFile jarFile)
JarFileResourceLoaderback to summary
pack-priv JarFileResourceLoader(final String rootName, final JarFile jarFile, final String relativePath)

Method Detail

closeback to summary
public void close()

Overrides default org.jboss.modules.ResourceLoader.close.

Doc from org.jboss.modules.ResourceLoader.close.

Closes this resource, relinquishing any underlying resources. This method is invoked automatically on objects managed by the try-with-resources statement.

Annotations
@Override
createCodeSourceback to summary
private CodeSource createCodeSource(final JarEntry entry)
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

extractJarPathsback to summary
pack-priv static void extractJarPaths(final JarFile jarFile, String relativePath, final Collection<String> index)
getClassSpecback to summary
public synchronized 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

Exceptions
IOException:
if an I/O error occurs
getJarEntryback to summary
private JarEntry getJarEntry(final String fileName)
getJarURIback to summary
private static URI getJarURI(final URI original, final String nestedPath) throws URISyntaxException
getLibraryback to summary
public String getLibrary(final 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

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

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

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

getResourceback to summary
public Resource getResource(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

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

iterateResourcesback to summary
public Iterator<Resource> iterateResources(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)

org.jboss.modules back to summary

pack-priv final Class JarFileResourceLoader.CodeSigners

extends Object
Class Inheritance

Field Summary

Modifier and TypeField and Description
private final CodeSigner[]
private final int

Constructor Summary

AccessConstructor and Description
pack-priv
CodeSigners(final CodeSigner[] codeSigners)

Method Summary

Modifier and TypeMethod and Description
public boolean
equals(final Object
the reference object with which to compare.
obj
)

Overrides java.lang.Object.equals.

Indicates whether some other object is "equal to" this one.
private boolean
public int
hashCode()

Overrides java.lang.Object.hashCode.

Returns a hash code value for the object.
Inherited from java.lang.Object:
clonefinalizegetClassnotifynotifyAlltoStringwaitwaitwait

Field Detail

codeSignersback to summary
private final CodeSigner[] codeSigners
hashCodeback to summary
private final int hashCode

Constructor Detail

CodeSignersback to summary
pack-priv CodeSigners(final CodeSigner[] codeSigners)

Method Detail

equalsback to summary
public boolean equals(final Object obj)

Overrides java.lang.Object.equals.

Doc from java.lang.Object.equals.

Indicates whether some other object is "equal to" this one.

The equals method implements an equivalence relation on non-null object references:

  • It is reflexive: for any non-null reference value x, x.equals(x) should return true.
  • It is symmetric: for any non-null reference values x and y, x.equals(y) should return true if and only if y.equals(x) returns true.
  • It is transitive: for any non-null reference values x, y, and z, if x.equals(y) returns true and y.equals(z) returns true, then x.equals(z) should return true.
  • It is consistent: for any non-null reference values x and y, multiple invocations of x.equals(y) consistently return true or consistently return false, provided no information used in equals comparisons on the objects is modified.
  • For any non-null reference value x, x.equals(null) should return false.

An equivalence relation partitions the elements it operates on into equivalence classes; all the members of an equivalence class are equal to each other. Members of an equivalence class are substitutable for each other, at least for some purposes.

Parameters
obj:Object

the reference object with which to compare.

Returns:boolean

true if this object is the same as the obj argument; false otherwise.

equalsback to summary
private boolean equals(final JarFileResourceLoader.CodeSigners other)
hashCodeback to summary
public int hashCode()

Overrides java.lang.Object.hashCode.

Doc from java.lang.Object.hashCode.

Returns a hash code value for the object. This method is supported for the benefit of hash tables such as those provided by java.util.HashMap.

The general contract of hashCode is:

  • Whenever it is invoked on the same object more than once during an execution of a Java application, the hashCode method must consistently return the same integer, provided no information used in equals comparisons on the object is modified. This integer need not remain consistent from one execution of an application to another execution of the same application.
  • If two objects are equal according to the equals method, then calling the hashCode method on each of the two objects must produce the same integer result.
  • It is not required that if two objects are unequal according to the equals method, then calling the hashCode method on each of the two objects must produce distinct integer results. However, the programmer should be aware that producing distinct integer results for unequal objects may improve the performance of hash tables.
Returns:int

a hash code value for this object.