Class AsyncDataProvider<T>

All Implemented Interfaces:
ConfigurableFilterDataProvider<T,SerializablePredicate<T>,SerializablePredicate<T>>, DataProvider<T,SerializablePredicate<T>>, InMemoryDataProvider<T>, Serializable

public class AsyncDataProvider<T> extends ListDataProvider<T>
A ListDataProvider whose contents are gathered in an asynchronous query.

Instances are just a ListDataProvider with support for asynchronous (re)loading of the underlying data in a background thread using an AsyncTaskManager. As a result, the UI never "locks up" while a backend data query executes.

The associated AsyncTaskManager provides status change notifications when a load operation starts, completes, fails, or is canceled. These updates can be used to drive GUI loading spinners, etc.

Load operations are initiated via load(), and may be canceled in progress via cancel(). Initiating a new load operation will cancel and replace any previous load operation still in progress.

All operations are atomic and race free. See AsyncTaskManager for details.

Queries

The DataProvider's fetch() and size() methods take a Query parameter, which includes basic filtering, sorting, and offset/limit information for the query. However, because these methods are synchronous, they not compatible with this class' aynchronous loading model. That's why this class extends ListDataProvider, which applies the Query to a list of objects already loaded into memory by other means. The purpose of this class is therefore simply to refresh that list, aynchronously, when requested.

However, there may be scenarios where the aynchronous load operation can benefit from knowing the Query currently being used, i.e., most recently passed to fetch() or size(). For such scenarios, subclasses could override these methods and trigger a new load operation if the Query has changed, etc.

See Also: