Interface NodeFactory<T>

Type Parameters:
T -
All Known Implementing Classes:
ClockFactory

public interface NodeFactory<T>
A factory for creating instances. The SEP will call this method to create nodes.

Instance re-use

To ensure that node instances are re-used there are two approaches:
  • The factory caches the node, and returns the same instance for the same configuration.
  • The factory creates new nodes and the node overrides hashcode and equals. The NodeRegistry will consult a map for an equivalent node. If an equivalent node is found then the newly created node will be discarded and the existing instance used.

Registering factories

Fluxtion employs the ServiceLoader pattern to register user implemented NodeFactories. Please read the java documentation describing the meta-data a factory implementor must provide to register a factory using the ServiceLoader pattern.
Author:
Greg Higgins
  • Method Summary

    Modifier and Type Method Description
    T createNode​(java.util.Map config, NodeRegistry registry)
    NodeFactory writer must implement this method to generate instances of nodes.
    default void postInstanceRegistration​(java.util.Map config, NodeRegistry registry, T instance)
    Callback invoked by Fluxtion generator after the generated SEP has been registered in theGenerationContext
    default void preSepGeneration​(GenerationContext context)
    If the node generates a class for this SEP, this callback gives the node access to the GenerationContext before generation.
    default void setTargetLanguage​(java.lang.String targetLanguage)
    If the node generates a class for this SEP, this callback will indicate the desired target.
  • Method Details

    • createNode

      T createNode​(java.util.Map config, NodeRegistry registry)
      NodeFactory writer must implement this method to generate instances of nodes. The Fluxtion compiler will call this method when an Inject instance is created. Config variables are used to populate the config map.
      Parameters:
      config - map configuration
      registry - The node registry of the current generation context
      Returns:
      The newly created node instance
    • postInstanceRegistration

      default void postInstanceRegistration​(java.util.Map config, NodeRegistry registry, T instance)
      Callback invoked by Fluxtion generator after the generated SEP has been registered in theGenerationContext
      Parameters:
      config - map configuration
      registry - The node registry of the current generation context
      instance - the newly created instance
    • setTargetLanguage

      default void setTargetLanguage​(java.lang.String targetLanguage)
      If the node generates a class for this SEP, this callback will indicate the desired target.
      Parameters:
      targetLanguage - target language for generation
    • preSepGeneration

      default void preSepGeneration​(GenerationContext context)
      If the node generates a class for this SEP, this callback gives the node access to the GenerationContext before generation.
      Parameters:
      context - The context the Fluxtion SEC compiler uses