private CompletableFuture invokeObserverMethodAsync(Object event, EventMetadataImpl metadata, ObserverMethod<? super Object> observer, NotificationOptions notificationOptions) { CompletableFuture<?> future = new CompletableFuture<>(); CompletableFuture.runAsync(() -> { try { runAsync(event, metadata, observer); future.complete(null); } catch (WebBeansException wbe) { future.completeExceptionally(wbe.getCause()); } }, notificationOptions.getExecutor() == null ? defaultNotificationOptions.getExecutor() : notificationOptions.getExecutor()); return future; }
/** * Delivers the given asynchronous event object to given observer asynchronous observer methods. * * Asynchronous observer methods are scheduled to be notified in a separate thread. Note that this method exits just after event delivery to asynchronous * observer methods is scheduled. {@link EventMetadata} is made available for injection into observer methods, if needed. * * Note that if any of the observer methods throws an exception, it is never thrown out of this method. Instead, all the exceptions are grouped together * using {@link CompletionException} and the returned {@link CompletionStage} fails with this compound exception. * * If an executor is provided then observer methods are notified using this executor. Otherwise, Weld's task executor is used. * * @param observers the given observer methods * @param event the given event object * @param metadata event metadata * @param options */ public <T, U extends T> CompletionStage<U> notifyAsync(ResolvedObservers<T> observers, U event, EventMetadata metadata, NotificationOptions options) { if (!observers.isMetadataRequired()) { metadata = null; } return notifyAsyncObservers(observers.getAsyncObservers(), event, metadata, options.getExecutor(), options); }
/** * Delivers the given asynchronous event object to given observer asynchronous observer methods. * * Asynchronous observer methods are scheduled to be notified in a separate thread. Note that this method exits just after event delivery to asynchronous * observer methods is scheduled. {@link EventMetadata} is made available for injection into observer methods, if needed. * * Note that if any of the observer methods throws an exception, it is never thrown out of this method. Instead, all the exceptions are grouped together * using {@link CompletionException} and the returned {@link CompletionStage} fails with this compound exception. * * If an executor is provided then observer methods are notified using this executor. Otherwise, Weld's task executor is used. * * @param observers the given observer methods * @param event the given event object * @param metadata event metadata * @param options */ public <T, U extends T> CompletionStage<U> notifyAsync(ResolvedObservers<T> observers, U event, EventMetadata metadata, NotificationOptions options) { if (!observers.isMetadataRequired()) { metadata = null; } return notifyAsyncObservers(observers.getAsyncObservers(), event, metadata, options.getExecutor(), options); }
/** * Delivers the given asynchronous event object to given observer asynchronous observer methods. * * Asynchronous observer methods are scheduled to be notified in a separate thread. Note that this method exits just after event delivery to asynchronous * observer methods is scheduled. {@link EventMetadata} is made available for injection into observer methods, if needed. * * Note that if any of the observer methods throws an exception, it is never thrown out of this method. Instead, all the exceptions are grouped together * using {@link CompletionException} and the returned {@link CompletionStage} fails with this compound exception. * * If an executor is provided then observer methods are notified using this executor. Otherwise, Weld's task executor is used. * * @param observers the given observer methods * @param event the given event object * @param metadata event metadata * @param options */ public <T, U extends T> CompletionStage<U> notifyAsync(ResolvedObservers<T> observers, U event, EventMetadata metadata, NotificationOptions options) { if (!observers.isMetadataRequired()) { metadata = null; } return notifyAsyncObservers(observers.getAsyncObservers(), event, metadata, options.getExecutor(), options); }
/** * Delivers the given asynchronous event object to given observer asynchronous observer methods. * * Asynchronous observer methods are scheduled to be notified in a separate thread. Note that this method exits just after event delivery to asynchronous * observer methods is scheduled. {@link EventMetadata} is made available for injection into observer methods, if needed. * * Note that if any of the observer methods throws an exception, it is never thrown out of this method. Instead, all the exceptions are grouped together * using {@link CompletionException} and the returned {@link CompletionStage} fails with this compound exception. * * If an executor is provided then observer methods are notified using this executor. Otherwise, Weld's task executor is used. * * @param observers the given observer methods * @param event the given event object * @param metadata event metadata * @param options */ public <T, U extends T> CompletionStage<U> notifyAsync(ResolvedObservers<T> observers, U event, EventMetadata metadata, NotificationOptions options) { if (!observers.isMetadataRequired()) { metadata = null; } return notifyAsyncObservers(observers.getAsyncObservers(), event, metadata, options.getExecutor(), options); }
/** * Delivers the given asynchronous event object to given observer asynchronous observer methods. * * Asynchronous observer methods are scheduled to be notified in a separate thread. Note that this method exits just after event delivery to asynchronous * observer methods is scheduled. {@link EventMetadata} is made available for injection into observer methods, if needed. * * Note that if any of the observer methods throws an exception, it is never thrown out of this method. Instead, all the exceptions are grouped together * using {@link CompletionException} and the returned {@link CompletionStage} fails with this compound exception. * * If an executor is provided then observer methods are notified using this executor. Otherwise, Weld's task executor is used. * * @param observers the given observer methods * @param event the given event object * @param metadata event metadata * @param options */ public <T, U extends T> CompletionStage<U> notifyAsync(ResolvedObservers<T> observers, U event, EventMetadata metadata, NotificationOptions options) { if (!observers.isMetadataRequired()) { metadata = null; } return notifyAsyncObservers(observers.getAsyncObservers(), event, metadata, options.getExecutor(), options); }
.getExecutor().execute(() -> {});