public class DefaultClassLoaderProvider extends Object implements ClassLoaderProvider
A default implementation of the ClassLoaderProvider interface.
This is a straight-forward (but thread-safe) implementation of all the
methods defined by the ClassLoaderProvider interface. Class loaders
registered at this object are stored in a map. A default class loader name
can be set. If none has been set, the class loader that loaded this class is
returned as default class loader.
Per default, classes of the library (starting with the prefix
net.sf.jguiraffe) are always loaded by the class loader which loaded
this class. This makes sense for instance in an OSGi environment: it
allows access even to internal implementation classes. This behavior can be
disabled by setting the handleInternalClasses property to
false. Then the selected class loader is used to load all classes.
CONTEXT_CLASS_LOADER| Constructor and Description |
|---|
DefaultClassLoaderProvider()
Creates a new instance of
DefaultClassLoaderProvider. |
DefaultClassLoaderProvider(boolean fHandleInternalClasses)
Creates a new instance of
DefaultClassLoaderProvider and sets the
flag whether internal classes should be handled in a special way. |
| Modifier and Type | Method and Description |
|---|---|
Set<String> |
classLoaderNames()
Returns a set with the names of the class loaders that have been
registered at this object.
|
ClassLoader |
getClassLoader(String name)
Returns the class loader specified by the given symbolic name.
|
String |
getDefaultClassLoaderName()
Returns the name of the default class loader.
|
boolean |
isHandleInternalClasses()
Returns a flag whether internal library classes are handled in a special
way by this class loader provider.
|
Class<?> |
loadClass(String name,
String loaderRef)
Loads the class with the specified name using the class loader identified
by the given symbolic reference.
|
void |
registerClassLoader(String name,
ClassLoader loader)
Allows to register a class loader under a symbolic name.
|
void |
setDefaultClassLoaderName(String loaderName)
Sets the name of the default class loader.
|
public DefaultClassLoaderProvider()
DefaultClassLoaderProvider.public DefaultClassLoaderProvider(boolean fHandleInternalClasses)
DefaultClassLoaderProvider and sets the
flag whether internal classes should be handled in a special way.fHandleInternalClasses - the value of the flagpublic boolean isHandleInternalClasses()
public Set<String> classLoaderNames()
getClassLoader() method.classLoaderNames in interface ClassLoaderProviderpublic ClassLoader getClassLoader(String name)
getClassLoader in interface ClassLoaderProvidername - the name of the class loaderInjectionException - if the class loader cannot be resolvedpublic String getDefaultClassLoaderName()
getDefaultClassLoaderName in interface ClassLoaderProvider#setDefaultClassLoader(ClassLoader)public Class<?> loadClass(String name, String loaderRef)
loadClass in interface ClassLoaderProvidername - the class of the name to be loadedloaderRef - determines the class loader to be usedInjectionException - if the class cannot be loadedpublic void registerClassLoader(String name, ClassLoader loader)
registerClassLoader in interface ClassLoaderProvidername - the name of the class loader (must not be null)loader - the class loader to be registered; can be null, then
the class loader with the given name will be removedIllegalArgumentException - if the name is nullpublic void setDefaultClassLoaderName(String loaderName)
ClassLoaderProvider.CONTEXT_CLASS_LOADER for the context class
loader. A value of null causes getClassLoader(String) to
fall back to the class loader which loaded this class.setDefaultClassLoaderName in interface ClassLoaderProviderloaderName - the new default class loaderCopyright © 2016 The JGUIraffe Team. All rights reserved.