org.scijava.event
Annotation Type EventHandler


@Retention(value=RUNTIME)
@Target(value=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 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.bushe.swing.event.* 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).

Author:
Curtis Rueden
See Also:
EventService

Optional Element Summary
 String key
          Unique subscription key.
 

key

public abstract String key
Unique subscription key. If multiple @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.

Default:
""


Copyright © 2009–2015 SciJava. All rights reserved.