Package com.streamconverter.command
Class ContextPropagatingDecorator
java.lang.Object
com.streamconverter.command.ContextPropagatingDecorator
- All Implemented Interfaces:
IStreamCommand
既存のIStreamCommandをコンテキスト対応にするデコレータ
このデコレータは既存のコマンドを変更することなく、 ExecutionContextの適用とMDCの設定を自動化します。
-
Constructor Summary
ConstructorsConstructorDescriptionデコレータを作成ContextPropagatingDecorator
(IStreamCommand command, String commandName) デコレータを作成(カスタムコマンド名付き) -
Method Summary
Modifier and TypeMethodDescriptionvoid
execute
(InputStream inputStream, OutputStream outputStream) Executes the command on the provided input stream and writes the result to the output stream.void
execute
(InputStream inputStream, OutputStream outputStream, ExecutionContext context) Executes the command with ExecutionContext support for enhanced traceability.コマンド名を取得ラップされたコマンドを取得toString()
-
Constructor Details
-
ContextPropagatingDecorator
デコレータを作成- Parameters:
command
- ラップするコマンド
-
ContextPropagatingDecorator
デコレータを作成(カスタムコマンド名付き)- Parameters:
command
- ラップするコマンドcommandName
- ログ用のコマンド名
-
-
Method Details
-
execute
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 interfaceIStreamCommand
- 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 interfaceIStreamCommand
- 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
-