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
FieldsFields inherited from class org.apache.camel.builder.RouteBuilder
logFields inherited from interface org.openremote.model.ContainerService
DEFAULT_PRIORITY, HIGH_PRIORITY, LOW_PRIORITY, MED_PRIORITYFields inherited from interface org.apache.camel.Ordered
HIGHEST, LOWEST -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidList<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.voidinit(org.openremote.model.Container container) 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 byNotificationHandler.getTargets(org.openremote.model.notification.Notification.Source, java.lang.String, java.util.List<org.openremote.model.notification.Notification.Target>, org.openremote.model.notification.AbstractNotificationMessage).voidstart(org.openremote.model.Container container) voidstop(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, validatorMethods 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, xpathMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface org.openremote.model.ContainerService
getPriority
-
Field Details
-
notificationHandlerMap
-
valid
protected boolean valid
-
-
Constructor Details
-
LocalizedNotificationHandler
public LocalizedNotificationHandler()
-
-
Method Details
-
init
- Specified by:
initin interfaceorg.openremote.model.ContainerService- Throws:
Exception
-
start
- Specified by:
startin interfaceorg.openremote.model.ContainerService- Throws:
Exception
-
stop
- Specified by:
stopin interfaceorg.openremote.model.ContainerService- Throws:
Exception
-
configure
- Specified by:
configurein classorg.apache.camel.builder.RouteBuilder- Throws:
Exception
-
getTypeName
Description copied from interface:NotificationHandlerThe unique type name; it must correspond with the value set inAbstractNotificationMessage.getType()so thatAbstractNotificationMessages can be mapped to aNotificationHandler.- Specified by:
getTypeNamein interfaceNotificationHandler
-
isMessageValid
public boolean isMessageValid(org.openremote.model.notification.AbstractNotificationMessage message) Description copied from interface:NotificationHandlerAllows the handler to validate the specifiedAbstractNotificationMessage.- Specified by:
isMessageValidin interfaceNotificationHandler
-
isValid
public boolean isValid()Description copied from interface:NotificationHandlerIndicates if this handler has a valid configuration and is usable.- Specified by:
isValidin interfaceNotificationHandler
-
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:NotificationHandlerMap 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.- Specified by:
getTargetsin interfaceNotificationHandler
-
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:NotificationHandlerSend the specifiedAbstractNotificationMessageto the target; the target supplied would be a target previously returned byNotificationHandler.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 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)- Specified by:
sendMessagein interfaceNotificationHandler- Throws:
Exception
-