Package titan.tasks

Interface TaskHandler

All Known Implementing Classes:
FileHandler, PdfConversionHandler, ScriptExecutorHandler, ServiceHandler

public interface TaskHandler
TaskHandler defines a contract for components that can execute a specific task. Implementations of this interface are responsible for processing an input payload and returning a result, typically as a String.

This interface also provides a default mechanism for setting a log listener, allowing for external observation of task execution logs.

  • Method Summary

    Modifier and Type
    Method
    Description
    execute(String payload)
    Executes a task with the given payload.
    default void
    Sets a listener to receive log messages generated during the task execution.
  • Method Details

    • execute

      String execute(String payload)
      Executes a task with the given payload. Implementations should define the specific logic for processing the payload and generating a result.
      Parameters:
      payload - The input data or parameters for the task, typically in a serialized format like JSON or XML.
      Returns:
      A string representing the result of the task execution. This could be a success message, a serialized object, or an error message.
    • setLogListener

      default void setLogListener(Consumer<String> listener)
      Sets a listener to receive log messages generated during the task execution. This default implementation does nothing, but concrete implementations can override it to provide logging capabilities, for example, to send logs to a centralized logging system or to a UI component.
      Parameters:
      listener - A Consumer that accepts log messages as strings. If null, any previously set listener should be removed or ignored.