I've analyzed HandlerManager and I do not see how it handles event source. Line 117:
public void fireEvent(GwtEvent<?> event) {
...
Object oldSource = event.getSource();
event.overrideSource(source);
try {
// May throw an UmbrellaException.
eventBus.fireEvent(event); // <--- LOOK HERE
} catch (com.google.web.bindery.event.shared.UmbrellaException e) {
throw new UmbrellaException(e.getCauses());
} finally {
....
}
}
But simple event bus implementation has following code, line 86:
@Override
public void fireEvent(Event<?> event) {
doFire(event, null); // <---- SOURCE IS NULL???
}
@Override
public void fireEventFromSource(Event<?> event, Object source) {
if (source == null) {
throw new NullPointerException("Cannot fire from a null source");
}
doFire(event, source);
}
So, HandlerManager does not fire events with source, because it always calls doFire(event, null);
Could you make it clear how does HandlerManager fire event for source? As HandlerManager used in Widget, how does it fire events for Widget instance only?
doFire
in SimpleEventBus
only changes the event's source if the source
argument is not null
.
HandlerManager
first sets the event's source with overrideSource
and then call doFire
with an implicit null
source so it won't overwrite it.
QED.