public static class ClasspathUtils.Delegate extends Object
Ant ProjectComponents that need a to be able to dynamically load Classes and instantiate them often expose the following ant syntax sugar:
This class functions as a delegate handling the configuration issues for this recurring pattern. Its usage pattern, as the name suggests, is delegation rather than inheritance.
Modifier and Type | Method and Description |
---|---|
Path |
createClasspath()
Delegate method handling the <classpath> tag.
|
java.lang.ClassLoader |
getClassLoader()
Finds or creates the classloader for this object.
|
String |
getClassLoadId()
Computes the loaderId based on the configuration of the component.
|
Path |
getClasspath()
The classpath.
|
boolean |
isReverseLoader()
Get the reverseLoader setting.
|
Object |
newInstance()
Helper method obtaining a fresh instance of the class specified
in the @classname and using the specified classpath.
|
void |
setClassname(String fcqn)
Delegate method handling the @classname attribute.
|
void |
setClasspath(Path classpath)
This method is a Delegate method handling the @classpath attribute.
|
void |
setClasspathref(Reference r)
Delegate method handling the @classpathref attribute.
|
void |
setLoaderRef(Reference r)
Sets the loaderRef.
|
void |
setReverseLoader(boolean reverseLoader)
Delegate method handling the @reverseLoader attribute.
|
public Path createClasspath()
This nested path-like structure can set a path to add to the classpath.
public java.lang.ClassLoader getClassLoader()
public String getClassLoadId()
public Path getClasspath()
public boolean isReverseLoader()
public Object newInstance()
public void setClassname(String fcqn)
This attribute sets the full qualified class name of the class to load and instantiate.
fcqn
- the name of the class to load.public void setClasspath(Path classpath)
This attribute can set a path to add to the classpath.
classpath
- the path to use for the classpath.public void setClasspathref(Reference r)
This attribute can add a referenced path-like structure to the classpath.
r
- the reference to the classpath.public void setLoaderRef(Reference r)
r
- the reference to the loader.public void setReverseLoader(boolean reverseLoader)
This attribute can set a boolean indicating that the used classloader should NOT follow the classical parent-first scheme.
By default this is supposed to be false.
Caution: this behaviour is contradictory to the normal way classloaders work. Do not let your ProjectComponent use it if you are not really sure.
reverseLoader
- if true reverse the order of looking up a class.