org.apache.tools.ant.util
Class ClasspathUtils.Delegate

java.lang.Object
  |
  +--org.apache.tools.ant.util.ClasspathUtils.Delegate
Enclosing class:
ClasspathUtils

public static class ClasspathUtils.Delegate
extends java.lang.Object

Delegate that helps out any specific ProjectComponent that needs dynamic classloading.

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 recuring pattern. Its usage pattern, as the name suggests is delegation, not inheritance.

Since:
Ant 1.6

Method Summary
 Path createClasspath()
          Delegate method handling the <classpath> tag.
 java.lang.ClassLoader getClassLoader()
          Finds or creates the classloader for this
 java.lang.String getClassLoadId()
          Computes the loaderId based on the configuration of the component.
 Path getClasspath()
          The classpath.
 boolean isReverseLoader()
           
 java.lang.Object newInstance()
          Helper method obtaining a fresh instance of the class specified in the @classname and using the specified classpath.
 void setClassname(java.lang.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.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

setClasspath

public void setClasspath(Path classpath)
This method is a Delegate method handling the @classpath attribute.

This attribute can set a path to add to the classpath

Parameters:
classpath -

createClasspath

public Path createClasspath()
Delegate method handling the <classpath> tag.

This nested path-like structure can set a path to add to the classpath

Returns:
the created path

setClassname

public void setClassname(java.lang.String fcqn)
Delegate method handling the @classname attribute.

This attribute sets the full qualified class name of the class to lad and instantiate

Parameters:
fcqn -

setClasspathref

public void setClasspathref(Reference r)
Delegate method handling the @classpathref attribute.

This attribute can add a referenced path-like structure to the classpath

Parameters:
r -

setReverseLoader

public 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 -

setLoaderRef

public void setLoaderRef(Reference r)
Sets the loaderRef

Parameters:
r -

getClassLoader

public java.lang.ClassLoader getClassLoader()
Finds or creates the classloader for this

Returns:
The class loader

getClassLoadId

public java.lang.String getClassLoadId()
Computes the loaderId based on the configuration of the component.


newInstance

public java.lang.Object newInstance()
Helper method obtaining a fresh instance of the class specified in the @classname and using the specified classpath.

Returns:
the fresh instantiated object.

getClasspath

public Path getClasspath()
The classpath.


isReverseLoader

public boolean isReverseLoader()


Copyright © 2000-2004 Apache Software Foundation. All Rights Reserved.