Class AbstractModuleLoaderStrategy
java.lang.Object
gov.nist.secauto.metaschema.databind.AbstractModuleLoaderStrategy
- All Implemented Interfaces:
IBindingContext.IModuleLoaderStrategy,ModuleLoadingPostProcessor
- Direct Known Subclasses:
SimpleModuleLoaderStrategy
public abstract class AbstractModuleLoaderStrategy
extends Object
implements IBindingContext.IModuleLoaderStrategy
Provides basic module loading capabilities.
- Since:
- 2.0.0
-
Constructor Summary
Constructors -
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 theIBoundDefinitionModelinstance associated with the provided Java class.protected abstract Class<? extends IBoundModule>loadModule(Class<? extends IBoundModule> clazz, IBindingContext bindingContext) Load the bound Metaschema module represented by the provided class.protected IBoundModulelookupInstance(Class<? extends IBoundModule> moduleClass, IBindingContext bindingContext) Get the Module instance for a given class annotated by theMetaschemaModuleannotation, instantiating it if needed.protected IBindingContext.IBindingMatcherregisterBindingMatcher(IBoundDefinitionModelAssembly definition) registerModule(IModule module, IBindingContext bindingContext) Registers the provided Metaschema module.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface gov.nist.secauto.metaschema.databind.IBindingContext.IModuleLoaderStrategy
postProcessModule
-
Constructor Details
-
AbstractModuleLoaderStrategy
public AbstractModuleLoaderStrategy()
-
-
Method Details
-
loadModule
public IBoundModule loadModule(@NonNull Class<? extends IBoundModule> clazz, @NonNull IBindingContext bindingContext) Description copied from interface:IBindingContext.IModuleLoaderStrategyLoad 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.
- Specified by:
loadModulein interfaceIBindingContext.IModuleLoaderStrategy- Parameters:
clazz- the Module classbindingContext- the Metaschema binding context used to load bound resources- Returns:
- the module
-
registerModule
Description copied from interface:IBindingContext.IModuleLoaderStrategyRegisters 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.- Specified by:
registerModulein interfaceIBindingContext.IModuleLoaderStrategy- 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
-
handleUnboundModule
-
lookupInstance
@NonNull protected IBoundModule lookupInstance(@NonNull Class<? extends IBoundModule> moduleClass, @NonNull IBindingContext bindingContext) Get the Module instance for a given class annotated by theMetaschemaModuleannotation, instantiating it if needed.Will also load any imported Metaschemas.
- Parameters:
moduleClass- the Module classbindingContext- the Metaschema binding context used to lookup binding information- Returns:
- the new Module instance
-
registerBindingMatcher
@NonNull protected IBindingContext.IBindingMatcher registerBindingMatcher(@NonNull IBoundDefinitionModelAssembly definition) -
getBindingMatchers
Description copied from interface:IBindingContext.IModuleLoaderStrategyGet the matchers used to identify the bound class associated with the definition's root name.- Specified by:
getBindingMatchersin interfaceIBindingContext.IModuleLoaderStrategy- Returns:
- the matchers
-
getBoundDefinitionForClass
public IBoundDefinitionModelComplex getBoundDefinitionForClass(@NonNull Class<? extends IBoundObject> clazz, @NonNull IBindingContext bindingContext) Description copied from interface:IBindingContext.IModuleLoaderStrategyGet theIBoundDefinitionModelinstance associated with the provided Java class.Typically the class will have a
MetaschemaAssemblyorMetaschemaFieldannotation.- Specified by:
getBoundDefinitionForClassin interfaceIBindingContext.IModuleLoaderStrategy- Parameters:
clazz- the class binding to loadbindingContext- the Metaschema binding context used to load bound resources- Returns:
- the associated class binding instance
-