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 voidaddSentByToResponse(NotificationResponse response, Class clazz) booleancanHandle(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.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) The default implementation checks the notification to determine if it has a messageBody.voidsendMessage(Notification notification, NotificationResponse response, com.broadleafcommerce.data.tracking.core.context.ContextInfo context) Return true if this NotificationHandler can handle the passed in request.voidsetDefault(boolean isDefault) 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.
-
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:NotificationHandlerReturn true if this NotificationHandler can handle the passed in request.- Specified by:
sendMessagein interfaceNotificationHandler
-
canHandleType
Description copied from interface:NotificationHandlerA NotificationHandler responds to a specific deliveryType.- Specified by:
canHandleTypein interfaceNotificationHandler
-
canHandle
public boolean canHandle(Notification notification, com.broadleafcommerce.data.tracking.core.context.ContextInfo context) Description copied from interface:NotificationHandlerReturn true if this NotificationHandler can handle the passed in request.- Specified by:
canHandlein 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:
populateNotificationin interfaceNotificationHandler- Parameters:
notification-response-context-
-
addSentByToResponse
-
isEnabled
public boolean isEnabled()Description copied from interface:NotificationHandlerTheNotificationServicewill ignore handlers that are disabled.- Specified by:
isEnabledin interfaceNotificationHandler- Returns:
-
setEnabled
public void setEnabled(boolean enabled) Description copied from interface:NotificationHandlerTurn on/off this notification handler- Specified by:
setEnabledin interfaceNotificationHandler
-
isDefault
public boolean isDefault()Description copied from interface:NotificationHandlerWhether 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:
isDefaultin 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:NotificationHandlerTheNotificationServicewill execute the first handler matching handler based on priority.- Specified by:
getDeliveryTypein interfaceNotificationHandler- Returns:
-
setDeliveryType
Description copied from interface:NotificationHandlerReturn the deliveryType of this NotificationHandler. Typically ("EMAIL" or "SMS"). Matches the deliveryType of the handler with the corresponding deliveryType of the Notification.- Specified by:
setDeliveryTypein interfaceNotificationHandler
-
getPriority
Description copied from interface:NotificationHandlerTheNotificationServicewill execute the first handler matching handler based on priority.- Specified by:
getPriorityin interfaceNotificationHandler- Returns:
-
setPriority
Description copied from interface:NotificationHandlerSet 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:
setPriorityin interfaceNotificationHandler
-