Class StatusMessage
java.lang.Object
de.iip_ecosphere.platform.transport.status.StatusMessage
Represents a status message for a component. A component is denoted by the device id (of the ECS runtime) the
component is running on, the component id (in the context of a device) and optional alias ids, e.g., introduced
by a specific device management approach. If the component to notify about is a device, the device id and the
component id shall be equal.
- Author:
- Holger Eichelberger, SSE
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate ActionTypeprivate String[]private ComponentTypeprivate Stringprivate Stringprivate Stringprivate intprivate Objectstatic final Stringprivate Stringprivate String -
Constructor Summary
ConstructorsConstructorDescriptionCreates an empty status message.StatusMessage(ActionType action, String id, String... aliasIds) Creates a new status message for devices, i.e.,ComponentTypes.DEVICE.StatusMessage(ComponentType componentType, ActionType action, String id, String deviceId, String... aliasIds) Creates a new status message. -
Method Summary
Modifier and TypeMethodDescriptionReturns the action type causing this message.String[]Returns optional alias ids of the component.Returns the component type.Returns the description,ActionTypes.PROCESS.Returns the device (context) id of the component.getId()Returns the primary id of the component.intReturns the progress forActionTypes.PROCESS.Returns the result of task-based processing.Returns the sub(-task) description,ActionTypes.PROCESS.Returns the task id this message is sent from within.voidsend(TransportConnector conn) Sends this message to the given connector on#STATUS_STREAM.(package private) voidsetAction(ActionType action) Changes the action type.(package private) voidsetAliasIds(String[] aliasIds) Changes the alias ids of the component.(package private) voidsetComponentType(ComponentType componentType) Changes the component type.(package private) voidsetDeviceId(String deviceId) Changes the device (context) id of the component.(package private) voidChanges the primary id of the component.withDescription(String description) Sets the description forgetProgress(),ActionTypes.PROCESS.withProgress(int progress) Defines the progress forActionTypes.PROCESS.withResult(Object result) Sets the result of task-based processing.withSubDescription(String subDescription) Sets the sub(-task) description forgetProgress(),ActionTypes.PROCESS.withTask()Adds task information if the actually running process were, e.g., initiated from the UI.withTask(de.iip_ecosphere.platform.support.TaskRegistry.TaskData data) Adds task information if the actually running process were, e.g., initiated from the UI.Adds task information if the actually running process were, e.g., initiated from the UI.
-
Field Details
-
STATUS_STREAM
- See Also:
-
componentType
-
action
-
id
-
aliasIds
-
deviceId
-
progress
private int progress -
description
-
subDescription
-
taskId
-
result
-
-
Constructor Details
-
StatusMessage
StatusMessage()Creates an empty status message. [deserialization] -
StatusMessage
Creates a new status message for devices, i.e.,ComponentTypes.DEVICE.- Parameters:
action- the actionid- the id of the componentaliasIds- optional alias ids
-
StatusMessage
public StatusMessage(ComponentType componentType, ActionType action, String id, String deviceId, String... aliasIds) Creates a new status message.- Parameters:
componentType- the component typeaction- the actionid- the id of the componentdeviceId- the id of device providing the context, shall be equal toidifcomponentTypeisComponentTypes.DEVICE.aliasIds- optional alias ids
-
-
Method Details
-
getComponentType
Returns the component type.- Returns:
- the component type
-
setComponentType
Changes the component type. [deserialization]- Parameters:
componentType- the new component type
-
getAction
Returns the action type causing this message.- Returns:
- the action type causing this message
-
setAction
Changes the action type. [deserialization]- Parameters:
action- the new action type
-
getId
Returns the primary id of the component.- Returns:
- the primary id, may be equal to
getDeviceId()ifgetComponentType()isComponentTypes.DEVICE.
-
setId
Changes the primary id of the component. [deserialization]- Parameters:
id- the primary id
-
getDeviceId
Returns the device (context) id of the component.- Returns:
- the device id, shall be equal to
getId()ifgetComponentType()isComponentTypes.DEVICE.
-
setDeviceId
Changes the device (context) id of the component. [deserialization]- Parameters:
deviceId- the device id
-
getAliasIds
Returns optional alias ids of the component.- Returns:
- the alias ids, may be empty
-
setAliasIds
Changes the alias ids of the component. [deserialization]- Parameters:
aliasIds- the primary id
-
send
Sends this message to the given connector on#STATUS_STREAM. [convenience]- Parameters:
conn- the connector- Throws:
IOException- if sending fails
-
withProgress
Defines the progress forActionTypes.PROCESS.- Parameters:
progress- the progress in [0;100]; if 100 longer running process is assumed to be completed- Returns:
- this
-
getProgress
public int getProgress()Returns the progress forActionTypes.PROCESS.- Returns:
- the progress in percent: if negative, no progress will be reported. If positive, further messages shall follow until 100.
-
withDescription
Sets the description forgetProgress(),ActionTypes.PROCESS.- Parameters:
description- the description, may be null or ""- Returns:
- this
-
getDescription
Returns the description,ActionTypes.PROCESS.- Returns:
- the description, may be empty but not null
-
withSubDescription
Sets the sub(-task) description forgetProgress(),ActionTypes.PROCESS.- Parameters:
subDescription- the sub(-task) description, may be null or ""- Returns:
- this
-
getSubDescription
Returns the sub(-task) description,ActionTypes.PROCESS.- Returns:
- the sub(-task) description, may be empty but not null
-
withTask
Adds task information if the actually running process were, e.g., initiated from the UI. Takes the registered task data for the actual thread from theTaskRegistry.- Returns:
- this
- See Also:
-
withTask
Adds task information if the actually running process were, e.g., initiated from the UI. Does not attach results.- Parameters:
data- the task data (fromTaskRegistry- Returns:
- this
- See Also:
-
withTask
public StatusMessage withTask(de.iip_ecosphere.platform.support.TaskRegistry.TaskData data, Object result) Adds task information if the actually running process were, e.g., initiated from the UI.- Parameters:
data- the task data (fromTaskRegistryresult- the result (must be serializable, seeSerializerRegistry) ifgetAction()isActionTypes.RESULTor information about an error/exception ifgetAction()isActionTypes.ERROR, may be null- Returns:
- this
- See Also:
-
withResult
Sets the result of task-based processing.- Parameters:
result- the result (must be serializable, seeSerializerRegistry) ifgetAction()isActionTypes.RESULTor information about an error/exception ifgetAction()isActionTypes.ERROR, may be null- Returns:
- this
-
getTaskId
Returns the task id this message is sent from within. Not all status messages have a task id, e.g., if the are not started from the UI as longer running task.- Returns:
- the task id, may be null
-
getResult
Returns the result of task-based processing.- Returns:
- the result (must be serializable, see
SerializerRegistry) ifgetAction()isActionTypes.RESULTor information about an error/exception ifgetAction()isActionTypes.ERROR, may be null
-