Class ModuleCompilerHelper
java.lang.Object
gov.nist.secauto.metaschema.databind.codegen.ModuleCompilerHelper
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 Summary
Modifier and TypeMethodDescriptionstatic IProduction
compileMetaschema
(IModule module, Path classDir) Generate and compile Java class, representing the provided Modulemodule
and its related definitions, using the default binding configuration.static IProduction
compileModule
(IModule module, Path classDir, IBindingConfiguration bindingConfiguration) Generate and compile Java class, representing the provided Modulemodule
and its related definitions, using the provided custombindingConfiguration
.static @Owning ClassLoader
newClassLoader
(Path classDir, ClassLoader parent) Create a new classloader capable of loading Java classes generated in the providedclassDir
.
-
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 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
-
compileMetaschema
@NonNull public static IProduction compileMetaschema(@NonNull IModule module, @NonNull Path classDir) throws IOException Generate and compile Java class, representing the provided Modulemodule
and 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 Modulemodule
and 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
-