class MailboxListenersLoaderImpl implements Configurable, MailboxListenersLoader {

    @Override
    public Pair<Group, MailboxListener.ReactiveMailboxListener> createListener(ListenerConfiguration configuration) {
        ClassName listenerClass = new ClassName(configuration.getClazz());
        try {
            LOGGER.info("Loading user registered mailbox listener {}", listenerClass);
            MailboxListener mailboxListener = mailboxListenerFactory.newInstance()
                .withConfiguration(configuration.getConfiguration())
                .withExecutionMode(configuration.isAsync().map(this::getExecutionMode))
                .clazz(listenerClass)
                .build();


            return configuration.getGroup()
                .map(GenericGroup::new)
                .map(group -> Pair.<Group, MailboxListener.ReactiveMailboxListener>of(group, wrapIfNeeded(mailboxListener)))
                .orElseGet(() -> withDefaultGroup(mailboxListener));
        } catch (ClassNotFoundException e) {
            LOGGER.error("Error while loading user registered global listener {}", listenerClass, e);
            throw new RuntimeException(e);
        }
    }

    @Inject  MailboxListenersLoaderImpl(MailboxListenerFactory mailboxListenerFactory, EventBus eventBus,
                               Set<MailboxListener.ReactiveGroupMailboxListener> guiceDefinedListeners,
                               Set<MailboxListener.GroupMailboxListener> nonReactiveGuiceDefinedListeners);

}