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:
  1. The isMessageValid(org.openremote.model.notification.AbstractNotificationMessage) method will be called which allows the NotificationHandler to validate that the message is compatible and correctly structured.
  2. 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 the NotificationHandler to 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 Type
    Method
    Description
    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.
    The unique type name; it must correspond with the value set in AbstractNotificationMessage.getType() so that AbstractNotificationMessages can be mapped to a NotificationHandler.
    boolean
    isMessageValid(org.openremote.model.notification.AbstractNotificationMessage message)
    Allows the handler to validate the specified AbstractNotificationMessage.
    boolean
    Indicates if this handler has a valid configuration and is usable.
    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)

    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 in AbstractNotificationMessage.getType() so that AbstractNotificationMessages can be mapped to a NotificationHandler.
    • 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 specified AbstractNotificationMessage.
    • 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 requested Notification.TargetType was Notification.TargetType.REALM and this handler only supports targets of type Notification.TargetType.ASSET where the Assets must be ConsoleAsset then the handler needs to find all console assets that belong to the specified realm). Handlers can also add extra Notification.TargetType.CUSTOM handlers 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 specified AbstractNotificationMessage to the target; the target supplied would be a target previously returned by getTargets(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 the NotificationHandler to 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 NotificationHandler to update the delivered and/or acknowledged status of the notification by calling NotificationService.setNotificationDelivered(long) or NotificationService.setNotificationAcknowledged(long, java.lang.String)

      Throws:
      Exception