public abstract class AbstractModuleRegistry extends ModuleRegistry
Modifier and Type | Field and Description |
---|---|
static String[] |
DEFAULT_DO_NOT_LOAD_CLASS_PREFIXES
Only load classes with this prefix from the default ClassLoader.
|
protected Object |
RESOLVE_LOCK
This object is used as a semaphore for Module loads.
|
protected String[] |
theDoNotLoadClassPrefixes
Always load classes with these prefixes through the default ClassLoader.
|
theSingleton
Modifier | Constructor and Description |
---|---|
protected |
AbstractModuleRegistry(String[] doNotLoadClassPrefixes)
Constructor.
|
Modifier and Type | Method and Description |
---|---|
void |
addModuleRegistryListener(ModuleRegistryListener newListener)
Add a ModuleRegistry listener to be notified when new Modules become available etc.
|
protected ClassLoader |
createClassLoader(Module module,
ClassLoader parentClassLoader)
ModuleRegistries can also acts as a factory for the Modules' ClassLoaders.
|
Module[] |
determineRuntimeDependencies(Module theModule)
Given a Module, this allows us to determine which other Modules it depends at
run-time.
|
Module[] |
determineRuntimeUses(Module theModule)
Given a Module, this allows us to determine which other Modules use it at
run-time.
|
ModuleMeta |
determineSingleResolutionCandidate(ModuleRequirement req)
Convenience method to determine the one and only ModuleMeta that is the only candidate to resolve a Module
dependency, based on the knowledge of this ModuleRegistry.
|
protected void |
fireModuleAddedEvent(ModuleRegistryEvent theEvent)
Send an event to our listeners.
|
Module |
getResolutionOf(ModuleMeta meta)
Determine whether a certain ModuleMeta is resolved already, and if so,
return it.
|
void |
removeModuleRegistryListener(ModuleRegistryListener oldListener)
Remove a ModuleRegistry listener.
|
Module |
resolve(ModuleMeta meta)
Recursively resolve this ModuleMeta into a Module.
|
Module |
resolve(ModuleMeta meta,
boolean recursive)
Resolve this ModuleMeta into a Module.
|
String |
toString()
Obtain String representation.
|
determineResolutionCandidates, getSingleton, nameSet, nameSet
protected String[] theDoNotLoadClassPrefixes
protected final Object RESOLVE_LOCK
public static final String[] DEFAULT_DO_NOT_LOAD_CLASS_PREFIXES
protected AbstractModuleRegistry(String[] doNotLoadClassPrefixes)
doNotLoadClassPrefixes
- prefixes of classes always to be loaded through the system class loader, not this onepublic final ModuleMeta determineSingleResolutionCandidate(ModuleRequirement req) throws NoModuleResolutionCandidateException, ModuleResolutionCandidateNotUniqueException
determineSingleResolutionCandidate
in class ModuleRegistry
req
- the ModuleRequirement that we attempt to resolveNoModuleResolutionCandidateException
- thrown if no ModuleMeta was foundModuleResolutionCandidateNotUniqueException
- thrown if there were more than one ModuleMeta foundpublic final Module resolve(ModuleMeta meta) throws ModuleNotFoundException, ModuleResolutionException
resolve
in class ModuleRegistry
meta
- the ModuleMeta to resolveModuleNotFoundException
- thrown if the Module could not be foundModuleResolutionException
- thrown if the Module could not be resolvedpublic final Module resolve(ModuleMeta meta, boolean recursive) throws ModuleNotFoundException, ModuleResolutionException
resolve
in class ModuleRegistry
meta
- the ModuleMeta to resolverecursive
- resolve recursively if set to trueModuleNotFoundException
- thrown if the Module could not be foundModuleResolutionException
- thrown if the Module could not be resolvedpublic final Module getResolutionOf(ModuleMeta meta)
getResolutionOf
in class ModuleRegistry
meta
- the ModuleMeta whose resolution we checkpublic final Module[] determineRuntimeDependencies(Module theModule)
determineRuntimeDependencies
in class ModuleRegistry
theModule
- the Module whose run-time dependencies we want to determineModuleRegistry.determineRuntimeUses(org.diet4j.core.Module)
public final Module[] determineRuntimeUses(Module theModule)
determineRuntimeUses
in class ModuleRegistry
theModule
- the Module whose uses we want to determine at run-timeModuleRegistry.determineRuntimeDependencies(org.diet4j.core.Module)
protected ClassLoader createClassLoader(Module module, ClassLoader parentClassLoader)
createClassLoader
in class ModuleRegistry
module
- the Module for which to create a ClassLoaderparentClassLoader
- the ClassLoader to use as the parent ClassLoaderpublic final void addModuleRegistryListener(ModuleRegistryListener newListener)
addModuleRegistryListener
in class ModuleRegistry
newListener
- the new listener to addModuleRegistry.removeModuleRegistryListener(org.diet4j.core.ModuleRegistryListener)
public final void removeModuleRegistryListener(ModuleRegistryListener oldListener)
removeModuleRegistryListener
in class ModuleRegistry
oldListener
- the listener to removeModuleRegistry.addModuleRegistryListener(org.diet4j.core.ModuleRegistryListener)
protected final void fireModuleAddedEvent(ModuleRegistryEvent theEvent)
theEvent
- the event to sendCopyright © 2018. All rights reserved.