- ExecutorService executor = Executors.newFixedThreadPool(5);
- ListeningExecutorService listeningExecutor = MoreExecutors.listeningDecorator(executor);
- NotificationBrokerImpl broker = new NotificationBrokerImpl(listeningExecutor);
- return broker;
+
+ final NotificationPublishService notificationPublishService = getNotificationPublishAdapterDependency();
+ final NotificationService notificationService = getNotificationAdapterDependency();
+
+ if(notificationPublishService != null & notificationService != null) {
+ return createHeliumAdapter(notificationPublishService,notificationService);
+ }
+
+ /*
+ * FIXME: Switch to new broker (which has different threading model)
+ * once this change is communicated with downstream users or
+ * we will have adapter implementation which will honor Helium
+ * threading model for notifications.
+ */
+ return new HydrogenNotificationBrokerImpl(SingletonHolder.getDefaultNotificationExecutor());
+ }
+
+ private static AutoCloseable createHeliumAdapter(final NotificationPublishService publishService,
+ final NotificationService listenService) {
+ if(publishService instanceof BindingDOMNotificationPublishServiceAdapter) {
+ final BindingDOMNotificationPublishServiceAdapter casted = (BindingDOMNotificationPublishServiceAdapter) publishService;
+ final DOMNotificationPublishService domService = casted.getDomPublishService();
+ if(domService instanceof DOMNotificationSubscriptionListenerRegistry) {
+ final DOMNotificationSubscriptionListenerRegistry subsRegistry = (DOMNotificationSubscriptionListenerRegistry) domService;
+ return new HeliumNotificationProviderServiceWithInterestListeners(publishService, listenService, casted.getCodecRegistry(), subsRegistry);
+ }
+ }
+ return new HeliumNotificationProviderServiceAdapter(publishService, listenService);