Interface EventListener


public interface EventListener
Event listeners are Event 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 final int
     
  • Method Summary

    Modifier and Type
    Method
    Description
     
    int
     
    boolean
    Called only on events of a proper category, for which isWanted returned true.
    default void
    Called before EventListener is being added to EventProcessor
    boolean
    isAsync(Event event)
    This method should return whether async processing is allowed.
    boolean
     
    boolean
    isWanted(Event event)
    This method should perform a fast filtering of uninteresting events.
  • Field Details

  • Method Details

    • 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(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(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(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

      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 before EventListener is being added to EventProcessor