Package org.hippoecm.hst.diagnosis
Interface Task
-
- All Superinterfaces:
AutoCloseable
- All Known Implementing Classes:
DefaultTaskImpl
public interface Task extends AutoCloseable
A unit of execution. A task may start a subtask, and may contain multiple child subtasks. Each task may have attributes map of necessary data needed for diagnostics. By the way, the root task should be given by the container.
-
-
Method Summary
All Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description default void
close()
Object
getAttribute(String key)
Retrieve the attribute value by the attribute name.Map<String,Object>
getAttributeMap()
Returns attribute map which is unmodifiable.Enumeration<String>
getAttributeNames()
Enumerates the attribute namesCollection<Task>
getChildTasks()
Returns the child tasks collectionlong
getDurationTimeMillis()
Returns the task execution duration time in millisecondsString
getName()
returns the task nameTask
getParentTask()
boolean
isRunning()
Returns true if the task was started but not stopped.Object
removeAttribute(String key)
Removes the attribute by the attribute name.void
setAttribute(String key, Object value)
Set an attribute for the task.Task
startSubtask(String name)
Starts and returns a child subtask with the name.void
stop()
Stops the task
-
-
-
Method Detail
-
getName
String getName()
returns the task name- Returns:
-
getAttributeMap
Map<String,Object> getAttributeMap()
Returns attribute map which is unmodifiable. So, do not try to put or remove items directly from the returned map.- Returns:
-
getAttributeNames
Enumeration<String> getAttributeNames()
Enumerates the attribute names
-
setAttribute
void setAttribute(String key, Object value)
Set an attribute for the task. The objectvalue
should have a proper #toString method as by default, the #toString method is used for displaying the object in the diagnostics.- Parameters:
key
- attribute namevalue
- attribute value
-
getAttribute
Object getAttribute(String key)
Retrieve the attribute value by the attribute name. When not found,null
is returned
-
removeAttribute
Object removeAttribute(String key)
Removes the attribute by the attribute name. When an Object was removed forkey
, this object is returned. Otherwisenull
is returned.
-
getParentTask
Task getParentTask()
- Returns:
- Returns the parent task and
null
if this is the root task
-
startSubtask
Task startSubtask(String name)
Starts and returns a child subtask with the name.- Parameters:
name
-- Returns:
-
stop
void stop()
Stops the task
-
getChildTasks
Collection<Task> getChildTasks()
Returns the child tasks collection- Returns:
-
isRunning
boolean isRunning()
Returns true if the task was started but not stopped.- Returns:
-
getDurationTimeMillis
long getDurationTimeMillis()
Returns the task execution duration time in milliseconds- Returns:
-
close
default void close()
- Specified by:
close
in interfaceAutoCloseable
-
-