2 Comments

Will it be better to use DI to replace registerHandler?

For example in Spring:

Use `@Component("Name")` to define handlers.

Then use `notificationHandlers = applicationContext.getBeansOfType(NotificationHandler.class)` to get the handler map when constructing the service object.

Finally use notificationHandlers.get(channel.getName()).send() to retrieve the handler object and call send() to send out the notification.

Expand full comment