Interface StreamTemplate<T>

Type Parameters:
T - The stream content type

public interface StreamTemplate<T>
A template for stream queries, like JDBCTemplate and friends. We need to wrap access to the stream with a tx-span, a try-with-resources block, and RequestDetails.
  • Method Summary

    Modifier and Type
    Method
    Description
    <R> R
    call(Function<Stream<T>,R> theCallback)
     
    static <ST> StreamTemplate<ST>
    fromSupplier(Supplier<Stream<ST>> theStreamQuery)
    Wrap the supplied stream as a StreamTemplate in a try-with-resources block to ensure it is closed.
    default StreamTemplate<T>
    withTransactionAdvice(org.springframework.transaction.support.TransactionOperations theTxBuilder)
    Wrap this template with a transaction boundary.
  • Method Details

    • call

      @Nullable <R> R call(@Nonnull Function<Stream<T>,R> theCallback)
    • withTransactionAdvice

      default StreamTemplate<T> withTransactionAdvice(org.springframework.transaction.support.TransactionOperations theTxBuilder)
      Wrap this template with a transaction boundary. Our dao Stream methods require an active Hibernate session for the duration of the Stream. This advice uses a tx boundary to ensure that active session.
      Parameters:
      theTxBuilder - the transaction and partition settings
      Returns:
      the wrapped template
    • fromSupplier

      static <ST> StreamTemplate<ST> fromSupplier(Supplier<Stream<ST>> theStreamQuery)
      Wrap the supplied stream as a StreamTemplate in a try-with-resources block to ensure it is closed.
      Parameters:
      theStreamQuery - the query to run
      Returns:
      a template that will always close the Stream on exit.