Interface CommandObserver

All Superinterfaces:
Cloneable
All Known Implementing Classes:
LoggingCommandObserver

public interface CommandObserver extends Cloneable
Defines the contract for observers that react to command executions within the DataApiClient. Implementing this interface allows for the execution of synchronous treatments in response to command execution events. These treatments can include logging, metrics collection, or any other form of monitoring or post-execution processing.

By registering a CommandObserver with a DataApiClient, clients can extend the client's functionality in a decoupled manner, enabling custom behaviors such as logging command details, pushing metrics to a monitoring system, or even triggering additional business logic based on the command's execution.

This interface is particularly useful in scenarios where actions need to be taken immediately after a command's execution, and where those actions might depend on the outcome or metadata of the command. Implementers can receive detailed information about the command's execution through the ExecutionInfos parameter, allowing for rich and context-aware processing.

Example use cases include:
  • Logging command execution details for audit or debugging purposes.
  • Collecting performance metrics of command executions to monitor the health and performance of the application.
  • Triggering additional processes or workflows based on the success or failure of a command.
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    onCommand(ExecutionInfos executionInfo)
    Invoked when a command is executed, providing an opportunity for registered observers to perform synchronous post-execution treatments based on the command's execution information.
  • Method Details

    • onCommand

      void onCommand(ExecutionInfos executionInfo)
      Invoked when a command is executed, providing an opportunity for registered observers to perform synchronous post-execution treatments based on the command's execution information.

      Implementers should define the logic within this method to handle the command execution event, utilizing the ExecutionInfos provided to access details about the command's execution context, results, and status. This method is called synchronously, ensuring that any processing here is completed before the command execution flow continues.

      Parameters:
      executionInfo - The ExecutionInfos containing detailed information about the executed command, including execution context, results, and any errors or warnings that occurred.