|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--java.lang.ClassLoader | +--org.apache.tools.ant.AntClassLoader
Used to load classes within ant with a different claspath from that used to start ant. Note that it is possible to force a class into this loader even when that class is on the system classpath by using the forceLoadClass method. Any subsequent classes loaded by that class will then use this loader rather than the system class loader.
Constructor Summary | |
AntClassLoader(Project project,
Path classpath)
Create a classloader for the given project using the classpath given. |
|
AntClassLoader(Project project,
Path classpath,
boolean systemFirst)
Create a classloader for the given project using the classpath given. |
Method Summary | |
void |
addLoaderPackageRoot(java.lang.String packageRoot)
Add a package root to the list of packages which must be loaded using this loader. |
void |
addSystemPackageRoot(java.lang.String packageRoot)
Add a package root to the list of packages which must be loaded on the system loader. |
java.lang.Class |
findClass(java.lang.String name)
Search for and load a class on the classpath of this class loader. |
java.lang.Class |
forceLoadClass(java.lang.String classname)
Load a class through this class loader even if that class is available on the system classpath. |
java.lang.Class |
forceLoadSystemClass(java.lang.String classname)
Load a class through this class loader but defer to the system class loader This ensures that instances of the returned class will be compatible with instances which which have already been loaded on the system loader. |
java.io.InputStream |
getResourceAsStream(java.lang.String name)
Get a stream to read the requested resource name. |
protected java.lang.Class |
loadClass(java.lang.String classname,
boolean resolve)
Load a class with this class loader. |
void |
setIsolated(boolean isolated)
Set this classloader to run in isolated mode. |
Methods inherited from class java.lang.ClassLoader |
defineClass, defineClass, defineClass, definePackage, findLibrary, findLoadedClass, findResource, findResources, findSystemClass, getPackage, getPackages, getParent, getResource, getResources, getSystemClassLoader, getSystemResource, getSystemResourceAsStream, getSystemResources, loadClass, resolveClass, setSigners |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
public AntClassLoader(Project project, Path classpath)
project
- the project to ehich this classloader is to belong.classpath
- the classpath to use to load the classes. This
is combined with the system classpath in a manner
determined by the value of ${build.sysclasspath}public AntClassLoader(Project project, Path classpath, boolean systemFirst)
project
- the project to which this classloader is to belong.classpath
- the classpath to use to load the classes.Method Detail |
public void setIsolated(boolean isolated)
public void addSystemPackageRoot(java.lang.String packageRoot)
packageRoot
- the root of all packages to be included.public void addLoaderPackageRoot(java.lang.String packageRoot)
packageRoot
- the root of akll packages to be included.public java.lang.Class forceLoadClass(java.lang.String classname) throws java.lang.ClassNotFoundException
classname
- the classname to be loaded.java.lang.ClassNotFoundException
- if the requested class does not exist on
this loader's classpath.public java.lang.Class forceLoadSystemClass(java.lang.String classname) throws java.lang.ClassNotFoundException
classname
- the classname to be loaded.java.lang.ClassNotFoundException
- if the requested class does not exist on
this loader's classpath.public java.io.InputStream getResourceAsStream(java.lang.String name)
getResourceAsStream
in class java.lang.ClassLoader
name
- the name of the resource for which a stream is required.protected java.lang.Class loadClass(java.lang.String classname, boolean resolve) throws java.lang.ClassNotFoundException
loadClass
in class java.lang.ClassLoader
classname
- the name of the class to be loaded.resolve
- true if all classes upon which this class depends are to be loaded.java.lang.ClassNotFoundException
- if the requested class does not exist on
the system classpath or this loader's classpath.public java.lang.Class findClass(java.lang.String name) throws java.lang.ClassNotFoundException
findClass
in class java.lang.ClassLoader
name
- the classname to be loaded.java.lang.ClassNotFoundException
- if the requested class does not exist on
this loader's classpath.
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |