add logging to event bus

pull/4/head
Zlatin Balevsky 2018-07-22 22:58:56 +01:00
parent 5407aa8616
commit f2f09a359d
1 changed files with 4 additions and 0 deletions

View File

@ -4,11 +4,14 @@ import java.util.concurrent.CopyOnWriteArrayList
import com.muwire.core.files.FileSharedEvent
import groovy.util.logging.Log
@Log
class EventBus {
private Map handlers = new HashMap()
void publish(Event e) {
log.fine "publishing event of type ${e.getClass().getSimpleName()}"
def currentHandlers
final def clazz = e.getClass()
synchronized(handlers) {
@ -20,6 +23,7 @@ class EventBus {
}
synchronized void register(Class<? extends Event> eventType, def handler) {
log.info "Registering $handler for type $eventType"
def currentHandlers = handlers.get(eventType)
if (currentHandlers == null) {
currentHandlers = new CopyOnWriteArrayList()