Interface AsyncDataProvider.Loader<T>

Type Parameters:
T - data provider model type
Enclosing class:
AsyncDataProvider<T>
Functional Interface:
This is a functional interface and can therefore be used as the assignment target for a lambda expression or method reference.

@FunctionalInterface public static interface AsyncDataProvider.Loader<T>
Callback interface for asynchronous loading of data for a AsyncDataProvider.
  • Method Summary

    Modifier and Type
    Method
    Description
    Stream<? extends T>
    load(long id)
    Perform a load operation.
  • Method Details

    • load

      Stream<? extends T> load(long id) throws InterruptedException
      Perform a load operation.

      This method runs in a background thread; in particular, no VaadinSession will be locked.

      Note: This method returns a Stream but the Stream is not actually consumed in the background thread; that operation occurs later, in a different thread with the VaadinSession locked. In cases where this matters (e.g., the data is gathered in a per-thread transaction), this method may need to proactively pull the data into memory ahead of time.

      This method should be prepared to handle an interrupt if/when AsyncDataProvider.cancel() is invoked; in that case this method may throw InterruptedException. This method may also cancel itself by throwing an unprompted InterruptedException.

      If this method returns null, the load fails with an IllegalArgumentException.

      Parameters:
      id - unique ID for this load attempt
      Returns:
      stream of data items
      Throws:
      InterruptedException - if the current thread is interrupted
      RuntimeException - if an error occurs during loading