| java.lang.Object org.apache.commons.discovery.resource.ClassLoaders
ClassLoaders | public class ClassLoaders (Code) | | There are many different contexts in which
loaders can be used. This provides a holder
for a set of class loaders, so that they
don't have to be build back up everytime...
author: Richard A. Sitze author: Craig R. McClanahan author: Costin Manolache |
Method Summary | |
public ClassLoader | get(int idx) | public static ClassLoaders | getAppLoaders(Class spi, Class factory, boolean prune) Utility method. | public static ClassLoaders | getLibLoaders(Class spi, Class factory, boolean prune) Utility method. | public boolean | isAncestor(ClassLoader classLoader) Check to see if classLoader is an
ancestor of any contained class loader.
This can be used to eliminate redundant class loaders
IF all class loaders defer to parent class loaders
before resolving a class.
It may be that this is not always true. | public void | put(ClassLoader classLoader) Specify a new class loader to be used in searching. | public void | put(ClassLoader classLoader, boolean prune) Specify a new class loader to be used in searching. | public int | size() |
ClassLoaders | public ClassLoaders()(Code) | | Construct a new class loader set
|
getAppLoaders | public static ClassLoaders getAppLoaders(Class spi, Class factory, boolean prune)(Code) | | Utility method. Returns a preloaded ClassLoaders instance
containing the following class loaders, in order:
- Thread Context Class Loader
- spi.getClassLoader
- seeker.getClassLoader
- System Class Loader
Note that the thread context class loader IS present.
This is a reasonable set of loaders to try if the resource to be found
may be provided by an application.
Parameters: spi - WHAT is being looked for (an implementation of this class,a default property file related to this class). Parameters: factory - WHO is performing the lookup (factory). Parameters: prune - Determines if ancestors are allowed to be loaded or not. |
getLibLoaders | public static ClassLoaders getLibLoaders(Class spi, Class factory, boolean prune)(Code) | | Utility method. Returns a preloaded ClassLoaders instance
containing the following class loaders, in order:
- spi.getClassLoader
- seeker.getClassLoader
- System Class Loader
Note that the thread context class loader is NOT present.
This is a reasonable set of loaders to try if the resource to be found
should be restricted to a libraries containing the SPI and Factory.
Parameters: spi - WHAT is being looked for (an implementation of this class,a default property file related to this class). Parameters: factory - WHO is performing the lookup. Parameters: prune - Determines if ancestors are allowed to be loaded or not. |
isAncestor | public boolean isAncestor(ClassLoader classLoader)(Code) | | Check to see if classLoader is an
ancestor of any contained class loader.
This can be used to eliminate redundant class loaders
IF all class loaders defer to parent class loaders
before resolving a class.
It may be that this is not always true. Therefore,
this check is not done internally to eliminate
redundant class loaders, but left to the discretion
of the user.
|
put | public void put(ClassLoader classLoader)(Code) | | Specify a new class loader to be used in searching.
The order of loaders determines the order of the result.
It is recommended to add the most specific loaders first.
|
put | public void put(ClassLoader classLoader, boolean prune)(Code) | | Specify a new class loader to be used in searching.
The order of loaders determines the order of the result.
It is recommended to add the most specific loaders first.
Parameters: prune - if true, verify that the class loader isnot an Ancestor (@see isAncestor) beforeadding it to our list. |
|
|