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 TypeMethodDescriptionbooleancanHandle(Notification notification, com.broadleafcommerce.data.tracking.core.context.ContextInfo context) Return true if this NotificationHandler can handle the passed in request.booleancanHandleType(String deliveryType) A NotificationHandler responds to a specific deliveryType.TheNotificationServicewill execute the first handler matching handler based on priority.TheNotificationServicewill execute the first handler matching handler based on priority.default booleanWhether this is the default handler of notifications.booleanTheNotificationServicewill ignore handlers that are disabled.voidpopulateNotification(Notification notification, NotificationResponse response, com.broadleafcommerce.data.tracking.core.context.ContextInfo context) Populates the passed in notification objectvoidsendMessage(Notification notification, NotificationResponse response, com.broadleafcommerce.data.tracking.core.context.ContextInfo context) Return true if this NotificationHandler can handle the passed in request.voidsetDeliveryType(String deliveryType) Return the deliveryType of this NotificationHandler.voidsetEnabled(boolean enabled) Turn on/off this notification handlervoidsetPriority(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()TheNotificationServicewill ignore handlers that are disabled.- Returns:
-
setEnabled
void setEnabled(boolean enabled) Turn on/off this notification handler -
getPriority
Integer getPriority()TheNotificationServicewill 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()TheNotificationServicewill 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.
-