java.lang.Object
dev.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 IProductioncompileMetaschema(dev.metaschema.core.model.IModule module, Path classDir) Generate and compile Java class, representing the provided Modulemoduleand its related definitions, using the default binding configuration.static IProductioncompileModule(dev.metaschema.core.model.IModule module, Path classDir, IBindingConfiguration bindingConfiguration) Generate and compile Java class, representing the provided Modulemoduleand its related definitions, using the provided custombindingConfiguration.static @Owning ClassLoadernewClassLoader(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.The caller owns the returned class loader and is responsible for closing it.
- 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 dev.metaschema.core.model.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 dev.metaschema.core.model.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
-