Interface OperationalModesService
- All Known Implementing Classes:
DefaultOperationalModesService
- Since:
- 1.62
- Version:
- 2.0
- Author:
- matt
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final StringEvent parameter with aSetof active operational modes.static final StringAnEventtopic for when a the active operational modes have changed.static final StringInstruction parameter for an expiration time.static final StringInstruction parameter for an operational mode name.static final StringThe instruction topic for deactivating a set of operational modes.static final StringThe instruction topic for activating a set of operational modes. -
Method Summary
Modifier and TypeMethodDescriptionGet the set of active operational modes.disableOperationalModes(Set<String> modes) Disable a set of operational modes.enableOperationalModes(Set<String> modes) Enable a set of operational modes.enableOperationalModes(Set<String> modes, Instant expire) Enable a set of operational modes.static InstantexpirationDate(Instruction instruction) Parse an expiration value from an instruction parameter.static booleanhasActiveOperationalMode(org.osgi.service.event.Event event, String mode) Test if an event has an active mode parameter value.booleanTest if a specific mode is active.
-
Field Details
-
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_MODEparameters with the modes to be enabled.- See Also:
-
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_MODEparameters with the modes to be disabled.- See Also:
-
INSTRUCTION_PARAM_OPERATIONAL_MODE
Instruction parameter for an operational mode name.- See Also:
-
INSTRUCTION_PARAM_EXPIRATION
Instruction parameter for an expiration time.- Since:
- 1.1
- See Also:
-
EVENT_TOPIC_OPERATIONAL_MODES_CHANGED
AnEventtopic 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_MODESparameter with the modes that are effectively active after the change.- See Also:
-
EVENT_PARAM_ACTIVE_OPERATIONAL_MODES
Event parameter with aSetof active operational modes.If no user-defined modes are active, a default mode is assumed and an empty
Setmust be provided.- See Also:
-
-
Method Details
-
isOperationalModeActive
Test if a specific mode is active.Note that a null or empty
modeargument 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
modeis active, or ifmodestarts with ! then true ifmodeis not active
-
activeOperationalModes
Get the set of active operational modes.- Returns:
- the active operational modes, never null
-
enableOperationalModes
Enable a set of operational modes.- Parameters:
modes- the modes to enable- Returns:
- the active operational modes, after activating
modes, never null
-
enableOperationalModes
Enable a set of operational modes.- Parameters:
modes- the modes to enableexpire- a date after whichmodesshould be automatically disabled, or null for no expiration- Returns:
- the active operational modes, after activating
modes, never null - Since:
- 2.0
-
disableOperationalModes
Disable a set of operational modes.- Parameters:
modes- the modes to disable- Returns:
- the active operational modes, after deactivating
modes, never null
-
hasActiveOperationalMode
Test if an event has an active mode parameter value.This method will look for a
EVENT_PARAM_ACTIVE_OPERATIONAL_MODESevent parameter in the providedevent. If the parameter is aSet, and it containsmodeormodeis null or empty, then true will be returned.- Parameters:
event- the event to inspectmode- the mode to test for- Returns:
- true if
modeis included in the active modes included in the event
-
expirationDate
Parse an expiration value from an instruction parameter.The
INSTRUCTION_PARAM_EXPIRATIONparameter 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
-