1   /*
2    * SPDX-FileCopyrightText: none
3    * SPDX-License-Identifier: CC0-1.0
4    */
5   
6   package gov.nist.secauto.metaschema.databind.model.metaschema;
7   
8   import gov.nist.secauto.metaschema.core.configuration.IMutableConfiguration;
9   import gov.nist.secauto.metaschema.core.model.IModuleLoader;
10  import gov.nist.secauto.metaschema.databind.IBindingContext;
11  import gov.nist.secauto.metaschema.databind.IBindingContext.IModuleLoaderStrategy;
12  import gov.nist.secauto.metaschema.databind.SimpleModuleLoaderStrategy;
13  import gov.nist.secauto.metaschema.databind.codegen.DefaultModuleBindingGenerator;
14  import gov.nist.secauto.metaschema.databind.io.DeserializationFeature;
15  
16  import edu.umd.cs.findbugs.annotations.NonNull;
17  
18  /**
19   * Supports loading a Metaschema module from a specified resource.
20   * <p>
21   * Metaschema modules loaded this way are automatically registered with the
22   * {@link IBindingContext}.
23   * <p>
24   * Use of this Metaschema module loader requires that the associated binding
25   * context is initialized using a {@link IModuleLoaderStrategy} that supports
26   * dynamic bound module loading. This can be accomplished using the
27   * {@link SimpleModuleLoaderStrategy} initialized using the
28   * {@link DefaultModuleBindingGenerator}.
29   *
30   */
31  public interface IBindingModuleLoader
32      extends IModuleLoader<IBindingMetaschemaModule>, IMutableConfiguration<DeserializationFeature<?>> {
33    /**
34     * Get the associated binding context.
35     *
36     * @return the binding context
37     */
38    @NonNull
39    IBindingContext getBindingContext();
40  
41    /**
42     * Enable entity resolution within a loaded Metaschema module resource.
43     */
44    default void allowEntityResolution() {
45      enableFeature(DeserializationFeature.DESERIALIZE_XML_ALLOW_ENTITY_RESOLUTION);
46    }
47  }