Class AbstractModuleLoader<T,M extends IModuleExtended<M,?,?,?,?>>

java.lang.Object
dev.metaschema.core.model.AbstractLoader<M>
dev.metaschema.core.model.AbstractModuleLoader<T,M>
Type Parameters:
T - the Java type of the module binding
M - the Java type of the Metaschema module loaded by this loader
All Implemented Interfaces:
ILoader<M>, IModuleLoader<M>
Direct Known Subclasses:
BindingModuleLoader

public abstract class AbstractModuleLoader<T,M extends IModuleExtended<M,?,?,?,?>> extends AbstractLoader<M> implements IModuleLoader<M>
Provides methods to load a Metaschema expressed in XML.

Loaded Metaschema instances are cached to avoid the need to load them for every use. Any Metaschema imported is also loaded and cached automatically.

  • Constructor Details

    • AbstractModuleLoader

      protected AbstractModuleLoader()
      Construct a new Metaschema module loader, which use the provided module post processors when loading a module.
  • Method Details

    • newModule

      @NonNull protected abstract M newModule(@NonNull URI resource, @NonNull T binding, @NonNull List<? extends M> importedModules) throws MetaschemaException
      Parse the resource based on the provided xmlObject.
      Parameters:
      resource - the URI of the resource being parsed
      binding - the XML beans object to parse
      importedModules - previously parsed Metaschema modules imported by the provided resource
      Returns:
      the parsed resource as a Metaschema module
      Throws:
      MetaschemaException - if an error occurred while parsing the XML beans object
    • getImports

      @NonNull protected abstract List<URI> getImports(@NonNull T binding)
      Get the list of Metaschema module URIs associated with the provided binding.
      Parameters:
      binding - the Metaschema module binding declaring the imports
      Returns:
      the list of Metaschema module URIs
    • parseResource

      protected M parseResource(@NonNull URI resource, @NonNull Deque<URI> visitedResources) throws IOException
      Description copied from class: AbstractLoader
      Parse the provided resource.
      Specified by:
      parseResource in class AbstractLoader<M extends IModuleExtended<M,?,?,?,?>>
      Parameters:
      resource - the resource to parse
      visitedResources - a stack representing previously parsed resources imported by the provided resource
      Returns:
      the parsed resource
      Throws:
      IOException - if an error occurred while parsing the resource
    • parseModule

      @NonNull protected abstract T parseModule(@NonNull URI resource) throws IOException
      Parse the provided XML resource as a Metaschema module.
      Parameters:
      resource - the resource to parse
      Returns:
      the parsed Metaschema module
      Throws:
      IOException - if a parsing error occurred