From f4ff4f55597c19a087703dd876ebd7a4f1760b94 Mon Sep 17 00:00:00 2001 From: Peter Donald Date: Sat, 2 Mar 2002 00:55:31 +0000 Subject: [PATCH] Start to document the Containers ClassLoader hierarchy. Adapted terminology from Catalina as that terminology is more widely used. Punt on antlib ClassLoader structure as that is defined via library specific mechanisms git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@271647 13f79535-47bb-0310-9956-ffa450edef68 --- proposal/myrmidon/src/xdocs/classloader.xml | 113 ++++++++++++++++++++ 1 file changed, 113 insertions(+) create mode 100644 proposal/myrmidon/src/xdocs/classloader.xml diff --git a/proposal/myrmidon/src/xdocs/classloader.xml b/proposal/myrmidon/src/xdocs/classloader.xml new file mode 100644 index 000000000..5a9d74205 --- /dev/null +++ b/proposal/myrmidon/src/xdocs/classloader.xml @@ -0,0 +1,113 @@ + + + + + On ClassLoaders in Ant2 + Peter Donald + + + + +
+ +

In many ways Ant2 needs to follow rules similar to a number of +different application servers with respect to ClassLoader management. +Ant2 will create a number of different ClassLoaders that have access +to different sets of resources (and thus Classes). The main reason +for this arrangment is to partition different sections of the +application such as the Container, the Task API, task/type libraries +and support libraries.

+ +

The recomended structure for ClassLoader relationships is a hierarchy. +When a ClassLoader is asked for a resource (or a class) it first delegates +to it's parent to ask for the resource. If the resource is not present in +its parent ClassLoader then the ClassLoader attempts to locate the resource +in it's own store. In practice this means that all the classes (and static +variables defined by said classes) in a parent ClassLoader are shared with +the child ClassLoaders.

+ +

Using kooky ascii art, the specific ClassLoader structure for Ant2 is as +follows:

+ + + Bootstrap + | + System + | + Common + / \ + Container Shared + / \ + Antlib1 Antlib2 ... + + +
    +
  • + The Bootstrap ClassLoader contains the classes and resources + provided by the Java runtime. +
  • +
  • + The System ClassLoader contains the classes that were made accessible + via the CLASSPATH environment variable. If the standard ant script was used then this + should only contain the classes that are used to bootstrap the ant runtime. ie + $ANT_HOME/bin/ant-launcher.jar +
  • +
  • + The Common ClassLoader contains the classes and resources + that are made visible to both the Container and to all the ant type librarys. This + contains all the classes that the Container uses to communicate with tasks and other + supporting infrastructure. In particular it contains the following APIs; +
      +
    • + Task API - Contains the classes that are part of the API used + to define tasks. +
    • +
    • + ProjectListener API - Contains the classes necessary to define new + ProjectListeners. +
    • +
    • + Aspect API - Contains the classes that are used to define Aspects + of the container. +
    • +
    • + Container API - Contains the interfaces that are required to communicate + with the objects deep within the container. NOTE: These interfaces + are not to be used by user tasks but are made available so that certain tasks (such + as <antcall/>) can be implemented. However they are subject to change without + notice between between different ant2 versions. +
    • +
    +

    + These classes are loaded from all the jars present in the $ANT_HOME/lib + directory. +

    +
  • +
  • + The Container ClassLoader contains all the classes and resources + that are part of the actual implementation of the Container. These classes are not + directly accessible to any Ant library or task. Some of the classes are indirectly + accessible to tasks and other elements defined in the ant librarys as they implement + interfaces defined in the Common ClassLoader. The classes that are + stored in jars in the $ANT_HOME/bin/lib/ directory. +
  • +
  • + The Shared ClassLoader contains all the classes and resources + that are shared across all of the ant librarys (unless they are als needed by the + container in which case they should be placed int the Container + ClassLoader). This ClassLoader is populated by all the jars that are contained in + the $ANT_HOME/shared/ directory. +
  • +
  • + The AntLib ClassLoaders each contain the classes and resources + that required by that particular library. Note that in some cases a single Ant + Library will manifest as a single ClassLoader containing a single jar. However + in some cases it is possible for one Ant Library to have multiple jars in its + ClassLoader or even have multiple ClassLoaders. See XXXX for further details. +
  • +
+ +
+ + +