Package com.fluxtion.builder.node
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
NodeRegistrywill 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 theServiceLoader 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 TcreateNode(java.util.Map config, NodeRegistry registry)NodeFactory writer must implement this method to generate instances of nodes.default voidpostInstanceRegistration(java.util.Map config, NodeRegistry registry, T instance)Callback invoked by Fluxtion generator after the generated SEP has been registered in theGenerationContextdefault voidpreSepGeneration(GenerationContext context)If the node generates a class for this SEP, this callback gives the node access to the GenerationContext before generation.default voidsetTargetLanguage(java.lang.String targetLanguage)If the node generates a class for this SEP, this callback will indicate the desired target.
-
Method Details
-
createNode
NodeFactory writer must implement this method to generate instances of nodes. The Fluxtion compiler will call this method when anInjectinstance is created.Configvariables are used to populate the config map.- Parameters:
config- map configurationregistry- The node registry of the current generation context- Returns:
- The newly created node instance
-
postInstanceRegistration
Callback invoked by Fluxtion generator after the generated SEP has been registered in theGenerationContext- Parameters:
config- map configurationregistry- The node registry of the current generation contextinstance- 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
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
-