|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectjava.lang.ClassLoader
java.security.SecureClassLoader
edu.emory.mathcs.util.classloader.GenericClassLoader
This class loader can be used to find class, resource and library
handles
as well as load classes, resources and libraries using abstract
ResourceFinder
entity encapsulating the searching approach.
Resource handles allow accessing meta-information (like Attributes,
Certificates etc.) related to classes, resources and libraries prior to
loading them.
GenericClassLoader is intended to be used as a base for custom class
loaders. In most applications, GenericClassLoader can be used directly --
the application-specific functionality of resource searching can often be
completely delegated to the resource finder. See URIClassLoader
for a concrete implementation using a simple resource finder.
ResourceFinder
,
ResourceLoader
,
ResourceHandle
Field Summary | |
protected ResourceFinder |
finder
|
Constructor Summary | |
GenericClassLoader(ResourceFinder finder)
Creates new GenericClassLoader instance using specified ResourceFinder to find resources and with default
parent class loader. |
|
GenericClassLoader(ResourceFinder finder,
java.lang.ClassLoader parent)
Creates new GenericClassLoader instance using specified ResourceFinder to find resources and having specified
parent class loader. |
Method Summary | |
protected java.lang.Class |
defineClass(java.lang.String name,
ResourceHandle h)
|
protected java.lang.Package |
definePackage(java.lang.String name,
java.util.jar.Manifest man,
java.net.URL url)
Defines a new package by name in this ClassLoader. |
protected java.lang.Class |
findClass(java.lang.String name)
Finds and loads the class with the specified name. |
protected java.lang.String |
findLibrary(java.lang.String libname)
Returns the absolute path name of a native library. |
protected java.net.URL |
findResource(java.lang.String name)
Finds the resource with the specified name. |
protected java.util.Enumeration |
findResources(java.lang.String name)
Returns an Enumeration of URLs representing all of the resources having the specified name. |
protected ResourceHandle |
getClassHandle(java.lang.String name)
Finds the ResourceHandle object for the class with the specified name. |
static java.net.URLStreamHandler |
getDefaultURLStreamHandler(java.lang.String protocol)
|
protected ResourceHandle |
getLibraryHandle(java.lang.String name)
Finds the ResourceHandle object for the native library with the specified name. |
protected ResourceHandle |
getResourceHandle(java.lang.String name)
Finds the ResourceHandle object for the resource with the specified name. |
protected java.util.Enumeration |
getResourceHandles(java.lang.String name)
Returns an Enumeration of ResourceHandle objects representing all of the resources having the specified name. |
Methods inherited from class java.security.SecureClassLoader |
defineClass, getPermissions |
Methods inherited from class java.lang.ClassLoader |
clearAssertionStatus, defineClass, defineClass, defineClass, definePackage, findLoadedClass, findSystemClass, getPackage, getPackages, getParent, getResource, getResourceAsStream, getResources, getSystemClassLoader, getSystemResource, getSystemResourceAsStream, getSystemResources, loadClass, loadClass, resolveClass, setClassAssertionStatus, setDefaultAssertionStatus, setPackageAssertionStatus, setSigners |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
protected ResourceFinder finder
Constructor Detail |
public GenericClassLoader(ResourceFinder finder, java.lang.ClassLoader parent)
ResourceFinder
to find resources and having specified
parent class loader.
public GenericClassLoader(ResourceFinder finder)
ResourceFinder
to find resources and with default
parent class loader.
Method Detail |
protected java.lang.Class findClass(java.lang.String name) throws java.lang.ClassNotFoundException
name
- the name of the class
java.lang.ClassNotFoundException
- if the class could not be foundprotected java.lang.Class defineClass(java.lang.String name, ResourceHandle h) throws java.io.IOException
java.io.IOException
protected java.net.URL findResource(java.lang.String name)
name
- the name of the resource
URL
for the resource, or null
if the resource could not be found.protected java.util.Enumeration findResources(java.lang.String name) throws java.io.IOException
name
- the resource name
Enumeration
of URL
s
java.io.IOException
- if an I/O exception occursprotected java.lang.String findLibrary(java.lang.String libname)
null
, the VM searches the library along the path
specified as the java.library.path
property.
This method invoke getLibraryHandle(java.lang.String)
method to find handle
of this library. If the handle is found and its URL protocol is "file",
the system-dependent absolute library file path is returned.
Otherwise this method returns null. Subclasses can override this method to provide specific approaches in library searching.
libname
- the library name
System.loadLibrary(java.lang.String)
,
System.mapLibraryName(java.lang.String)
protected ResourceHandle getClassHandle(java.lang.String name)
findClass()
, this method does not load the class.
name
- the name of the class
protected ResourceHandle getResourceHandle(java.lang.String name)
name
- the name of the resource
protected ResourceHandle getLibraryHandle(java.lang.String name)
System.mapLibraryName(String)
method). Next, the
ResourceFinder
is used to look for the library as it
was ordinary resource. Subclasses can override this method to provide specific approaches in library searching.
name
- the name of the library
protected java.util.Enumeration getResourceHandles(java.lang.String name)
name
- the name of the resource
protected java.lang.Package definePackage(java.lang.String name, java.util.jar.Manifest man, java.net.URL url) throws java.lang.IllegalArgumentException
name
- the package nameman
- the Manifest containing package version and sealing
informationurl
- the code source url for the package, or null if none
java.lang.IllegalArgumentException
- if the package name duplicates
an existing package either in this class loader or one
of its ancestorspublic static java.net.URLStreamHandler getDefaultURLStreamHandler(java.lang.String protocol)
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |