Interface IBindingContext.IModuleLoaderStrategy
- All Superinterfaces:
ModuleLoadingPostProcessor
- All Known Implementing Classes:
AbstractModuleLoaderStrategy
,PostProcessingModuleLoaderStrategy
,SimpleModuleLoaderStrategy
- Enclosing interface:
- IBindingContext
A module will flow through the following process.
- Loading: The module is read from its source.
- Post Processing: The module is prepared for use.
- Registration: The module is registered for use.
A module will be loaded when either the module or one of its global definitions is accessed the first time.
-
Method Summary
Modifier and TypeMethodDescriptionGet the matchers used to identify the bound class associated with the definition's root name.getBoundDefinitionForClass
(Class<? extends IBoundObject> clazz, IBindingContext bindingContext) Get theIBoundDefinitionModel
instance associated with the provided Java class.loadModule
(Class<? extends IBoundModule> clazz, IBindingContext bindingContext) Load the bound Metaschema module represented by the provided class.default void
postProcessModule
(IModule module, IBindingContext bindingContext) Perform post-processing on the module.registerModule
(IModule module, IBindingContext bindingContext) Registers the provided Metaschema module.
-
Method Details
-
loadModule
@NonNull IBoundModule loadModule(@NonNull Class<? extends IBoundModule> clazz, @NonNull IBindingContext bindingContext) Load the bound Metaschema module represented by the provided class.This is the primary entry point for loading an already bound module. This method must ensure that the loaded module is post-processed and registered.
Implementations are allowed to return a cached instance if the module has already been loaded by this method.
- Parameters:
clazz
- the Module classbindingContext
- the Metaschema binding context used to load bound resources- Returns:
- the module
- Throws:
IllegalStateException
- if an error occurred while processing the associated module information- Since:
- 2.0.0
-
postProcessModule
Perform post-processing on the module.- Specified by:
postProcessModule
in interfaceModuleLoadingPostProcessor
- Parameters:
module
- the Metaschema module to post-processbindingContext
- the Metaschema binding context used to load bound resources- Since:
- 2.0.0
-
registerModule
@NonNull IBoundModule registerModule(@NonNull IModule module, @NonNull IBindingContext bindingContext) Registers the provided Metaschema module.If this module has not been post-processed, this method is expected to drive post-processing first.
If the provided instance is not an instance of
IBoundModule
, then annotated Java classes for this module will be generated, compiled, and loaded based on the provided Module.- Parameters:
module
- the Module module to generate classes forbindingContext
- the Metaschema binding context used to load bound resources- Returns:
- the registered module, which may be a different instance than what was provided if dynamic compilation was performed
- Throws:
UnsupportedOperationException
- if this binding context is not configured to support dynamic bound module loading and the module instance is not a subclass ofIBoundModule
- Since:
- 2.0.0
-
getBindingMatchers
Get the matchers used to identify the bound class associated with the definition's root name.- Returns:
- the matchers
-
getBoundDefinitionForClass
@NonNull IBoundDefinitionModelComplex getBoundDefinitionForClass(@NonNull Class<? extends IBoundObject> clazz, @NonNull IBindingContext bindingContext) Get theIBoundDefinitionModel
instance associated with the provided Java class.Typically the class will have a
MetaschemaAssembly
orMetaschemaField
annotation.- Parameters:
clazz
- the class binding to loadbindingContext
- the Metaschema binding context used to load bound resources- Returns:
- the associated class binding instance
- Throws:
IllegalArgumentException
- if the class is not a bound definition with aMetaschemaAssembly
orMetaschemaField
annotation
-