Note to developers: This annotation serves exactly the same purpose as
annotation, recapitulating a subset of the same functionality. We do this to
avoid third party code depending directly on EventBus. That is, we do not
wish to require SciJava developers to
or similar. In this way, EventBus is isolated as only a transitive dependency
of downstream code, rather than a direct dependency. Unfortunately, because
Java annotation interfaces cannot utilize inheritance, we have to
recapitulate the functionality rather than extend it (as we are able to do
public abstract String key
@EventHandlerannotations exist with the same key, only the first to be subscribed will be respected; the others will be silently ignored. If no key is specified, the event handler is always subscribed.
This feature exists to enable better extensibility of event handling: if code exists that handles an event in an undesirable way, that logic can be completely intercepted and overridden by writing more code that handles the event in a better way, specifying the same key as the original.
Copyright © 2015–2017 SciJava. All rights reserved.