Event handling
Use of @EventHandler annotation to push data into a SEP
Single event handler per class
The goal is to invoke a method on a user created node when an Event is posted to the encapsulating SEP.
The method must accept a single argument that is of type Event and be marked with @EventHandler annotation. There are no requirements on method naming, only the method signature and annotation are analysed by Fluxtion.
Fluxtion employs pattern type matching analysis to ensure the correct method dispatch occurs.
Example
The example is located here. A single event type MyEvent will be dispateched to an event handler method, MyEventProcessor.handleEvent
Node class
In this example MyEventProcessor handles MyEvent. The method is marked with the annotation @EventHandler
to identify it as an event handler method to the Fluxtion compiler at generation time.
Generated SEP
Fluxtion ESC will generate the following SEP. The interface method onEvent discovers the runtime type (line 11) and dipatches the event to a type specific handleEvent method (line 20). The execution path is invoked in the handleEvent method.
Graph builder
The SEPConfig class that constructs the graph imperatively is shown below. Use of SEPConfig is described in imperative graph building.
Last updated