de.innovationgate.wga.modules
public class ModuleRegistry extends java.lang.Object
ModuleDefinition
objects, which are mapped by their module type and their implementation class. There can be exactly one module definition for a combination of module type and implementation class
ModuleType
ModuleDefinition
instances or even module implementations themselves when they implement RegistryAwareModuleDefinition
and RegistryAwareModule
respectively. So those module (definitions) can use the registry to do further lookups.
getContextObjects()
OptionCategoryDefinition
to provide titles and descriptions for the category names that option definitions provide via OptionDefinition.getCategory()
. There can be exactly one option category for a combination of category name and module type.
Modifier and Type | Field and Description |
---|---|
static java.lang.String |
MODULEREGISTRATORS_RESOURCE
The name of the text file resource which should contain a full qualified name of a
ModuleRegistrar implementation |
Constructor and Description |
---|
ModuleRegistry() |
Modifier and Type | Method and Description |
---|---|
void |
addChangeListener(ModuleRegistryChangeListener listener,
java.lang.Class<? extends ModuleType> moduleType) |
void |
addModuleDefinition(ModuleDefinition modDef)
Add a module definition to the registry.
|
void |
addOptionCategoryDefinition(OptionCategoryDefinition catDef)
Adds an option category definition
|
void |
clearChangeListeners() |
ValidationContext |
createValidationContext(WGAConfiguration configCopy)
Creates a validation context for option validations
|
java.util.Map<java.lang.Class,java.lang.Object> |
getContextObjects()
Returns a map of arbitrary context objects that may be needed for registry aware
ModuleDefinition implementations or modules themselves to work |
ModuleDefinition |
getModuleDefinition(java.lang.Class<? extends ModuleType> moduleType,
java.lang.Class implClass)
Returns a module definition for a givne module type and implementation class
|
ModuleDefinition |
getModuleDefinition(java.lang.Class<? extends ModuleType> moduleType,
java.lang.String className)
Returns a module definition for a givne module type and implementation class
|
ModuleDefinition |
getModuleDefinition(java.lang.String modType,
java.lang.String className)
Returns a module definition for a given module type and implementation class
|
ModuleDefinition |
getModuleDefinitionByKey(java.lang.Class<? extends ModuleType> moduleType,
java.lang.String regKey)
Tries to retrieve a
KeyBasedModuleDefinition from registry via it's key |
java.util.Map<java.lang.String,ModuleDefinition> |
getModulesForType(java.lang.Class<? extends ModuleType> moduleType)
Returns the
Map that stores all module definitions of a given type. |
java.util.Map<java.lang.String,ModuleDefinition> |
getModulesForType(java.lang.String moduleTypeClassName) |
java.util.Set<java.lang.String> |
getModuleTypes() |
java.util.Map<java.lang.String,OptionCategoryDefinition> |
getOptionCategoriesForType(java.lang.Class<? extends ModuleType> moduleType)
Returns the
Map that stores all option category definitions for a given module type. |
OptionCategoryDefinition |
getOptionCategoryDefinition(java.lang.Class<? extends ModuleType> moduleType,
java.lang.String key)
Returns an option category definition
|
java.lang.Object |
instantiate(java.lang.Class<? extends java.lang.Object> moduleClass)
Method to create a module instantiation.
|
java.lang.Object |
instantiate(ModuleDefinition def)
Method to create a module instantiation.
|
void |
removeChangeListener(ModuleRegistryChangeListener listener) |
void |
removeDefinitionsFromLoader(java.lang.String loaderKey) |
void |
searchModuleDefinitions(java.lang.ClassLoader classLoader)
Triggers the search for
ModuleRegistrar s on the given class loader. |
void |
searchModuleDefinitions(java.lang.ClassLoader classLoader,
java.lang.Iterable<java.net.URLClassLoader> registrarCfgLoaders)
Triggers the search for
ModuleRegistrar s on the given class loader, but only those whose registration configs are on a list of registrar class loaders. |
public static final java.lang.String MODULEREGISTRATORS_RESOURCE
ModuleRegistrar
implementationpublic void addModuleDefinition(ModuleDefinition modDef)
RegistryAwareModuleDefinition
, this also injects a registry reference via method RegistryAwareModuleDefinition.injectRegistry(ModuleRegistry)
public void addOptionCategoryDefinition(OptionCategoryDefinition catDef)
public void removeDefinitionsFromLoader(java.lang.String loaderKey)
public java.util.Map<java.lang.String,OptionCategoryDefinition> getOptionCategoriesForType(java.lang.Class<? extends ModuleType> moduleType)
Map
that stores all option category definitions for a given module type.
Modifying this map also modifies the registration!moduleType
- The type of module for whom the registered option categories are retrievedOptionCategoryDefinition
s themselvespublic OptionCategoryDefinition getOptionCategoryDefinition(java.lang.Class<? extends ModuleType> moduleType, java.lang.String key)
moduleType
- The module type for whom the category was registeredkey
- The category name as returned by option definitions via OptionDefinition.getCategory()
public java.util.Map<java.lang.String,ModuleDefinition> getModulesForType(java.lang.Class<? extends ModuleType> moduleType)
Map
that stores all module definitions of a given type.
Modifying this map also modifies the registration!moduleType
- The type of moduleKEYBASED_MODULE_PREFIX
plus key for KeyBasedModuleDefinition
instantations. The values are the ModuleDefinition
s themselvespublic java.util.Map<java.lang.String,ModuleDefinition> getModulesForType(java.lang.String moduleTypeClassName)
public ModuleDefinition getModuleDefinition(java.lang.String modType, java.lang.String className)
modType
- The full qualified class name of the module typeclassName
- The full qualified class name of the implementation classpublic ModuleDefinition getModuleDefinition(java.lang.Class<? extends ModuleType> moduleType, java.lang.String className)
moduleType
- The module typeclassName
- the full qualified name of the implementation classpublic ModuleDefinition getModuleDefinitionByKey(java.lang.Class<? extends ModuleType> moduleType, java.lang.String regKey)
KeyBasedModuleDefinition
from registry via it's keymoduleType
- The type of moduleregKey
- The registration key that the module definition returns via KeyBasedModuleDefinition.getRegistrationKey()
public ModuleDefinition getModuleDefinition(java.lang.Class<? extends ModuleType> moduleType, java.lang.Class implClass)
moduleType
- The module typeimplClass
- The implementation classpublic void searchModuleDefinitions(java.lang.ClassLoader classLoader) throws java.io.IOException
ModuleRegistrar
s on the given class loader.
The method searches for all known text file resources of name "de/innovationgate/wga/modules/registrar.cfg" on the class loader.
These files should contain the full qualified name of a ModuleRegistrar
implementation which then is instantiated.
The method ModuleRegistrar.registerModules(ModuleRegistry)
is called so it can register it's known module definitions.classLoader
- The class loader to load registrars fromjava.io.IOException
public void searchModuleDefinitions(java.lang.ClassLoader classLoader, java.lang.Iterable<java.net.URLClassLoader> registrarCfgLoaders) throws java.io.IOException
ModuleRegistrar
s on the given class loader, but only those whose registration configs are on a list of registrar class loaders.
The method searches for all known text file resources of name "de/innovationgate/wga/modules/registrar.cfg" on the registrarCfgLoaders.
However it only searches for these resources right on these class loaders, not on their parent loaders.
These files should contain the full qualified name of a ModuleRegistrar
implementation which then is instantiated.
The method ModuleRegistrar.registerModules(ModuleRegistry)
is called so it can register it's known module definitions.classLoader
- The class loader to load registrar and module classes fromregistrarCfgLoaders
- The class loader to load registrar configurations from.java.io.IOException
public ValidationContext createValidationContext(WGAConfiguration configCopy)
public java.util.Map<java.lang.Class,java.lang.Object> getContextObjects()
ModuleDefinition
implementations or modules themselves to workpublic java.lang.Object instantiate(ModuleDefinition def) throws ModuleInstantiationException
instantiate(Class)
to create module instances, because it is capable of injecting the registry to RegistryAwareModule
s.def
- The definition of the moduleModuleInstantiationException
public java.lang.Object instantiate(java.lang.Class<? extends java.lang.Object> moduleClass) throws ModuleInstantiationException
instantiate(ModuleDefinition)
to create module instances, because it is capable of injecting the registry to RegistryAwareModule
s.moduleClass
- The implementation class of the moduleModuleInstantiationException
public java.util.Set<java.lang.String> getModuleTypes()
public void addChangeListener(ModuleRegistryChangeListener listener, java.lang.Class<? extends ModuleType> moduleType)
public void clearChangeListeners()
public void removeChangeListener(ModuleRegistryChangeListener listener)