Interface OperationalModesService
- All Known Implementing Classes:
DefaultOperationalModesService
- Since:
- 1.62
- Version:
- 2.1
- Author:
- matt
-
Nested Class Summary
Nested ClassesModifier and TypeInterfaceDescriptionstatic final classRegistered operational mode information. -
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.Get the set of active operational modes with expirations.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.Get all registered operational mode information.Register operational mode information for "well known" modes.booleanunregisterOperationalModeInfo(UUID registrationId) Unregister previously registered operational mode information.withPrefix(String prefix) An operational mode information predicate to match on a name prefix.withPrefixAndTag(String prefix, String tag) An operational mode information predicate to match on a tag.An operational mode information predicate to match on a tag.
-
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
-
activeOperationalModesWithExpirations
Get the set of active operational modes with expirations.This method returns only the operational modes that are both active and have an expiration configured (that is still in the future).
- Returns:
- the active operational modes that have expiration dates, never null
- Since:
- 2.1
-
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
-
registerOperationalModeInfo
Register operational mode information for "well known" modes.- Parameters:
info- the information to register- Returns:
- a unique registration ID
- Since:
- 2.1
-
registeredOperationalModes
Stream<OperationalModesService.OperationalModeInfo> registeredOperationalModes()Get all registered operational mode information.- Returns:
- all registered operational mode information
- Since:
- 2.1
-
unregisterOperationalModeInfo
Unregister previously registered operational mode information.- Parameters:
registrationId- the registration ID, previously returned fromregisterOperationalModeInfo(OperationalModeInfo)- Returns:
- true if the registration ID was found, false otherwise
- Since:
- 2.1
-
withPrefix
An operational mode information predicate to match on a name prefix.- Parameters:
prefix- the prefix to match- Returns:
- the predicate
- Since:
- 2.1
-
withTag
An operational mode information predicate to match on a tag.- Parameters:
tag- the tag to match- Returns:
- the predicate
- Since:
- 2.1
-
withPrefixAndTag
static Predicate<OperationalModesService.OperationalModeInfo> withPrefixAndTag(String prefix, String tag) An operational mode information predicate to match on a tag.- Parameters:
prefix- the prefix to matchtag- the tag to match- Returns:
- the predicate
- Since:
- 2.1
-