Class LocalizedNotificationHandler

java.lang.Object
org.apache.camel.builder.BuilderSupport
org.apache.camel.builder.RouteBuilder
org.openremote.manager.notification.LocalizedNotificationHandler
All Implemented Interfaces:
org.apache.camel.builder.ModelRoutesBuilder, org.apache.camel.CamelContextAware, org.apache.camel.Ordered, org.apache.camel.RoutesBuilder, org.apache.camel.spi.HasCamelContext, org.apache.camel.spi.ResourceAware, NotificationHandler, org.openremote.model.ContainerService

public class LocalizedNotificationHandler extends org.apache.camel.builder.RouteBuilder implements NotificationHandler
This LocalizedNotificationHandler handles notification differently compared to other handlers. When a LocalizedNotificationMessage is processed, that normally contains a configuration for multiple languages, we repeat the isMessageValid(org.openremote.model.notification.AbstractNotificationMessage) and getTargets(org.openremote.model.notification.Notification.Source, java.lang.String, java.util.List<org.openremote.model.notification.Notification.Target>, org.openremote.model.notification.AbstractNotificationMessage) methods for each individual locale. (using the notificationHandlerMap)
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
     
    protected boolean
     

    Fields inherited from class org.apache.camel.builder.RouteBuilder

    log

    Fields inherited from interface org.openremote.model.ContainerService

    DEFAULT_PRIORITY, HIGH_PRIORITY, LOW_PRIORITY, MED_PRIORITY

    Fields inherited from interface org.apache.camel.Ordered

    HIGHEST, LOWEST
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    void
     
    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.
    void
    init(org.openremote.model.Container container)
     
    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)
    void
    start(org.openremote.model.Container container)
     
    void
    stop(org.openremote.model.Container container)
     

    Methods inherited from class org.apache.camel.builder.RouteBuilder

    addLifecycleInterceptor, addRoutes, addRoutesToCamelContext, addTemplatedRoutesToCamelContext, bindToRegistry, bindToRegistry, checkInitialized, configuration, configureRest, configureRests, configureRoute, configureRouteConfiguration, configureRoutes, configureRouteTemplate, configureTemplatedRoute, customize, customize, dataFormat, errorHandler, errorHandler, expression, from, from, from, fromF, fromV, fromV, getBeans, getOrder, getResource, getRestCollection, getRestConfiguration, getRests, getRouteCollection, getRoutes, getRouteTemplateCollection, getTemplatedRouteCollection, initializeCamelContext, intercept, interceptFrom, interceptFrom, interceptSendToEndpoint, loadRoutesBuilder, loadRoutesBuilder, onCompletion, onException, onException, populateBeans, populateOrUpdateRoutes, populateRests, populateRoutes, populateRouteTemplates, populateTemplatedRoutes, populateTransformers, populateValidators, prepareModel, property, propertyInject, removeLifecycleInterceptor, rest, rest, restConfiguration, routeTemplate, setErrorHandlerFactory, setResource, setRestCollection, setRouteTemplateCollection, setTemplatedRouteCollection, templatedRoute, tokenizer, toString, transformer, updateRoutesToCamelContext, validator

    Methods inherited from class org.apache.camel.builder.BuilderSupport

    body, bodyAs, constant, constant, constant, createErrorHandlerBuilder, csimple, csimple, datasonnet, datasonnet, datasonnet, deadLetterChannel, deadLetterChannel, defaultErrorHandler, endpoint, endpoint, exceptionMessage, exchangeProperty, expression, getCamelContext, getContext, getErrorHandlerFactory, hasErrorHandlerFactory, header, java, java, joor, joor, jq, jq, jsonpath, jsonpath, jtaTransactionErrorHandler, jtaTransactionErrorHandler, jtaTransactionErrorHandler, method, method, method, method, noErrorHandler, regexReplaceAll, regexReplaceAll, setCamelContext, simple, simple, simpleF, simpleF, springTransactionErrorHandler, springTransactionErrorHandler, springTransactionErrorHandler, systemProperty, systemProperty, variable, xpath, xpath, xpath, xpath

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait

    Methods inherited from interface org.openremote.model.ContainerService

    getPriority
  • Field Details

  • Constructor Details

    • LocalizedNotificationHandler

      public LocalizedNotificationHandler()
  • Method Details

    • init

      public void init(org.openremote.model.Container container) throws Exception
      Specified by:
      init in interface org.openremote.model.ContainerService
      Throws:
      Exception
    • start

      public void start(org.openremote.model.Container container) throws Exception
      Specified by:
      start in interface org.openremote.model.ContainerService
      Throws:
      Exception
    • stop

      public void stop(org.openremote.model.Container container) throws Exception
      Specified by:
      stop in interface org.openremote.model.ContainerService
      Throws:
      Exception
    • configure

      public void configure() throws Exception
      Specified by:
      configure in class org.apache.camel.builder.RouteBuilder
      Throws:
      Exception
    • getTypeName

      public String getTypeName()
      Description copied from interface: NotificationHandler
      The unique type name; it must correspond with the value set in AbstractNotificationMessage.getType() so that AbstractNotificationMessages can be mapped to a NotificationHandler.
      Specified by:
      getTypeName in interface NotificationHandler
    • isMessageValid

      public boolean isMessageValid(org.openremote.model.notification.AbstractNotificationMessage message)
      Description copied from interface: NotificationHandler
      Allows the handler to validate the specified AbstractNotificationMessage.
      Specified by:
      isMessageValid in interface NotificationHandler
    • isValid

      public boolean isValid()
      Description copied from interface: NotificationHandler
      Indicates if this handler has a valid configuration and is usable.
      Specified by:
      isValid in interface NotificationHandler
    • getTargets

      public 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)
      Description copied from interface: NotificationHandler
      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.
      Specified by:
      getTargets in interface NotificationHandler
    • sendMessage

      public 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
      Description copied from interface: NotificationHandler
      Send the specified AbstractNotificationMessage to the target; the target supplied would be a target previously returned by NotificationHandler.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)

      Specified by:
      sendMessage in interface NotificationHandler
      Throws:
      Exception