Class DefaultNotificationHandler
java.lang.Object
com.broadleafcommerce.notification.service.DefaultNotificationHandler
- All Implemented Interfaces:
NotificationHandler
NotificationHandler with the most common default settings. - deliveryType : EMAIL - priority :
Integer.MAX_VALUE - enabled : true - canHandleType method implemented based on the deliveryType
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected void
addSentByToResponse
(NotificationResponse response, Class clazz) boolean
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.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) The default implementation checks the notification to determine if it has a messageBody.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.void
setDefault
(boolean isDefault) 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.
-
Constructor Details
-
DefaultNotificationHandler
-
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 interfaceNotificationHandler
-
canHandleType
Description copied from interface:NotificationHandler
A NotificationHandler responds to a specific deliveryType.- Specified by:
canHandleType
in interfaceNotificationHandler
-
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 interfaceNotificationHandler
- 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 interfaceNotificationHandler
- Parameters:
notification
-response
-context
-
-
addSentByToResponse
-
isEnabled
public boolean isEnabled()Description copied from interface:NotificationHandler
TheNotificationService
will ignore handlers that are disabled.- Specified by:
isEnabled
in interfaceNotificationHandler
- Returns:
-
setEnabled
public void setEnabled(boolean enabled) Description copied from interface:NotificationHandler
Turn on/off this notification handler- Specified by:
setEnabled
in interfaceNotificationHandler
-
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 interfaceNotificationHandler
- 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
Description copied from interface:NotificationHandler
TheNotificationService
will execute the first handler matching handler based on priority.- Specified by:
getDeliveryType
in interfaceNotificationHandler
- Returns:
-
setDeliveryType
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 interfaceNotificationHandler
-
getPriority
Description copied from interface:NotificationHandler
TheNotificationService
will execute the first handler matching handler based on priority.- Specified by:
getPriority
in interfaceNotificationHandler
- Returns:
-
setPriority
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 interfaceNotificationHandler
-