Interface NotificationHandler
- All Superinterfaces:
org.openremote.model.ContainerService
- All Known Implementing Classes:
EmailNotificationHandler,LocalizedNotificationHandler,PushNotificationHandler
public interface NotificationHandler
extends org.openremote.model.ContainerService
A
NotificationHandler is responsible for sending compatible AbstractNotificationMessage messages to
the specified target. Before a message is sent:
- The
isMessageValid(org.openremote.model.notification.AbstractNotificationMessage)method will be called which allows theNotificationHandlerto validate that the message is compatible and correctly structured. - The
getTargets(org.openremote.model.notification.Notification.Source, java.lang.String, java.util.List<org.openremote.model.notification.Notification.Target>, org.openremote.model.notification.AbstractNotificationMessage)method will be called which allows theNotificationHandlerto map the requested target to a target that is compatible with this handler.
-
Field Summary
Fields inherited from interface org.openremote.model.ContainerService
DEFAULT_PRIORITY, HIGH_PRIORITY, LOW_PRIORITY, MED_PRIORITY -
Method Summary
Modifier and TypeMethodDescriptionList<org.openremote.model.notification.Notification.Target> getTargets(org.openremote.model.notification.Notification.Source source, String sourceId, List<org.openremote.model.notification.Notification.Target> requestedTargets, org.openremote.model.notification.AbstractNotificationMessage message) Map the requested targets to one or more targets that are compatible with this handler; if there are no compatible targets then return null.The unique type name; it must correspond with the value set inAbstractNotificationMessage.getType()so thatAbstractNotificationMessages can be mapped to aNotificationHandler.booleanisMessageValid(org.openremote.model.notification.AbstractNotificationMessage message) Allows the handler to validate the specifiedAbstractNotificationMessage.booleanisValid()Indicates if this handler has a valid configuration and is usable.voidsendMessage(long id, org.openremote.model.notification.Notification.Source source, String sourceId, org.openremote.model.notification.Notification.Target target, org.openremote.model.notification.AbstractNotificationMessage message) Send the specifiedAbstractNotificationMessageto the target; the target supplied would be a target previously returned bygetTargets(org.openremote.model.notification.Notification.Source, java.lang.String, java.util.List<org.openremote.model.notification.Notification.Target>, org.openremote.model.notification.AbstractNotificationMessage).Methods inherited from interface org.openremote.model.ContainerService
getPriority, init, start, stop
-
Method Details
-
getTypeName
String getTypeName()The unique type name; it must correspond with the value set inAbstractNotificationMessage.getType()so thatAbstractNotificationMessages can be mapped to aNotificationHandler. -
isValid
boolean isValid()Indicates if this handler has a valid configuration and is usable. -
isMessageValid
boolean isMessageValid(org.openremote.model.notification.AbstractNotificationMessage message) Allows the handler to validate the specifiedAbstractNotificationMessage. -
getTargets
List<org.openremote.model.notification.Notification.Target> getTargets(org.openremote.model.notification.Notification.Source source, String sourceId, List<org.openremote.model.notification.Notification.Target> requestedTargets, org.openremote.model.notification.AbstractNotificationMessage message) Map the requested targets to one or more targets that are compatible with this handler; if there are no compatible targets then return null. If the requested target is already compatible then it can just be returned; handlers are free to determine how the requested target should be mapped (e.g. if requestedNotification.TargetTypewasNotification.TargetType.REALMand this handler only supports targets of typeNotification.TargetType.ASSETwhere theAssets must beConsoleAssetthen the handler needs to find all console assets that belong to the specified realm). Handlers can also add extraNotification.TargetType.CUSTOMhandlers extracted from the message. -
sendMessage
void sendMessage(long id, org.openremote.model.notification.Notification.Source source, String sourceId, org.openremote.model.notification.Notification.Target target, org.openremote.model.notification.AbstractNotificationMessage message) throws Exception Send the specifiedAbstractNotificationMessageto the target; the target supplied would be a target previously returned bygetTargets(org.openremote.model.notification.Notification.Source, java.lang.String, java.util.List<org.openremote.model.notification.Notification.Target>, org.openremote.model.notification.AbstractNotificationMessage). It is the responsibility of theNotificationHandlerto maintain any required cache to ensure this call is as performant as possible (i.e. the handler should avoid making excessive DB calls if possible).The ID can be used by the
NotificationHandlerto update the delivered and/or acknowledged status of the notification by callingNotificationService.setNotificationDelivered(long)orNotificationService.setNotificationAcknowledged(long, java.lang.String)- Throws:
Exception
-