|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES All Classes | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectjava.lang.ClassLoader
com.ibm.as400.ui.framework.java.FileClassLoader
public class FileClassLoader extends ClassLoader
A class loader which is capable of locating and loading class files from
its own internally defined classpath. FileClassLoader
was developed to solve two problems:
FileClassLoader
provides a way to dynamically locate and
load classes not defined on the system classpath.
Each instance of a user-defined class loader provides this namespace-based isolation.
Constructor and Description |
---|
FileClassLoader()
Creates a new FileClassLoader object. |
FileClassLoader(String classpath)
Creates a new FileClassLoader object using the specified classpath. |
Modifier and Type | Method and Description |
---|---|
void |
addPath(String pathname)
Appends a new file or directory name to the classpath for this FileClassLoader . |
void |
clearCache()
Clears the cached classes on a user request before the garbage collector gets invoked. |
String |
getClasspath()
Returns the classpath for this FileClassLoader . |
URL |
getResource(String name)
Finds the resource with the given name. |
InputStream |
getResourceAsStream(String name)
Returns an input stream for reading the specified resource. |
Class |
loadClass(String name,
boolean resolve)
Loads the class with the specified name. |
boolean |
removePath(String pathname)
Removes the specified file or directory name from the classpath for this FileClassLoader . |
void |
setClasspath(String classpath)
Sets the classpath for this FileClassLoader . |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public FileClassLoader()
FileClassLoader
object. The parent class loader is the
ClassLoader
returned by the method getSystemClassLoader()
.
If there is a security manager, its checkCreateClassLoader
method is called. This may result in a security exception.
SecurityException
- if a security manager exists and its checkCreateClassLoader
method doesn't allow creation of a new class loader.SecurityException
,
SecurityManager.checkCreateClassLoader()
public FileClassLoader(String classpath)
FileClassLoader
object using the specified classpath.
The parent class loader is the
ClassLoader
returned by the method getSystemClassLoader()
.
If there is a security manager, its checkCreateClassLoader
method is called. This may result in a security exception.
classpath
- The classpath string that this FileClassLoader
will use when searching for class files.SecurityException
- if a security manager exists and its checkCreateClassLoader
method doesn't allow creation of a new class loader.SecurityException
,
SecurityManager.checkCreateClassLoader()
Method Detail |
---|
public void setClasspath(String classpath)
FileClassLoader
.
classpath
- The classpath string that this FileClassLoader
will use when searching for class files.public void addPath(String pathname)
FileClassLoader
.
pathname
- A valid name of a file system directory, ZIP file,
or JAR file. The name may either be an absolute pathname
or specified relative to the current directory.IllegalArgumentException
- If the specified pathname
is not a valid file system directory, ZIP file name or JAR file name.public boolean removePath(String pathname)
FileClassLoader
.
pathname
- The name of a file system directory, ZIP file,
or JAR file.true
if the path was successfully removed;
false
if the classpath does not contain the path.public String getClasspath()
FileClassLoader
.
FileClassLoader
.public Class loadClass(String name, boolean resolve) throws ClassNotFoundException
loadClass
in class ClassLoader
name
- the name of the classresolve
- if true
then resolve the classClass
objectClassNotFoundException
- if the class could not be foundpublic InputStream getResourceAsStream(String name)
This method will first attempt to load the resource from the classpath. If that fails then this method will call the system class loader to find the resource.
getResourceAsStream
in class ClassLoader
name
- the resource namenull
if the resource could not be foundpublic URL getResource(String name)
The name of a resource is a "/"-separated path name that identifies the resource.
This method will first attempt to load the resource from the classpath. If that fails then this method will call the system class loader to find the resource.
getResource
in class ClassLoader
name
- resource namenull
if
the resource could not be found or the caller doesn't have
adequate privileges to get the resource.public void clearCache()
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES All Classes | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |