Class StatusCache


  • public class StatusCache
    extends java.lang.Object
    Simple pre-processing cache of StatusMessage for UI display.
    Author:
    Holger Eichelberger, SSE
    • Nested Class Summary

      Nested Classes 
      Modifier and Type Class Description
      static class  StatusCache.ServiceDeviceState
      Denotes the state of a service on a certain device.
    • Field Summary

      Fields 
      Modifier and Type Field Description
      private static java.util.Map<java.lang.String,​java.util.Map<java.lang.String,​java.lang.String>> serviceStates  
      private static de.iip_ecosphere.platform.transport.connectors.ReceptionCallback<de.iip_ecosphere.platform.transport.status.StatusMessage> statusCallback  
    • Constructor Summary

      Constructors 
      Constructor Description
      StatusCache()  
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      private static java.util.Map<java.lang.String,​java.lang.String> ensureServicePerDevice​(de.iip_ecosphere.platform.transport.status.StatusMessage message)
      Ensures the existence of a device-state map for the service message message.
      static void getServiceStates​(java.lang.String sId, java.util.function.Consumer<StatusCache.ServiceDeviceState> consumer)
      Returns the states of service sId on all known devices.
      private static void handleServiceStateChange​(de.iip_ecosphere.platform.transport.status.StatusMessage message)
      Handles a service state change.
      static void start()
      Starts the status cache.
      static void stop()
      Stops the status cache.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • serviceStates

        private static java.util.Map<java.lang.String,​java.util.Map<java.lang.String,​java.lang.String>> serviceStates
      • statusCallback

        private static de.iip_ecosphere.platform.transport.connectors.ReceptionCallback<de.iip_ecosphere.platform.transport.status.StatusMessage> statusCallback
    • Constructor Detail

      • StatusCache

        public StatusCache()
    • Method Detail

      • ensureServicePerDevice

        private static java.util.Map<java.lang.String,​java.lang.String> ensureServicePerDevice​(de.iip_ecosphere.platform.transport.status.StatusMessage message)
        Ensures the existence of a device-state map for the service message message.
        Parameters:
        message - the message
        Returns:
        the device-state map
      • handleServiceStateChange

        private static void handleServiceStateChange​(de.iip_ecosphere.platform.transport.status.StatusMessage message)
        Handles a service state change.
        Parameters:
        message - the message indicating the service status change
      • getServiceStates

        public static void getServiceStates​(java.lang.String sId,
                                            java.util.function.Consumer<StatusCache.ServiceDeviceState> consumer)
        Returns the states of service sId on all known devices. If a device is not mentioned, the service is not running there.
        Parameters:
        sId - the service id
        consumer - a consumer receiving the data
      • start

        public static void start()
        Starts the status cache.
      • stop

        public static void stop()
        Stops the status cache.