Class ContextPropagatingDecorator

java.lang.Object
com.streamconverter.command.ContextPropagatingDecorator
All Implemented Interfaces:
IStreamCommand

public class ContextPropagatingDecorator extends Object implements IStreamCommand
既存のIStreamCommandをコンテキスト対応にするデコレータ

このデコレータは既存のコマンドを変更することなく、 ExecutionContextの適用とMDCの設定を自動化します。

  • Constructor Details

  • Method Details

    • execute

      public void execute(InputStream inputStream, OutputStream outputStream) throws IOException
      Description copied from interface: IStreamCommand
      Executes the command on the provided input stream and writes the result to the output stream.

      This method maintains backward compatibility for existing implementations. When called without ExecutionContext, a new context will be automatically created by the StreamConverter pipeline.

      Specified by:
      execute in interface IStreamCommand
      Parameters:
      inputStream - The input stream to read data from.
      outputStream - The output stream to write data to.
      Throws:
      IOException - If an I/O error occurs during the execution of the command.
    • execute

      public void execute(InputStream inputStream, OutputStream outputStream, ExecutionContext context) throws IOException
      Description copied from interface: IStreamCommand
      Executes the command with ExecutionContext support for enhanced traceability.

      This is the primary execution method that supports MDC context propagation, execution tracking, and enhanced logging capabilities.

      Specified by:
      execute in interface IStreamCommand
      Parameters:
      inputStream - The input stream to read data from.
      outputStream - The output stream to write data to.
      context - The execution context for traceability and logging enhancement.
      Throws:
      IOException - If an I/O error occurs during the execution of the command.
    • getWrappedCommand

      ラップされたコマンドを取得
      Returns:
      ラップされたコマンド
    • getCommandName

      コマンド名を取得
      Returns:
      コマンド名
    • toString

      public String toString()
      Overrides:
      toString in class Object