Class ProcessingBufferInterceptor

java.lang.Object
ai.pipestream.common.interceptor.ProcessingBufferInterceptor

@Interceptor @Priority(2100) public class ProcessingBufferInterceptor extends Object
Interceptor that automatically captures processing output to buffers based on @ProcessingBuffered annotation.

This interceptor: 1. Intercepts methods annotated with @ProcessingBuffered 2. Creates and manages ProcessingBuffer instances based on configuration 3. Automatically captures output documents from ProcessResponse when enabled 4. Provides seamless integration without manual buffer management

Configuration is resolved from annotation parameters, supporting config expressions. Buffers are created lazily and cached per method to avoid recreation overhead.

  • Constructor Details

    • ProcessingBufferInterceptor

      public ProcessingBufferInterceptor()
  • Method Details

    • captureProcessingOutput

      public Object captureProcessingOutput(jakarta.interceptor.InvocationContext context) throws Exception
      Intercepts method calls annotated with @ProcessingBuffered.
      Parameters:
      context - The invocation context containing method and parameters
      Returns:
      The original method result, with buffer capture as a side effect
      Throws:
      Exception - If the original method throws an exception
    • getBuffer

      public static ProcessingBuffer<ai.pipestream.data.v1.PipeDoc> getBuffer(String methodKey)
      Gets the buffer for a specific method, if it exists.
      Parameters:
      methodKey - The method key in format "ClassName.methodName"
      Returns:
      The buffer for the method, or null if not found
    • getBuffer

      public static ProcessingBuffer<ai.pipestream.data.v1.PipeDoc> getBuffer(String className, String methodName)
      Gets the buffer for a specific class and method name.
      Parameters:
      className - The simple class name
      methodName - The method name
      Returns:
      The buffer for the method, or null if not found
    • getActiveBufferKeys

      public static Set<String> getActiveBufferKeys()
      Gets all active buffer keys (method identifiers).
      Returns:
      Set of all method keys that have active buffers
    • getTotalCapturedDocuments

      public static int getTotalCapturedDocuments()
      Gets the total number of documents across all buffers.
      Returns:
      Total count of captured documents
    • saveAllBuffers

      public static void saveAllBuffers()
      Saves all buffers to disk using their configured directories and prefixes. This is a future trigger capability for batch saving.
    • saveBuffer

      public static boolean saveBuffer(String methodKey)
      Saves a specific buffer to disk.
      Parameters:
      methodKey - The method key identifying the buffer
      Returns:
      true if buffer was found and saved, false otherwise
    • clearAllBuffers

      public static void clearAllBuffers()
      Clears all buffers. Useful for testing or memory management.
    • getBufferStatistics

      public static Map<String,Integer> getBufferStatistics()
      Gets buffer statistics for monitoring.
      Returns:
      Map of method keys to buffer sizes