Class InprocessSepCompiler

java.lang.Object
com.fluxtion.generator.compiler.InprocessSepCompiler

public class InprocessSepCompiler
extends java.lang.Object
Generates and compiles a SEP for use by a caller in the same process. The compilation is invoked programmatically removing the need to execute the Fluxtion event stream compiler as an external process.

To generate a SEP the caller invokes one of the static compileSep methods. An instance of SEPConfig is passed to the consumer to control the graph construction, such as adding nodes and defining scopes or identifiers. Simple example adding a single node:

sepTestInstance((c) -> c.addNode(new MyHandler(), "handler"), "com.fluxtion.examples.inprocess", "GenNode_1");

Optionally creates an instance of the compiled StaticEventProcessor with or without calling the init method using one of sepInstance(Consumer, String, String, String, String, boolean).

>This is an experimental feature that needs to tested carefully. The class loading for SEP generation was originally designed to be out of process so there may be issues.

Author:
V12 Technology Ltd.
  • Nested Class Summary

    Nested Classes 
    Modifier and Type Class Description
    static class  InprocessSepCompiler.InitOptions  
  • Constructor Summary

    Constructors 
    Constructor Description
    InprocessSepCompiler()  
  • Method Summary

    Modifier and Type Method Description
    static com.fluxtion.api.StaticEventProcessor build​(java.lang.String name, java.lang.String pkg, java.util.function.Consumer<com.fluxtion.builder.node.SEPConfig> builder)
    Build a static event processor using the supplied consumer to populate the SEPConfig.
    static java.lang.Class<com.fluxtion.api.StaticEventProcessor> compileSep​(java.util.function.Consumer<com.fluxtion.builder.node.SEPConfig> cfgBuilder, java.lang.String pckg, java.lang.String sepName)  
    static java.lang.Class<com.fluxtion.api.StaticEventProcessor> CompileTestSep​(java.util.function.Consumer<com.fluxtion.builder.node.SEPConfig> cfgBuilder, java.lang.String pckg, java.lang.String sepName)  
    static SepCompilerConfig getSepCompileConfig​(java.lang.String packageName, java.lang.String className, java.lang.String srcGenDir, java.lang.String resGenDir)  
    static com.fluxtion.api.StaticEventProcessor reuseOrBuild​(com.fluxtion.api.partition.LambdaReflection.SerializableConsumer<com.fluxtion.builder.node.SEPConfig> builder)  
    static com.fluxtion.api.StaticEventProcessor reuseOrBuild​(java.lang.String name, java.lang.String pkg, java.util.function.Consumer<com.fluxtion.builder.node.SEPConfig> builder)
    Returns an instance of a static event processor to the caller.
    static com.fluxtion.api.StaticEventProcessor sepInstance​(java.util.function.Consumer<com.fluxtion.builder.node.SEPConfig> cfgBuilder, java.lang.String pckg, java.lang.String sepName)  
    static com.fluxtion.api.StaticEventProcessor sepInstance​(java.util.function.Consumer<com.fluxtion.builder.node.SEPConfig> cfgBuilder, java.lang.String pckg, java.lang.String sepName, DirOptions dirOptions, InprocessSepCompiler.InitOptions initOptions)  
    static com.fluxtion.api.StaticEventProcessor sepInstance​(java.util.function.Consumer<com.fluxtion.builder.node.SEPConfig> cfgBuilder, java.lang.String pckg, java.lang.String sepName, java.lang.String srcGenDir, java.lang.String resGenDir, boolean initialise)
    Compiles and instantiates a SEP described with the provided SEPConfig, optionally initialising the SEP instance.
    static com.fluxtion.api.StaticEventProcessor sepInstanceNoInit​(java.util.function.Consumer<com.fluxtion.builder.node.SEPConfig> cfgBuilder, java.lang.String pckg, java.lang.String sepName)  
    static com.fluxtion.api.StaticEventProcessor sepTestInstance​(java.util.function.Consumer<com.fluxtion.builder.node.SEPConfig> cfgBuilder, java.lang.String pckg, java.lang.String sepName)  
    static com.fluxtion.api.StaticEventProcessor sepTestInstanceNoInit​(java.util.function.Consumer<com.fluxtion.builder.node.SEPConfig> cfgBuilder, java.lang.String pckg, java.lang.String sepName)  

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

  • Method Details

    • sepInstance

      public static com.fluxtion.api.StaticEventProcessor sepInstance​(java.util.function.Consumer<com.fluxtion.builder.node.SEPConfig> cfgBuilder, java.lang.String pckg, java.lang.String sepName, DirOptions dirOptions, InprocessSepCompiler.InitOptions initOptions) throws java.lang.InstantiationException, java.lang.IllegalAccessException, java.lang.Exception
      Throws:
      java.lang.InstantiationException
      java.lang.IllegalAccessException
      java.lang.Exception
    • sepInstance

      public static com.fluxtion.api.StaticEventProcessor sepInstance​(java.util.function.Consumer<com.fluxtion.builder.node.SEPConfig> cfgBuilder, java.lang.String pckg, java.lang.String sepName) throws java.lang.InstantiationException, java.lang.IllegalAccessException, java.lang.Exception
      Throws:
      java.lang.InstantiationException
      java.lang.IllegalAccessException
      java.lang.Exception
    • sepTestInstance

      public static com.fluxtion.api.StaticEventProcessor sepTestInstance​(java.util.function.Consumer<com.fluxtion.builder.node.SEPConfig> cfgBuilder, java.lang.String pckg, java.lang.String sepName) throws java.lang.InstantiationException, java.lang.IllegalAccessException, java.lang.Exception
      Throws:
      java.lang.InstantiationException
      java.lang.IllegalAccessException
      java.lang.Exception
    • sepInstanceNoInit

      public static com.fluxtion.api.StaticEventProcessor sepInstanceNoInit​(java.util.function.Consumer<com.fluxtion.builder.node.SEPConfig> cfgBuilder, java.lang.String pckg, java.lang.String sepName) throws java.lang.InstantiationException, java.lang.IllegalAccessException, java.lang.Exception
      Throws:
      java.lang.InstantiationException
      java.lang.IllegalAccessException
      java.lang.Exception
    • sepTestInstanceNoInit

      public static com.fluxtion.api.StaticEventProcessor sepTestInstanceNoInit​(java.util.function.Consumer<com.fluxtion.builder.node.SEPConfig> cfgBuilder, java.lang.String pckg, java.lang.String sepName) throws java.lang.InstantiationException, java.lang.IllegalAccessException, java.lang.Exception
      Throws:
      java.lang.InstantiationException
      java.lang.IllegalAccessException
      java.lang.Exception
    • build

      public static com.fluxtion.api.StaticEventProcessor build​(java.lang.String name, java.lang.String pkg, java.util.function.Consumer<com.fluxtion.builder.node.SEPConfig> builder) throws java.lang.Exception
      Build a static event processor using the supplied consumer to populate the SEPConfig. Will always build a new processor, supplying a newly created instance of the class to the caller.

      Set the system property fluxtion.cacheDirectory and fluxtion will create the following sub-directories:

      • classes - the compiled classes
      • source - generated source files the classes are compiled from
      • resources - any other resources generated by fluxtion, suchas meta-data
      Parameters:
      name - The name of the generated static event processor
      pkg - The package name of the generated static event processor
      builder - The Consumer that populates the SEPConfig
      Returns:
      An instance of the newly generated static event processor
      Throws:
      java.lang.Exception
    • reuseOrBuild

      public static com.fluxtion.api.StaticEventProcessor reuseOrBuild​(java.lang.String name, java.lang.String pkg, java.util.function.Consumer<com.fluxtion.builder.node.SEPConfig> builder) throws java.lang.Exception
      Returns an instance of a static event processor to the caller. Will only build a new processor if a class cannot be found on the classpath that matches the fqn name of the processor. Will generate a static event processor using the supplied consumer to populate the SEPConfig if an existing class cannot be found.

      Set the system property fluxtion.cacheDirectory and fluxtion will create the following sub-directories:

      • classes - the compiled classes
      • source - generated source files the classes are compiled from
      • resources - any other resources generated by fluxtion, suchas meta-data
      Parameters:
      name - The name of the generated static event processor
      pkg - The package name of the generated static event processor
      builder - The Consumer that populates the SEPConfig
      Returns:
      An instance of the newly generated static event processor
      Throws:
      java.lang.Exception
    • reuseOrBuild

      public static com.fluxtion.api.StaticEventProcessor reuseOrBuild​(com.fluxtion.api.partition.LambdaReflection.SerializableConsumer<com.fluxtion.builder.node.SEPConfig> builder) throws java.lang.Exception
      Throws:
      java.lang.Exception
    • sepInstance

      public static com.fluxtion.api.StaticEventProcessor sepInstance​(java.util.function.Consumer<com.fluxtion.builder.node.SEPConfig> cfgBuilder, java.lang.String pckg, java.lang.String sepName, java.lang.String srcGenDir, java.lang.String resGenDir, boolean initialise) throws java.lang.InstantiationException, java.lang.IllegalAccessException, java.lang.Exception
      Compiles and instantiates a SEP described with the provided SEPConfig, optionally initialising the SEP instance. See compileSep(Consumer, String, String, String, String) for a description of compilation.
      Parameters:
      cfgBuilder - - A client consumer to buld sep using the provided
      pckg - - output package of the generated class
      sepName - - output class name of the generated SEP
      srcGenDir - - output directory for generated SEP source files
      resGenDir - - output directory for generated resources
      initialise - - if true call init method on SEP instance
      Returns:
      Throws:
      java.lang.InstantiationException
      java.lang.IllegalAccessException
      java.lang.Exception
    • compileSep

      public static java.lang.Class<com.fluxtion.api.StaticEventProcessor> compileSep​(java.util.function.Consumer<com.fluxtion.builder.node.SEPConfig> cfgBuilder, java.lang.String pckg, java.lang.String sepName) throws java.io.IOException, java.lang.InstantiationException, java.lang.IllegalAccessException, java.lang.Exception
      Throws:
      java.io.IOException
      java.lang.InstantiationException
      java.lang.IllegalAccessException
      java.lang.Exception
    • CompileTestSep

      public static java.lang.Class<com.fluxtion.api.StaticEventProcessor> CompileTestSep​(java.util.function.Consumer<com.fluxtion.builder.node.SEPConfig> cfgBuilder, java.lang.String pckg, java.lang.String sepName) throws java.io.IOException, java.lang.InstantiationException, java.lang.IllegalAccessException, java.lang.Exception
      Throws:
      java.io.IOException
      java.lang.InstantiationException
      java.lang.IllegalAccessException
      java.lang.Exception
    • getSepCompileConfig

      public static SepCompilerConfig getSepCompileConfig​(java.lang.String packageName, java.lang.String className, java.lang.String srcGenDir, java.lang.String resGenDir) throws java.io.IOException
      Throws:
      java.io.IOException