Interface OperationalModesService

All Known Implementing Classes:
DefaultOperationalModesService

public interface OperationalModesService
API for operational mode management.
Since:
1.62
Version:
2.0
Author:
matt
  • Field Details

    • TOPIC_ENABLE_OPERATIONAL_MODES

      static final String TOPIC_ENABLE_OPERATIONAL_MODES
      The instruction topic for activating a set of operational modes.

      The instruction is expected to provide one or more INSTRUCTION_PARAM_OPERATIONAL_MODE parameters with the modes to be enabled.

      See Also:
    • TOPIC_DISABLE_OPERATIONAL_MODES

      static final String TOPIC_DISABLE_OPERATIONAL_MODES
      The instruction topic for deactivating a set of operational modes.

      The instruction is expected to provide one or more INSTRUCTION_PARAM_OPERATIONAL_MODE parameters with the modes to be disabled.

      See Also:
    • INSTRUCTION_PARAM_OPERATIONAL_MODE

      static final String INSTRUCTION_PARAM_OPERATIONAL_MODE
      Instruction parameter for an operational mode name.
      See Also:
    • INSTRUCTION_PARAM_EXPIRATION

      static final String INSTRUCTION_PARAM_EXPIRATION
      Instruction parameter for an expiration time.
      Since:
      1.1
      See Also:
    • EVENT_TOPIC_OPERATIONAL_MODES_CHANGED

      static final String EVENT_TOPIC_OPERATIONAL_MODES_CHANGED
      An Event topic for when a the active operational modes have changed.

      This event must be sent after the a change to the operational modes has been persisted. The event is expected to provide a EVENT_PARAM_ACTIVE_OPERATIONAL_MODES parameter with the modes that are effectively active after the change.

      See Also:
    • EVENT_PARAM_ACTIVE_OPERATIONAL_MODES

      static final String EVENT_PARAM_ACTIVE_OPERATIONAL_MODES
      Event parameter with a Set of active operational modes.

      If no user-defined modes are active, a default mode is assumed and an empty Set must be provided.

      See Also:
  • Method Details

    • isOperationalModeActive

      boolean isOperationalModeActive(String mode)
      Test if a specific mode is active.

      Note that a null or empty mode argument will be treated as testing if the default mode is active, which is always true.

      Parameters:
      mode - the mode to test; the mode can be prefixed with ! to test if the given mode is not active
      Returns:
      true if mode is active, or if mode starts with ! then true if mode is not active
    • activeOperationalModes

      Set<String> activeOperationalModes()
      Get the set of active operational modes.
      Returns:
      the active operational modes, never null
    • enableOperationalModes

      Set<String> enableOperationalModes(Set<String> modes)
      Enable a set of operational modes.
      Parameters:
      modes - the modes to enable
      Returns:
      the active operational modes, after activating modes, never null
    • enableOperationalModes

      Set<String> enableOperationalModes(Set<String> modes, Instant expire)
      Enable a set of operational modes.
      Parameters:
      modes - the modes to enable
      expire - a date after which modes should be automatically disabled, or null for no expiration
      Returns:
      the active operational modes, after activating modes, never null
      Since:
      2.0
    • disableOperationalModes

      Set<String> disableOperationalModes(Set<String> modes)
      Disable a set of operational modes.
      Parameters:
      modes - the modes to disable
      Returns:
      the active operational modes, after deactivating modes, never null
    • hasActiveOperationalMode

      static boolean hasActiveOperationalMode(org.osgi.service.event.Event event, String mode)
      Test if an event has an active mode parameter value.

      This method will look for a EVENT_PARAM_ACTIVE_OPERATIONAL_MODES event parameter in the provided event. If the parameter is a Set, and it contains mode or mode is null or empty, then true will be returned.

      Parameters:
      event - the event to inspect
      mode - the mode to test for
      Returns:
      true if mode is included in the active modes included in the event
    • expirationDate

      static Instant expirationDate(Instruction instruction)
      Parse an expiration value from an instruction parameter.

      The INSTRUCTION_PARAM_EXPIRATION parameter is inspected for an epoch String value, which will be parsed and returned as a date instance if available.

      Parameters:
      instruction - the instruction to parse the expiration parameter from
      Returns:
      the expiration date, or null if none available
      Since:
      2.0