Class BackgroundDataProvider<IDType,RightType>
- Type Parameters:
IDType- the type of the request ID of the underlying access managerRightType- the type of the rights handled by the underlying access manager
AsyncDataQuery and
AsyncDataLink instances which only provides data until a requested
AccessToken is available.
Every BackgroundDataProvider has an associated AccessManager
and data requested from a data query or data link created by the
BackgroundDataProvider will be provided in the context of an
access token of the associated access manager. That is, the
onDataArrive(DataType) method
of the listeners will be called in the context of the access token. Both the
onDataArrive and the onDoneReceive method is called from the
UI Thread.
Thread safety
Methods of this class are safe to be accessed from multiple threads concurrently.Synchronization transparency
Methods of this class are synchronization transparent but they are non-blocking quick methods allowed to be called from the UI thread.-
Constructor Summary
ConstructorsConstructorDescriptionBackgroundDataProvider(AccessManager<IDType, RightType> accessManager, UiExecutorProvider uiExecutorProvider) Creates a newBackgroundDataProviderwith the givenAccessManager. -
Method Summary
Modifier and TypeMethodDescription<DataType> AsyncDataLink<DataType>createLink(AccessRequest<? extends IDType, ? extends RightType> request, AsyncDataLink<DataType> wrappedLink) Creates anAsyncDataLinkwhich forwards every requested to the specifiedAsyncDataLinkbut delivers the retrieved data in the context of an access token of the access manager of thisBackgroundDataProviderand also on the UI thread.<QueryArgType,DataType>
AsyncDataQuery<QueryArgType,DataType> createQuery(AccessRequest<? extends IDType, ? extends RightType> request, AsyncDataQuery<QueryArgType, DataType> wrappedQuery) Creates anAsyncDataQuerywhich forwards every requested to the specifiedAsyncDataQuerybut delivers the retrieved data in the context of an access token of the access manager of thisBackgroundDataProvider.
-
Constructor Details
-
BackgroundDataProvider
public BackgroundDataProvider(AccessManager<IDType, RightType> accessManager, UiExecutorProvider uiExecutorProvider) Creates a newBackgroundDataProviderwith the givenAccessManager.- Parameters:
accessManager- theAccessManagerfrom which access tokens are requested to transfer data in their context. This argument cannot benull.uiExecutorProvider- a factory to create executors running tasks on the UI thread of the associated UI framework. This argument cannot benull.- Throws:
NullPointerException- thrown if the specified access manager isnull
-
-
Method Details
-
createQuery
public <QueryArgType,DataType> AsyncDataQuery<QueryArgType,DataType> createQuery(AccessRequest<? extends IDType, ? extends RightType> request, AsyncDataQuery<QueryArgType, DataType> wrappedQuery) Creates anAsyncDataQuerywhich forwards every requested to the specifiedAsyncDataQuerybut delivers the retrieved data in the context of an access token of the access manager of thisBackgroundDataProvider.The returned data query will simply wrap the data links of the specified data query using the
createLinkmethod. So everything what holds for the links created by thecreateLinkholds for the data links of the returned data query.- Type Parameters:
QueryArgType- the type of the input of the queryDataType- the type of the data to be retrieved- Parameters:
request- theAccessRequestused to acquire the required access token in which context the data will be provided. This argument cannot benull.wrappedQuery- theAsyncDataQueryactually used to retrieve the data requested by the returnedAsyncDataQuery. This argument cannot benull.- Returns:
- the
AsyncDataQuerywhich forwards every requested to the specifiedAsyncDataQuerybut delivers the retrieved data in the context of an access token of the access manager of thisBackgroundDataProvider. This method never returnsnull. - Throws:
NullPointerException- thrown if any of the arguments isnull- See Also:
-
createLink
public <DataType> AsyncDataLink<DataType> createLink(AccessRequest<? extends IDType, ? extends RightType> request, AsyncDataLink<DataType> wrappedLink) Creates anAsyncDataLinkwhich forwards every requested to the specifiedAsyncDataLinkbut delivers the retrieved data in the context of an access token of the access manager of thisBackgroundDataProviderand also on the UI thread.The required access token is attempted to be retrieved every time the data is requested (i.e.:
getDatais invoked). In case the access token cannot be acquired, the data transferring is automatically canceled. If the access token can be acquired but the token is released while retrieving the data, the data retrieval process is canceled and no more data will be transfered to the listener. Note however that the wrapped data link may not respond to this cancellation request and may actually continue retrieving data but this retrieved data will not be forwarded to the listener of the data retrieval.The listener is used the following way:
The
onDataArrivemethod is always called in the context of the acquired access token (and therefore the access token will remain acquired at least until theonDataArrivemethod returns.The
onDoneReceivemethod is attempted to be called in the context of the access token. If the access token has been released, theonDoneReceivemethod is called regardless but not from the context of the access token. In this later case, theAsyncReportwill signal that the data retrieval process has been canceled. Therefore if theisCanceled()method of theAsyncReportreturnstrue, theonDoneReceivemethod has been called in the context of the access token (the opposite may not be true).Both of the above mentioned methods are always called from the UI thread.
- Type Parameters:
DataType- the type of the data to be retrieved- Parameters:
request- theAccessRequestused to acquire the required access token in which context the data will be provided. This argument cannot benull.wrappedLink- theAsyncDataLinkactually used to retrieve the data requested by the returnedAsyncDataLink. This argument cannot benull.- Returns:
- the
AsyncDataLinkwhich forwards every requested to the specifiedAsyncDataLinkbut delivers the retrieved data in the context of an access token of the access manager of thisBackgroundDataProvider. This method never returnsnull. - Throws:
NullPointerException- thrown if any of the arguments isnull- See Also:
-