Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
private static final class CDIEventDistributor<T extends HasMetadata> implements Consumer<AbstractEvent<? extends T>> {
private static final Annotation[] EMPTY_ANNOTATION_ARRAY = new Annotation[0];
private final Annotation[] qualifiers;
private final NotificationOptions notificationOptions;
private final boolean syncNeeded;
private final boolean asyncNeeded;
private CDIEventDistributor(final Set<Annotation> qualifiers, final NotificationOptions notificationOptions, final boolean syncNeeded, final boolean asyncNeeded) {
if (qualifiers == null) {
this.qualifiers = EMPTY_ANNOTATION_ARRAY;
} else {
this.qualifiers = qualifiers.toArray(new Annotation[qualifiers.size()]);
this.notificationOptions = notificationOptions;
this.syncNeeded = syncNeeded;
this.asyncNeeded = asyncNeeded;
public final void accept(final AbstractEvent<? extends T> controllerEvent) {
if (controllerEvent != null && (this.syncNeeded || this.asyncNeeded)) {
final BeanManager beanManager = CDI.current().getBeanManager();
assert beanManager != null;
final javax.enterprise.event.Event<Object> cdiEventMachinery = beanManager.getEvent();
assert cdiEventMachinery != null;
final TypeLiteral<AbstractEvent<? extends T>> eventTypeLiteral = new TypeLiteral<AbstractEvent<? extends T>>() {
private static final long serialVersionUID = 1L;
final javax.enterprise.event.Event<AbstractEvent<? extends T>> broadcaster =, this.qualifiers);
assert broadcaster != null;
if (this.asyncNeeded) {
if (this.notificationOptions == null) {
} else {
broadcaster.fireAsync(controllerEvent, this.notificationOptions);
if (this.syncNeeded) {;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.