Class ModuleCompilerHelper
- 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. ThenewClassLoader(Path, ClassLoader)method can be used to get aClassLoaderfor Java code previously generated by this class.
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static IProductioncompileMetaschema(IModule module, Path classDir)Generate and compile Java class, representing the provided Modulemoduleand its related definitions, using the default binding configuration.static IProductioncompileModule(IModule module, Path classDir, IBindingConfiguration bindingConfiguration)Generate and compile Java class, representing the provided Modulemoduleand its related definitions, using the provided custombindingConfiguration.static ClassLoadernewClassLoader(Path classDir, ClassLoader parent)Create a new classloader capable of loading Java classes generated in the providedclassDir.
-
-
-
Method Detail
-
compileMetaschema
@NonNull public static IProduction compileMetaschema(@NonNull IModule module, @NonNull Path classDir) throws IOException
Generate and compile Java class, representing the provided Modulemoduleand its related definitions, using the default binding configuration.- Parameters:
module- the Module module to generate Java classes forclassDir- 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 Modulemoduleand its related definitions, using the provided custombindingConfiguration.- Parameters:
module- the Module module to generate Java classes forclassDir- the directory to generate the classes inbindingConfiguration- 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
-
newClassLoader
@NonNull public static ClassLoader newClassLoader(@NonNull Path classDir, @NonNull ClassLoader parent)
Create a new classloader capable of loading Java classes generated in the providedclassDir.- Parameters:
classDir- the directory where generated Java classes have been compiledparent- the classloader to delegate to when the created class loader cannot load a class- Returns:
- the new class loader
-
-