November 2018
Intermediate to advanced
388 pages
9h 5m
English
Now we need to fire the event that we created. We can use CDI events for firing the event, which will loosely couple the event and the listener components. In order to do this, we need to inject a type that comes from the CDI—the Event type. This is shown in the following code:
@Statelessclass App { @Inject private lateinit var identityCreator: IdentityCreator @Inject private lateinit var identityRepository: IdentityRepository @Inject private lateinit var event: Event<PersonCreationEvent> fun createIdentity(inputData: InputData): Identity { val person = identityCreator.createPerson(inputData) identityRepository.store(person) event.fire(PersonCreationEvent(person.identifier)) return person }}
The PersonCreationEvent type is ...
Read now
Unlock full access