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 Details

    • 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 object value should have a proper #toString method as by default, the #toString method is used for displaying the object in the diagnostics.
      Parameters:
      key - attribute name
      value - 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 for key, this object is returned. Otherwise null 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 interface AutoCloseable