- Preconditions.checkArgument(maxQueueCapacity > 0, "Invalid maxQueueCapacity %s must be > 0", maxQueueCapacity);
- this.executor = Preconditions.checkNotNull(executor);
- this.listenerInvoker = Preconditions.checkNotNull(listenerInvoker);
- this.maxQueueCapacity = maxQueueCapacity;
- this.name = Preconditions.checkNotNull(name);
+ this(executor, (BatchedInvoker<L, N>)(l, c) -> c.forEach(n -> listenerInvoker.invokeListener(l, n)),
+ maxQueueCapacity, name);
+ Preconditions.checkNotNull(listenerInvoker);
+ }
+
+ /**
+ * Create a new notification manager.
+ *
+ * @param executor the {@link Executor} to use for notification tasks
+ * @param listenerInvoker the {@link BatchedInvoker} to use for invoking listeners
+ * @param maxQueueCapacity the capacity of each listener queue
+ * @param name the name of this instance for logging info
+ */
+ public static <L, N> QueuedNotificationManager<L, N> create(final Executor executor,
+ final BatchedInvoker<L, N> listenerInvoker, final int maxQueueCapacity, final String name) {
+ return new QueuedNotificationManager<>(executor, listenerInvoker, maxQueueCapacity, name);