Skip to content

Instantly share code, notes, and snippets.

@thomasmartin-whoz
Last active November 24, 2021 08:09
Show Gist options
  • Save thomasmartin-whoz/0751fc527be9355fb09a644bb29a1dcb to your computer and use it in GitHub Desktop.
Save thomasmartin-whoz/0751fc527be9355fb09a644bb29a1dcb to your computer and use it in GitHub Desktop.
/**
* A Micronaut adapter for Spring application listeners.
* Grails now uses micronaut so application events will be listened to here.
* To avoid rewriting event listening configuration, based on spring, this class dispatches events to the spring listeners.
*/
@Singleton
class ApplicationEventListenerAdapter implements ApplicationEventListener<WhozEvent> {
@Inject
MicronautApplicationContext applicationContext
@Override
void onApplicationEvent(WhozEvent event) {
if (event instanceof ProfileEvent) {
applicationContext.getBean(ProfileEventListener).onApplicationEvent(event)
}
if (event instanceof SkillEvent) {
applicationContext.getBean(SkillEventListener).onApplicationEvent(event)
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment