Interface IBindingContext.IModuleLoaderStrategy

All Superinterfaces:
ModuleLoadingPostProcessor
All Known Implementing Classes:
AbstractModuleLoaderStrategy, PostProcessingModuleLoaderStrategy, SimpleModuleLoaderStrategy
Enclosing interface:
IBindingContext

A behavioral class used by the binding context to load Metaschema modules.

A module will flow through the following process.

  1. Loading: The module is read from its source.
  2. Post Processing: The module is prepared for use.
  3. 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 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 class
      bindingContext - 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

      default void postProcessModule(@NonNull IModule module, @NonNull IBindingContext bindingContext)
      Perform post-processing on the module.
      Specified by:
      postProcessModule in interface ModuleLoadingPostProcessor
      Parameters:
      module - the Metaschema module to post-process
      bindingContext - 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 for
      bindingContext - 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 of IBoundModule
      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 the IBoundDefinitionModel instance associated with the provided Java class.

      Typically the class will have a MetaschemaAssembly or MetaschemaField annotation.

      Parameters:
      clazz - the class binding to load
      bindingContext - 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 a MetaschemaAssembly or MetaschemaField annotation