Interface NotificationHandler

All Known Implementing Classes:
DefaultNotificationHandler

public interface NotificationHandler
A NotificationHandler can be registered with the NotificationService to validate, prepare, and send a Notification. The NotificationService will attempt to find a NotificationHandler based on priority. If multiple handlers have the same priority, it is expected that they would have mutually exclusive canHandle() results.
  • Method Details

    • sendMessage

      void sendMessage(Notification notification, NotificationResponse response, com.broadleafcommerce.data.tracking.core.context.ContextInfo context)
      Return true if this NotificationHandler can handle the passed in request.
    • canHandleType

      boolean canHandleType(String deliveryType)
      A NotificationHandler responds to a specific deliveryType.
    • canHandle

      boolean canHandle(Notification notification, com.broadleafcommerce.data.tracking.core.context.ContextInfo context)
      Return true if this NotificationHandler can handle the passed in request.
      Returns:
    • isDefault

      default boolean isDefault()
      Whether this is the default handler of notifications. This is used as a fallback if the desired delivery type is not supported by any handler.
      Returns:
      Whether this is the default handler of notifications. This is used as a fallback if the desired delivery type is not supported by any handler.
    • populateNotification

      void populateNotification(Notification notification, NotificationResponse response, com.broadleafcommerce.data.tracking.core.context.ContextInfo context)
      Populates the passed in notification object
    • isEnabled

      boolean isEnabled()
      The NotificationService will ignore handlers that are disabled.
      Returns:
    • setEnabled

      void setEnabled(boolean enabled)
      Turn on/off this notification handler
    • getPriority

      Integer getPriority()
      The NotificationService will execute the first handler matching handler based on priority.
      Returns:
    • setPriority

      @NonNull void setPriority(Integer priority)
      Set the priority of this NotificationHandler. The NotificationService will order Handlers by priority. By default all Handlers are 0. Order is not deterministic if multiple handlers have the same priority, then they should have mutually exclusive canHandle() results.
    • getDeliveryType

      String getDeliveryType()
      The NotificationService will execute the first handler matching handler based on priority.
      Returns:
    • setDeliveryType

      void setDeliveryType(@NonNull String deliveryType)
      Return the deliveryType of this NotificationHandler. Typically ("EMAIL" or "SMS"). Matches the deliveryType of the handler with the corresponding deliveryType of the Notification.