001/* 002 * SPDX-FileCopyrightText: none 003 * SPDX-License-Identifier: CC0-1.0 004 */ 005 006package gov.nist.secauto.metaschema.databind; 007 008import gov.nist.secauto.metaschema.core.model.IModule; 009import gov.nist.secauto.metaschema.databind.codegen.IModuleBindingGenerator; 010import gov.nist.secauto.metaschema.databind.model.IBoundModule; 011 012import edu.umd.cs.findbugs.annotations.NonNull; 013 014public class SimpleModuleLoaderStrategy 015 extends AbstractModuleLoaderStrategy { 016 @NonNull 017 private static final IModuleBindingGenerator COMPILATION_DISABLED_GENERATOR = module -> { 018 throw new UnsupportedOperationException( 019 "Dynamic compilation of Metaschema modules is not enabled by default." + 020 " Configure a different IModuleBindingGenerator with the IModuleLoaderStrategy" + 021 " used with the IBindignContext."); 022 }; 023 024 @NonNull 025 private final IModuleBindingGenerator generator; 026 027 public SimpleModuleLoaderStrategy() { 028 this(COMPILATION_DISABLED_GENERATOR); 029 } 030 031 public SimpleModuleLoaderStrategy(@NonNull IModuleBindingGenerator generator) { 032 this.generator = generator; 033 } 034 035 @Override 036 protected Class<? extends IBoundModule> handleUnboundModule(IModule module) { 037 return generator.generate(module); 038 } 039}