Annotation Type EventHandler
-
@Retention(RUNTIME) @Target(METHOD) public @interface EventHandler
Annotation identifying an event handler method. This annotation allows a class to subscribe to multiple types of events by implementing multiple event handling methods and annotating each with @EventHandler.Note to developers: This annotation serves exactly the same purpose as EventBus's
org.scijava.event.bushe.EventSubscriberannotation, 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 toimport org.scijava.event.bushe.*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 withEventSubscriber).- Author:
- Curtis Rueden
- See Also:
EventService
-
-
Element Detail
-
key
String key
Unique subscription key. If multiple@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.
- Default:
- ""
-
-