Class ClasspathUtils.Delegate
- Enclosing class:
- ClasspathUtils
Ant ProjectComponents that need a to be able to dynamically load Classes and instantiate them often expose the following ant syntax sugar:
- nested <classpath>
- attribute @classpathref
- attribute @classname
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.
- Since:
- Ant 1.6
- 
Method SummaryModifier and TypeMethodDescriptionDelegate method handling the <classpath> tag.Finds or creates the classloader for this object.Computes the loaderId based on the configuration of the component.The classpath.booleanGet the reverseLoader setting.Helper method obtaining a fresh instance of the class specified in the @classname and using the specified classpath.voidsetClassname(String fcqn) Delegate method handling the @classname attribute.voidsetClasspath(Path classpath) This method is a Delegate method handling the @classpath attribute.voidDelegate method handling the @classpathref attribute.voidSets the loaderRef.voidsetReverseLoader(boolean reverseLoader) Delegate method handling the @reverseLoader attribute.
- 
Method Details- 
setClasspathThis method is a Delegate method handling the @classpath attribute.This attribute can set a path to add to the classpath. - Parameters:
- classpath- the path to use for the classpath.
 
- 
createClasspathDelegate method handling the <classpath> tag.This nested path-like structure can set a path to add to the classpath. - Returns:
- the created path.
 
- 
setClassnameDelegate method handling the @classname attribute.This attribute sets the full qualified class name of the class to load and instantiate. - Parameters:
- fcqn- the name of the class to load.
 
- 
setClasspathrefDelegate method handling the @classpathref attribute.This attribute can add a referenced path-like structure to the classpath. - Parameters:
- r- the reference to the classpath.
 
- 
setReverseLoaderpublic void setReverseLoader(boolean reverseLoader) Delegate method handling the @reverseLoader attribute.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. - Parameters:
- reverseLoader- if true reverse the order of looking up a class.
 
- 
setLoaderRefSets the loaderRef.- Parameters:
- r- the reference to the loader.
 
- 
getClassLoaderFinds or creates the classloader for this object.- Returns:
- The class loader.
 
- 
getClassLoadIdComputes the loaderId based on the configuration of the component.- Returns:
- a loader identifier.
 
- 
newInstanceHelper method obtaining a fresh instance of the class specified in the @classname and using the specified classpath.- Returns:
- the fresh instantiated object.
 
- 
getClasspath
- 
isReverseLoaderpublic boolean isReverseLoader()Get the reverseLoader setting.- Returns:
- true if looking up in reverse order.
 
 
-