JARModel Builder
Using the supplied JAR file, this class creates an instance of an object that implements the ModelBuilderIfc interface. The resulting instance can be used to build models as defined by the JAR file classes.
It is much more efficient to supply a class name found within the JAR file that implements the ModelBuilderIfc. If not supplied, the JAR will be searched for the first class that implements the ModelBuilderIfc interface. If no classes are found that implement the interface, then an exception occurs.
The simplest approach is to include a Kotlin object reference declaration that implements the ModelBuilderIfc interface in the compiled code within the JAR file. Then, you supply the name of the object/class as the modelBuilderClassName parameter. If you don't supply an object reference declaration, then there must be one class within the JAR file that implements the ModelBuilderIfc interface, and it must have a public zero argument constructor.
If the required KSLCore release's jar file is on the classpath for the implementation that uses the JARModelBuilder, then the jar file does not need to be a "fat" jar. As long as the jar file has all the necessary user-defined class definitions needed to construct an instance of the desired model, then the necessary KSL classes will be loaded via the class loader's parent through delegation. The parent loader will be the loader required to instantiate this class.
The JARModelBuilder should not be closed until all required models are built. Once the builder is closed, no additional models can be built. It is important to close the builder once all models have been built.
Because of the underlying JAR files and class loading, it is important to not store long-lasting references to the models built from the builder. This could have important memory issues because of how java class loading operates. See this article. for more information.
Parameters
the path to the JAR file. The file must be a JAR file and contain a class that implements the ModelBuilderIfc interface.
the (optional) name of the class within the JAR file that implements the ModelBuilderIfc
Properties
Functions
The returned model will have been instantiated by the underlying class loader. Be sure not to store long-lasting references to the model instances because this may have memory implications that prevent garbage collection of the loader and any classes that it loaded.
Initializes the builder so that model building can occur. This function must be called before the first time build() is called.