Multiple handlers per class
Use of multiple @EventHandler annotations to push data into a SEP
Multiple handlers
The goal is to have individual methods in a single class handle separate events.
Multiple event handler methods in a single class are supported if the Events are of different types. Another event handler method is added to the node and annotated before running the generator.
Using an EventHandler interface would only allow one event type per instance, annotations allow a plurality of event handler methods in a class.
Example
In this xxample MyEventProcessor handles MyEvent and ConfigEvent's. Two single argument methods are annotated with @EventHandler, the argument type is the event type to dispatch by the generated SEP.
The example is located here.
Node class
SEPConfig builder
The graph is created using imperative construction in the Builder file. The Builder is loaded by Fluxtion ESC at compile time to generate the SEP.
Generated SEP
Fluxtion ESC will generate the SEP below. The interface method onEvent
implements a pattern based switch using the class name as the pattern. onEvent
delegates to a type specific dispatcher, in the overloaded handleEvent
methods.
The overloaded methods are generated at compile time and are early bound for correct dispatch resolution by the JVM.
Last updated