@Retention(value=RUNTIME) @Target(value=METHOD) public @interface EventHandler
EventHandler
.
Note to developers: This annotation serves exactly the same purpose as
EventBus's org.scijava.event.bushe.EventSubscriber
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 import 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 with
EventSubscriber
).
EventService
public abstract String key
@EventHandler
annotations
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 © 2009–2023 SciJava. All rights reserved.