Interface EventListener
-
public interface EventListener
Event listeners areEvent
consumers. E.g. a listener can send email with notification or dump the event to an auditing database.- Author:
- K. Benedyczak
-
-
Field Summary
Fields Modifier and Type Field Description static int
DEFAULT_MAX_FAILURES
-
Method Summary
All Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description java.lang.String
getId()
int
getMaxFailures()
boolean
handleEvent(pl.edu.icm.unity.types.Event event)
Called only on events of a proper category, for which isWanted returned true.default void
init()
Called beforeEventListener
is being added toEventProcessor
boolean
isAsync(pl.edu.icm.unity.types.Event event)
This method should return whether async processing is allowed.boolean
isLightweight()
boolean
isWanted(pl.edu.icm.unity.types.Event event)
This method should perform a fast filtering of uninteresting events.
-
-
-
Field Detail
-
DEFAULT_MAX_FAILURES
static final int DEFAULT_MAX_FAILURES
- See Also:
- Constant Field Values
-
-
Method Detail
-
isLightweight
boolean isLightweight()
- Returns:
- if true is returned then the listener's handle method will be invoked without persisting the event into database first. Therefore it is assumed that handler is going to perform an operation which nearly always succeeds. Otherwise the event is stored in DB first and if the handle method fails or throws an exception then the handling will be repeated after some time.
-
isWanted
boolean isWanted(pl.edu.icm.unity.types.Event event)
This method should perform a fast filtering of uninteresting events.- Returns:
- true if the event should be handled by this listener
-
isAsync
boolean isAsync(pl.edu.icm.unity.types.Event event)
This method should return whether async processing is allowed. Otherwise processing is done immediately.- Returns:
- true if the event should be handled in async mode.
-
handleEvent
boolean handleEvent(pl.edu.icm.unity.types.Event event)
Called only on events of a proper category, for which isWanted returned true.- Parameters:
event
-- Returns:
- true if the event was processed successfully. Returning false is relevant only for the heavy-weight listeners.
-
getId
java.lang.String getId()
- Returns:
- system unique and constant ID of the listener instance. It is suggested to form it from the full class name concatenated with listener name if it can have many instances.
-
getMaxFailures
int getMaxFailures()
- Returns:
- after how many failures the system should give up sending the event. It is suggested
to return
DEFAULT_MAX_FAILURES
-
init
default void init()
Called beforeEventListener
is being added toEventProcessor
-
-