@Test void createListenerShouldThrowWhenClassCantBeCastToMailboxListener() { ListenerConfiguration configuration = ListenerConfiguration.forClass("java.lang.String"); assertThatThrownBy(() -> testee.createListener(configuration)) .isInstanceOf(RuntimeException.class); }
@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); } }
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); } } }
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); }
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); @Override void configure(HierarchicalConfiguration<ImmutableNode> configuration); void configure(ListenersConfiguration listenersConfiguration); @Override void register(Pair<Group, MailboxListener.ReactiveMailboxListener> listener); @Override Pair<Group, MailboxListener.ReactiveMailboxListener> createListener(ListenerConfiguration configuration); }
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); @Override void configure(HierarchicalConfiguration<ImmutableNode> configuration); void configure(ListenersConfiguration listenersConfiguration); @Override void register(Pair<Group, MailboxListener.ReactiveMailboxListener> listener); @Override Pair<Group, MailboxListener.ReactiveMailboxListener> createListener(ListenerConfiguration configuration);  }