Class DefaultNotificationHandler

java.lang.Object
com.broadleafcommerce.notification.service.DefaultNotificationHandler
All Implemented Interfaces:
NotificationHandler

public class DefaultNotificationHandler extends Object implements NotificationHandler
NotificationHandler with the most common default settings. - deliveryType : EMAIL - priority : Integer.MAX_VALUE - enabled : true - canHandleType method implemented based on the deliveryType
  • Constructor Details

    • DefaultNotificationHandler

      public DefaultNotificationHandler(MessageBuilder builder, MessageSender sender)
    • DefaultNotificationHandler

      public DefaultNotificationHandler()
  • Method Details

    • sendMessage

      public void sendMessage(Notification notification, NotificationResponse response, com.broadleafcommerce.data.tracking.core.context.ContextInfo context)
      Description copied from interface: NotificationHandler
      Return true if this NotificationHandler can handle the passed in request.
      Specified by:
      sendMessage in interface NotificationHandler
    • canHandleType

      public boolean canHandleType(String deliveryType)
      Description copied from interface: NotificationHandler
      A NotificationHandler responds to a specific deliveryType.
      Specified by:
      canHandleType in interface NotificationHandler
    • canHandle

      public boolean canHandle(Notification notification, com.broadleafcommerce.data.tracking.core.context.ContextInfo context)
      Description copied from interface: NotificationHandler
      Return true if this NotificationHandler can handle the passed in request.
      Specified by:
      canHandle in interface NotificationHandler
      Returns:
    • populateNotification

      public void populateNotification(Notification notification, NotificationResponse response, com.broadleafcommerce.data.tracking.core.context.ContextInfo context)
      The default implementation checks the notification to determine if it has a messageBody. If not, it calls the messageBuilder and sets the messageBody to the result. By design, a client can send in a Notification with a body that is ready to send. Other times, a MessageBuilder like the ThymeleafMessageBuilder can be invoked to construct a templated message from the passed in Notification data, context, and request.
      Specified by:
      populateNotification in interface NotificationHandler
      Parameters:
      notification -
      response -
      context -
    • addSentByToResponse

      protected void addSentByToResponse(NotificationResponse response, Class clazz)
    • isEnabled

      public boolean isEnabled()
      Description copied from interface: NotificationHandler
      The NotificationService will ignore handlers that are disabled.
      Specified by:
      isEnabled in interface NotificationHandler
      Returns:
    • setEnabled

      public void setEnabled(boolean enabled)
      Description copied from interface: NotificationHandler
      Turn on/off this notification handler
      Specified by:
      setEnabled in interface NotificationHandler
    • isDefault

      public boolean isDefault()
      Description copied from interface: NotificationHandler
      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.
      Specified by:
      isDefault in interface NotificationHandler
      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.
    • setDefault

      public void setDefault(boolean isDefault)
    • getDeliveryType

      public String getDeliveryType()
      Description copied from interface: NotificationHandler
      The NotificationService will execute the first handler matching handler based on priority.
      Specified by:
      getDeliveryType in interface NotificationHandler
      Returns:
    • setDeliveryType

      public void setDeliveryType(String deliveryType)
      Description copied from interface: NotificationHandler
      Return the deliveryType of this NotificationHandler. Typically ("EMAIL" or "SMS"). Matches the deliveryType of the handler with the corresponding deliveryType of the Notification.
      Specified by:
      setDeliveryType in interface NotificationHandler
    • getPriority

      public Integer getPriority()
      Description copied from interface: NotificationHandler
      The NotificationService will execute the first handler matching handler based on priority.
      Specified by:
      getPriority in interface NotificationHandler
      Returns:
    • setPriority

      public void setPriority(Integer priority)
      Description copied from interface: NotificationHandler
      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.
      Specified by:
      setPriority in interface NotificationHandler