public interface ClassLoaderProvider
Definition of an interface for objects that act as a registry for class loaders.
In complex environments different class loaders can play an important role. Thus the dependency injection framework supports the registration of arbitrary class loaders; they are assigned a symbolic name. When a class is loaded, a class loader can be specified by the symbolic name it was registered.
This interface provides access to the registered class loaders by their symbolic name. It can be used by components that need to load classes per reflection.
Modifier and Type | Field and Description |
---|---|
static String |
CONTEXT_CLASS_LOADER
Constant for the reserved name of the context class loader.
|
Modifier and Type | Method and Description |
---|---|
Set<String> |
classLoaderNames()
Returns a set with the names of all registered class loaders.
|
ClassLoader |
getClassLoader(String name)
Returns a reference to the class loader with the specified symbolic name.
|
String |
getDefaultClassLoaderName()
Returns the name of the default class loader.
|
Class<?> |
loadClass(String name,
String loaderRef)
Returns the class specified by the given name.
|
void |
registerClassLoader(String name,
ClassLoader loader)
Registers a
ClassLoader under the given name. |
void |
setDefaultClassLoaderName(String loaderName)
Sets the name of the default class loader.
|
static final String CONTEXT_CLASS_LOADER
getClassLoader()
method, the
context class loader will automatically be used.ClassLoader getClassLoader(String name)
CONTEXT_CLASS_LOADER
can be
passed in, too, for obtaining a reference to the context class loader. In
all other cases the parameter is interpreted as the symbolic name of a
registered class loader. If no class loader is found under this name, an
exception will be thrown.name
- the name of the desired class loaderInjectionException
- if the class loader cannot be resolvedClass<?> loadClass(String name, String loaderRef)
getClassLoader(String)
method.
Occurring exceptions are re-thrown as runtime exceptions.name
- the name of the class to be loaded (must not be null)loaderRef
- the name, under which the desired class loader is
registered (null for the default class loader)InjectionException
- if the class cannot be loadedvoid registerClassLoader(String name, ClassLoader loader)
ClassLoader
under the given name. This class
loader can later be accessed using the getClassLoader()
method. If the class loader reference is null, the class loader
with the given name will be unregistered.name
- a symbolic name for the class loader (must not be null)loader
- the class loader to be registeredIllegalArgumentException
- if the name is undefinedString getDefaultClassLoaderName()
#setDefaultClassLoader(ClassLoader)
void setDefaultClassLoaderName(String loaderName)
loaderName
- the name of the new default class loaderCopyright © 2016 The JGUIraffe Team. All rights reserved.