Class FeatureOptimizer


  • public class FeatureOptimizer
    extends Object
    The SOAR Optimizer (aka SOAR-O) public API for building Features.
    The SOAR Optimizer allows to build Feature (.fo files) for the very Kernel on which it is executed. Then the .fo file can be dynamically linked using ej.kf.Kernel.install(InputStream). The Kernel metadata content is loaded and cached on demand. The more a Feature adheres to a Kernel (i.e. depends on various Kernel APIs types, methods and fields), the more this instance will allocate and cache Kernel metadata objects in Java heap.
    • Constructor Detail

      • FeatureOptimizer

        public FeatureOptimizer​(KernelMetadataProvider kernelMetadataProvider)
                         throws FeatureOptimizerException
        Creates a new FeatureOptimizer instance with the given Kernel metadata provider.

        It loads the Kernel metadata header and checks whether it corresponds to the Kernel on which this method is actually executed.

        Parameters:
        kernelMetadataProvider - the Kernel metadata provider.
        Throws:
        FeatureOptimizerException - if the Kernel metadata cannot be loaded.
    • Method Detail

      • build

        public void build​(InputStream fsoFile,
                          OutputStream foFile)
                   throws FeatureOptimizerException
        Builds a Feature (.fo file) for this Kernel from a shared Feature (.fso file).

        This methods blocks until the Feature .fo file is fully generated and flushed to the given output stream. An error may be thrown while the output stream is partially written.

        Parameters:
        fsoFile - the input stream for the loaded shared Feature (.fso file).
        foFile - the output stream for the generated Feature (.fo file).
        Throws:
        FeatureOptimizerException - if the Feature cannot be built on this Kernel.
      • getKernelUID

        public byte[] getKernelUID()
        Gets the Kernel UID of the loaded Kernel metadata.
        Returns:
        the Kernel UID of the loaded Kernel metadata.