Work In Progress.
In This Section
Overview
To reduce boilerplate code, the AepEngine and XVM provide a basic set of annotations. EventHandler annotations are the primary means by which an AepEngine communicates events to an application. XVM annotations allow the XVM to inject the objects it creates into the application, and for the application to expose hooks for monitoring and lifecycle-related operations that the XVM manages.
AEP Annotations
EventHandler
The EventHandler annotation is used to annotate a method that serves as an AEPEngine event handler.
Developers should annotate methods that serve as AEP event handlers with this annotation. Upon creation, the AEP engine searches the event handler container objects supplied to the engine constructor or to an XVM via the AppEventHandlerAccessor annotation for methods that are annotated with this annotation. If the annotated method accepts an SMA message as its (only) argument, it is treated as a message handler; i.e. inbound messages are dispatched to the annotated method. Otherwise, if the method accepts an event object as its (only) argument, then the method is treated as the handler for the same event type as the method argument. All other methods annotated with this annotated are flagged as erroneous annotations and ignored.
Message Handlers
The most common usage of the EventHandler annotation is to mark a method as a handler for a Message.
State Replication applications can also annotate a method that accepts the application state as its second argument.
Work done in a message event handler is transactional and atomic: changes to state, delivery of outbound messages, and acknowledgement of the received message are an atomic unit of work.
Lifecycle Event
The AepEngine will also communicate events about the engine lifecycle to the application if it has annotated event handlers for the event type. Lifecycle events all implement the com.neeve.event.lifecycle.ILifecycleEvent. The engine will forward such events to the application with the exception of the events which occur before the application has registered event handlers.
Applications should not modify state or send outbound messages as a result of handling a lifecycle event because they are dispatched outside of a transactional context.
See Talon Application Lifecycle for more details on the application lifecycle and events emitted.
Alert Event Handlers
The AepEngine also communicates alerts to the application if it has annotated event handlers for the event type. Alert events all implement the com.neeve.event.alert.IAlertEvent. The engine will forward such events to the application with the exception of those which occur before the application has registered event handlers.
Applications should not modify state or send outbound messages as a result of handling a lifecycle event because they are dispatched outside of a transactional context.
XVM Annotations
The Talon XVM manages the creation and lifecycle of the Talon Applications that it contains. For each application it loads, it discovers event handlers and injects AEP objects of interest into the loaded application. This process is described in detail in the Talon Application Lifecycle's Load Phase.