November 2018
Intermediate to advanced
388 pages
9h 5m
English
Now, the application has to specify a component that listens to this event and executes some further logic. We need to define an event listener. We can do this as part of a new managed bean, such as PersonCreationEventListener. This managed bean will define an observer function. An observer function comes with the signature void. It is important to specify a parameter, which is actually the event that we fire. The event is annotated with the @Observes annotation. We then execute some logic on the event parameter of the event listener, as follows:
class PersonCreationEventListener { fun onPersonCreation(@Observes event: PersonCreationEvent) { println("new person created with id " + event.identifier) }}
Read now
Unlock full access