Package io.preboot.eventbus
Annotation Interface EventHandler
Marks a method within a bean as an event handler. Methods annotated with
@EventHandler will be registered to
receive events that match the type of their first parameter. The event dispatching mechanism will look for public
methods with this annotation and a single parameter (the event object).-
Optional Element Summary
Optional ElementsModifier and TypeOptional ElementDescriptionintDefines the priority of the event handler.Class<?> Optional type parameter filter for generic events.
-
Element Details
-
priority
int priorityDefines the priority of the event handler. Handlers with higher priority values (e.g., 100) are generally executed before handlers with lower priority values (e.g., 1). The default priority is 0. The exact behavior of priority-based ordering can depend on the event bus implementation.- Returns:
- the priority of the event handler.
- Default:
0
-
typeParameter
Class<?> typeParameterOptional type parameter filter for generic events. When set, the handler will only receive events where the generic type parameter of the event (if the event is aGenericEventor similar construct) matches this specified class. For example, for events like Event<String> or Event<Integer>, this setting allows the handler to specify it's only interested inString.classas the generic type.If the event is not generic or if this is set to
void.class(the default), this filter is not applied based on the generic type parameter.- Returns:
- the class of the generic type parameter to filter on, or
void.classif no specific filtering by the generic type is needed.
- Default:
void.class
-