Class GatewayClientService

java.lang.Object
org.apache.camel.builder.BuilderSupport
org.apache.camel.builder.RouteBuilder
org.openremote.manager.gateway.GatewayClientService
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, org.openremote.model.ContainerService

public class GatewayClientService extends org.apache.camel.builder.RouteBuilder implements org.openremote.model.ContainerService
Handles outbound connections to central managers
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
     
     
    static final String
     
    protected Map<String,Map<org.openremote.model.attribute.AttributeRef,Long>>
     
     
    protected final Map<String,GatewayIOClient>
     
    protected final Map<String,org.openremote.model.gateway.GatewayConnection>
     
     
     
    static final String
     
    protected org.openremote.container.persistence.PersistenceService
     
    static final int
     
    protected Consumer<org.openremote.model.asset.AssetEvent>
     
    protected Consumer<org.openremote.model.attribute.AttributeEvent>
     
    protected org.openremote.container.timer.TimerService
     

    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
    protected org.openremote.model.asset.Asset<?>
    applySyncRules(org.openremote.model.asset.Asset<?> asset, Map<String,org.openremote.model.gateway.GatewayAssetSyncRule> assetSyncRules)
    If the assetSyncRules affect this AssetType: 1) Filter out the attributes that have been defined in GatewayAssetSyncRule..excludeAttributes 2) Find the metaItem exclusions, with the specific attibuteName having priority over the wildcard.
    protected void
    applySyncRuleToMeta(String attributeName, org.openremote.model.attribute.MetaMap meta, org.openremote.model.gateway.GatewayAssetSyncRule syncRule)
     
    void
     
    protected GatewayIOClient
    createGatewayClient(org.openremote.model.gateway.GatewayConnection connection)
     
    boolean
     
    protected void
    destroyGatewayClient(org.openremote.model.gateway.GatewayConnection connection, GatewayIOClient client)
     
    protected String
    getClientSessionKey(org.openremote.model.gateway.GatewayConnection connection)
     
    protected List<org.openremote.model.gateway.GatewayConnection>
    GATEWAY RESOURCE METHODS
    protected org.openremote.model.asset.agent.ConnectionStatus
     
    protected org.openremote.model.event.shared.EventFilter<org.openremote.model.attribute.AttributeEvent>
    getOutboundAttributeEventFilter(org.openremote.model.gateway.GatewayConnection gatewayConnection)
     
    void
    init(org.openremote.model.Container container)
     
    protected <T> T
    messageFromString(String message, String prefix, Class<T> clazz)
     
    protected String
    messageToString(String prefix, Object message)
     
    protected void
    onCentralManagerMessage(org.openremote.model.gateway.GatewayConnection connection, String message)
     
    protected void
    onGatewayClientConnectionStatusChanged(org.openremote.model.gateway.GatewayConnection connection, org.openremote.model.asset.agent.ConnectionStatus connectionStatus)
     
    protected void
    processConnectionChange(org.openremote.model.gateway.GatewayConnection connection, org.openremote.model.PersistenceEvent.Cause cause)
     
    protected void
    sendAssetEvent(org.openremote.model.gateway.GatewayConnection connection, org.openremote.model.asset.AssetEvent event)
     
    protected void
    sendAttributeEvent(org.openremote.model.gateway.GatewayConnection connection, org.openremote.model.attribute.AttributeEvent event)
     
    protected void
     
    void
    setConnection(org.openremote.model.gateway.GatewayConnection connection)
     
    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

    • PRIORITY

      public static final int PRIORITY
      See Also:
    • CLIENT_EVENT_SESSION_PREFIX

      public static final String CLIENT_EVENT_SESSION_PREFIX
    • OR_GATEWAY_TUNNEL_LOCALHOST_REWRITE

      public static final String OR_GATEWAY_TUNNEL_LOCALHOST_REWRITE
      See Also:
    • assetStorageService

      protected AssetStorageService assetStorageService
    • assetProcessingService

      protected AssetProcessingService assetProcessingService
    • persistenceService

      protected org.openremote.container.persistence.PersistenceService persistenceService
    • clientEventService

      protected ClientEventService clientEventService
    • timerService

      protected org.openremote.container.timer.TimerService timerService
    • identityService

      protected ManagerIdentityService identityService
    • connectionRealmMap

      protected final Map<String,org.openremote.model.gateway.GatewayConnection> connectionRealmMap
    • clientRealmMap

      protected final Map<String,GatewayIOClient> clientRealmMap
    • gatewayTunnelFactory

      protected GatewayTunnelFactory gatewayTunnelFactory
    • clientAttributeTimestamps

      protected Map<String,Map<org.openremote.model.attribute.AttributeRef,Long>> clientAttributeTimestamps
    • realmAssetEventConsumer

      protected Consumer<org.openremote.model.asset.AssetEvent> realmAssetEventConsumer
    • realmAttributeEventConsumer

      protected Consumer<org.openremote.model.attribute.AttributeEvent> realmAttributeEventConsumer
  • Constructor Details

    • GatewayClientService

      public GatewayClientService()
  • 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
    • processConnectionChange

      protected void processConnectionChange(org.openremote.model.gateway.GatewayConnection connection, org.openremote.model.PersistenceEvent.Cause cause)
    • createGatewayClient

      protected GatewayIOClient createGatewayClient(org.openremote.model.gateway.GatewayConnection connection)
    • sendAssetEvent

      protected void sendAssetEvent(org.openremote.model.gateway.GatewayConnection connection, org.openremote.model.asset.AssetEvent event)
    • sendAttributeEvent

      protected void sendAttributeEvent(org.openremote.model.gateway.GatewayConnection connection, org.openremote.model.attribute.AttributeEvent event)
    • getOutboundAttributeEventFilter

      protected org.openremote.model.event.shared.EventFilter<org.openremote.model.attribute.AttributeEvent> getOutboundAttributeEventFilter(org.openremote.model.gateway.GatewayConnection gatewayConnection)
    • destroyGatewayClient

      protected void destroyGatewayClient(org.openremote.model.gateway.GatewayConnection connection, GatewayIOClient client)
    • onGatewayClientConnectionStatusChanged

      protected void onGatewayClientConnectionStatusChanged(org.openremote.model.gateway.GatewayConnection connection, org.openremote.model.asset.agent.ConnectionStatus connectionStatus)
    • onCentralManagerMessage

      protected void onCentralManagerMessage(org.openremote.model.gateway.GatewayConnection connection, String message)
    • sendCentralManagerMessage

      protected void sendCentralManagerMessage(String realm, String message)
    • getClientSessionKey

      protected String getClientSessionKey(org.openremote.model.gateway.GatewayConnection connection)
    • messageFromString

      protected <T> T messageFromString(String message, String prefix, Class<T> clazz)
    • messageToString

      protected String messageToString(String prefix, Object message)
    • getConnections

      protected List<org.openremote.model.gateway.GatewayConnection> getConnections()
      GATEWAY RESOURCE METHODS
    • setConnection

      public void setConnection(org.openremote.model.gateway.GatewayConnection connection)
    • deleteConnections

      public boolean deleteConnections(List<String> realms)
    • getConnectionStatus

      protected org.openremote.model.asset.agent.ConnectionStatus getConnectionStatus(String realm)
    • applySyncRules

      protected org.openremote.model.asset.Asset<?> applySyncRules(org.openremote.model.asset.Asset<?> asset, Map<String,org.openremote.model.gateway.GatewayAssetSyncRule> assetSyncRules)
      If the assetSyncRules affect this AssetType: 1) Filter out the attributes that have been defined in GatewayAssetSyncRule..excludeAttributes 2) Find the metaItem exclusions, with the specific attibuteName having priority over the wildcard. If none are found, Use Optional.Empty 3) Put the attribute and the List of excluded metaItems in a Tuple (MutablePair) 4) Filter out any excluded metaItems by using Attribute.setMeta(Attribute.getMeta) 5)
      Parameters:
      asset - Asset to filter
      assetSyncRules - Asset Sync Rules as found in GatewayConnection
      Returns:
      The asset as given, with attributes and metaItems stripped out as instructed by the assetSyncRules
    • applySyncRuleToMeta

      protected void applySyncRuleToMeta(String attributeName, org.openremote.model.attribute.MetaMap meta, org.openremote.model.gateway.GatewayAssetSyncRule syncRule)