public class ClassLoaders extends Object
Modifier and Type | Field and Description |
---|---|
protected List<ClassLoader> |
classLoaders |
Constructor and Description |
---|
ClassLoaders()
Construct a new class loader set.
|
Modifier and Type | Method and Description |
---|---|
ClassLoader |
get(int idx)
Returns the class loader positioned at the given index.
|
static ClassLoaders |
getAppLoaders(Class<?> spi,
Class<?> factory,
boolean prune)
Utility method.
|
static ClassLoaders |
getLibLoaders(Class<?> spi,
Class<?> factory,
boolean prune)
Utility method.
|
boolean |
isAncestor(ClassLoader classLoader)
Check to see if
classLoader is an
ancestor of any contained class loader. |
void |
put(ClassLoader classLoader)
Specify a new class loader to be used in searching.
|
void |
put(ClassLoader classLoader,
boolean prune)
Specify a new class loader to be used in searching.
|
int |
size()
Returns the size of class loaders set.
|
protected List<ClassLoader> classLoaders
public int size()
public ClassLoader get(int idx)
idx
- The index the class loader has to be retrieved frompublic void put(ClassLoader classLoader)
null
class loaders are discarded.classLoader
- The class loader has to added in the setpublic void put(ClassLoader classLoader, boolean prune)
null
class loaders are discarded.classLoader
- The class loader has to added in the setprune
- if true, verify that the class loader is
not an Ancestor (@see isAncestor) before
adding it to our list.public boolean isAncestor(ClassLoader classLoader)
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.classLoader
- The class loader under testpublic static ClassLoaders getLibLoaders(Class<?> spi, Class<?> factory, boolean prune)
spi
- WHAT is being looked for (an implementation of this class,
a default property file related to this class).factory
- WHO is performing the lookup.prune
- Determines if ancestors are allowed to be loaded or not.public static ClassLoaders getAppLoaders(Class<?> spi, Class<?> factory, boolean prune)
spi
- WHAT is being looked for (an implementation of this class,
a default property file related to this class).factory
- WHO is performing the lookup (factory).prune
- Determines if ancestors are allowed to be loaded or not.Copyright © 2002–2016 The Apache Software Foundation. All rights reserved.