vetoable events

auto-update
Zlatin Balevsky 2022-02-18 11:18:46 +00:00
parent be9229d24b
commit e5f585c413
No known key found for this signature in database
GPG Key ID: A72832072D525E41
2 changed files with 5 additions and 2 deletions

View File

@ -7,6 +7,7 @@ class Event {
private static final AtomicLong SEQ_NO = new AtomicLong();
final long seqNo
final long timestamp
boolean vetoed
Event() {
seqNo = SEQ_NO.getAndIncrement()

View File

@ -31,9 +31,11 @@ class EventBus {
synchronized(this) {
currentHandlers = handlers.getOrDefault(clazz, [])
}
currentHandlers.each {
for(def handler : currentHandlers) {
if (e.vetoed)
break
try {
it."on${clazz.getSimpleName()}"(e)
handler."on${clazz.getSimpleName()}"(e)
} catch (Exception bad) {
log.log(Level.SEVERE, "exception dispatching event",bad)
}