java.lang.Object
gov.nist.secauto.metaschema.databind.codegen.ModuleCompilerHelper

public final class ModuleCompilerHelper extends Object
This class provides methods to generate and dynamically compile Java code based on a Module. The newClassLoader(Path, ClassLoader) method can be used to get a ClassLoader for Java code previously generated by this class.
  • Method Details

    • newClassLoader

      @Owning @NonNull public static @Owning ClassLoader newClassLoader(@NonNull Path classDir, @NonNull ClassLoader parent)
      Create a new classloader capable of loading Java classes generated in the provided classDir.
      Parameters:
      classDir - the directory where generated Java classes have been compiled
      parent - the classloader to delegate to when the created class loader cannot load a class
      Returns:
      the new class loader
    • compileMetaschema

      @NonNull public static IProduction compileMetaschema(@NonNull IModule module, @NonNull Path classDir) throws IOException
      Generate and compile Java class, representing the provided Module module and its related definitions, using the default binding configuration.
      Parameters:
      module - the Module module to generate Java classes for
      classDir - the directory to generate the classes in
      Returns:
      information about the generated classes
      Throws:
      IOException - if an error occurred while generating or compiling the classes
    • compileModule

      @NonNull public static IProduction compileModule(@NonNull IModule module, @NonNull Path classDir, @NonNull IBindingConfiguration bindingConfiguration) throws IOException
      Generate and compile Java class, representing the provided Module module and its related definitions, using the provided custom bindingConfiguration.
      Parameters:
      module - the Module module to generate Java classes for
      classDir - the directory to generate the classes in
      bindingConfiguration - configuration settings with directives that tailor the class generation
      Returns:
      information about the generated classes
      Throws:
      IOException - if an error occurred while generating or compiling the classes