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 Summary
Modifier and TypeMethodDescriptionboolean
canHandle
(Notification notification, com.broadleafcommerce.data.tracking.core.context.ContextInfo context) Return true if this NotificationHandler can handle the passed in request.boolean
canHandleType
(String deliveryType) A NotificationHandler responds to a specific deliveryType.TheNotificationService
will execute the first handler matching handler based on priority.TheNotificationService
will execute the first handler matching handler based on priority.default boolean
Whether this is the default handler of notifications.boolean
TheNotificationService
will ignore handlers that are disabled.void
populateNotification
(Notification notification, NotificationResponse response, com.broadleafcommerce.data.tracking.core.context.ContextInfo context) Populates the passed in notification objectvoid
sendMessage
(Notification notification, NotificationResponse response, com.broadleafcommerce.data.tracking.core.context.ContextInfo context) Return true if this NotificationHandler can handle the passed in request.void
setDeliveryType
(String deliveryType) Return the deliveryType of this NotificationHandler.void
setEnabled
(boolean enabled) Turn on/off this notification handlervoid
setPriority
(Integer priority) Set the priority of this NotificationHandler.
-
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
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()TheNotificationService
will ignore handlers that are disabled.- Returns:
-
setEnabled
void setEnabled(boolean enabled) Turn on/off this notification handler -
getPriority
Integer getPriority()TheNotificationService
will execute the first handler matching handler based on priority.- Returns:
-
setPriority
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()TheNotificationService
will execute the first handler matching handler based on priority.- Returns:
-
setDeliveryType
Return the deliveryType of this NotificationHandler. Typically ("EMAIL" or "SMS"). Matches the deliveryType of the handler with the corresponding deliveryType of the Notification.
-