- All Implemented Interfaces:
RemoteResource
,Loadable
- Direct Known Subclasses:
ArcGISStreamService
The DynamicEntityDataSource class is the base class for classes that stream dynamic entity data. The class provides methods and properties that allow:
- maintenance of a persistent connection for streaming
- control over the storage of observations in its local data cache
- notification of received or purged observations
DynamicEntityLayer
.- Since:
- 200.1.0
- See Also:
-
Property Summary
TypePropertyDescriptionThe current network connectionArcGISRuntimeException
.The current network connection status of the DynamicEntityDataSource.The load error.final ReadOnlyObjectProperty
<LoadStatus> The load status.final IntegerProperty
The maximum number of attempts to reconnect after a connection fails.ADynamicEntityDataSourcePurgeOptions
that defines when observations are purged from the local data cache.final DoubleProperty
The time (in seconds) to wait between attempts to reconnect. -
Nested Class Summary
Modifier and TypeClassDescriptionstatic final class
A notification that aDynamicEntityObservation
was purged from the local data cache.static interface
Defines the callback listener to listen to DynamicEntityObservationPurgedListener events.static final class
A notification that aDynamicEntityObservation
was received from the data source.static interface
Defines the callback listener to listen toDynamicEntityDataSource.DynamicEntityObservationReceivedEvent
events.static final class
A notification that aDynamicEntity
was purged from the local data cache.static interface
Defines the callback listener to listen to DynamicEntityPurgedListener events.static final class
A notification that aDynamicEntity
was received from the data source.static interface
Defines the callback listener to listen to DynamicEntityReceivedListener events. -
Constructor Summary
ModifierConstructorDescriptionprotected
No argument constructor to avoid custom dynamic entity data sources having to define a no argument constructor. -
Method Summary
Modifier and TypeMethodDescriptionfinal void
addDoneLoadingListener
(Runnable runner) Adds a listener to the loadable resource that is invoked when loading has completed.final void
addDynamicEntityObservationPurgedListener
(DynamicEntityDataSource.DynamicEntityObservationPurgedListener listener) Registers the given DynamicEntityObservationPurgedListener to be called when an update is received from the DynamicEntityDataSource.final void
addDynamicEntityObservationReceivedListener
(DynamicEntityDataSource.DynamicEntityObservationReceivedListener listener) Registers the given listener to be called when an update is received from the DynamicEntityDataSource.final void
Registers the given DynamicEntityPurgedListener to be called when an update is received from the DynamicEntityDataSource.final void
Registers the given DynamicEntityReceivedListener to be called when an update is received from the DynamicEntityDataSource.final void
Adds aLoadStatusChangedListener
to the loadable resource that is invoked whenever the load status changes.protected final void
addObservation
(Geometry geometry, Map<String, Object> attributes) Adds or updates the newly-received observation data in the data source store.final void
Cancels loading metadata for the object.final ListenableFuture
<Void> Connects to a service that provides dynamic entity observations.The current network connectionArcGISRuntimeException
.The current network connection status of the DynamicEntityDataSource.final ListenableFuture
<Void> deleteEntityAsync
(String entityId) Deletes the dynamic entity identified by the id value from the data source store.final ListenableFuture
<Void> Closes the connection to a service.final ArcGISRuntimeException
Gets the value of theconnectionError
property.final ConnectionStatus
Gets the value of theconnectionStatus
property.final Credential
Gets theCredential
that is set on the network-enabled resource.final ArcGISRuntimeException
Gets the value of theloadError
property.final LoadStatus
Gets the value of theloadStatus
property.final int
Gets the value of themaximumReconnectionAttempts
property.Gets the value of thepurgeOptions
property.final double
Gets the value of thereconnectionInterval
property.final RequestConfiguration
Gets theRequestConfiguration
used to modify the parameters of network requests made by thisRemoteResource
.final void
Loads the metadata of the loadable resource asynchronously.The load error.final ReadOnlyObjectProperty
<LoadStatus> The load status.final IntegerProperty
The maximum number of attempts to reconnect after a connection fails.protected abstract CompletableFuture
<Void> Handles the connection process of a data source.protected abstract CompletableFuture
<Void> Handles the disconnection process of a data source.protected abstract CompletableFuture
<DynamicEntityDataSourceInfo> Handles the loading process of a data source and returnsDynamicEntityDataSourceInfo
.final ListenableFuture
<Void> Removes all dynamic entity observations from the in-memory data cache as well as from the map or scene.ADynamicEntityDataSourcePurgeOptions
that defines when observations are purged from the local data cache.final DoubleProperty
The time (in seconds) to wait between attempts to reconnect.final boolean
removeDoneLoadingListener
(Runnable runner) Removes a done loading listener from the loadable resource.final boolean
removeDynamicEntityObservationPurgedListener
(DynamicEntityDataSource.DynamicEntityObservationPurgedListener listener) Unregisters the given DynamicEntityObservationPurgedListener that was previously added usingaddDynamicEntityObservationPurgedListener(DynamicEntityObservationPurgedListener)
.final boolean
removeDynamicEntityObservationReceivedListener
(DynamicEntityDataSource.DynamicEntityObservationReceivedListener listener) Unregisters the given listener that was previously added usingaddDynamicEntityObservationReceivedListener(DynamicEntityObservationReceivedListener)
.final boolean
Unregisters the given DynamicEntityPurgedListener that was previously added usingaddDynamicEntityPurgedListener(DynamicEntityPurgedListener)
.final boolean
Unregisters the given DynamicEntityReceivedListener that was previously added usingaddDynamicEntityReceivedListener(DynamicEntityReceivedListener)
.final boolean
Removes aLoadStatusChangedListener
from the loadable resource.final void
Loads or retries loading metadata for the object asynchronously.protected final void
setConnectionFailed
(Throwable error, boolean reconnect) Handles the error when the connection fails and may attempt to reconnect.final void
setCredential
(Credential credential) Sets aCredential
to be used by the network-enabled resource in the event of an authentication challenge.final void
setMaximumReconnectionAttempts
(int maximumReconnectionAttempts) Sets the value of themaximumReconnectionAttempts
property.final void
setReconnectionInterval
(double reconnectionInterval) Sets the value of thereconnectionInterval
property.final void
setRequestConfiguration
(RequestConfiguration requestConfiguration) Sets theRequestConfiguration
used to modify the parameters of network requests made by thisRemoteResource
.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface com.esri.arcgisruntime.io.RemoteResource
getUri
-
Property Details
-
connectionError
The current network connectionArcGISRuntimeException
.This property is null until an attempt to connect the data source is made. If a connection attempt succeeds, this property is set to null. If a connection fails, this property contains the platform-specific error.
If
maximumReconnectionAttemptsProperty()
is greater than 0, this property will contain the exception that caused the data source to lose the connection.- Since:
- 200.1.0
- See Also:
-
connectionStatus
The current network connection status of the DynamicEntityDataSource.This property contains the state of the connection throughout the lifetime of the data source. The initial value of this property is
ConnectionStatus.DISCONNECTED
.- Since:
- 200.1.0
- See Also:
-
maximumReconnectionAttempts
The maximum number of attempts to reconnect after a connection fails.This property informs the data source to attempt reconnection if a connection is lost. When a connection fails, the data source attempts to reconnect the specified number of times waiting
reconnectionIntervalProperty()
between attempts.If reconnection fails on the final attempt,
connectionStatusProperty()
is set toConnectionStatus.FAILED
and theconnectionErrorProperty()
is set to the platform specific connection error.The default value is 12. The first 2 connection attempts are made without waiting the specified
DynamicEntityDataSource.reconnectionIntervalProperty()
between attempts.- Since:
- 200.1.0
- See Also:
-
purgeOptions
ADynamicEntityDataSourcePurgeOptions
that defines when observations are purged from the local data cache.Data received from the DynamicEntityDataSource is stored in memory on the client and can grow quickly depending on the number of dynamic entities and frequency of updates. If purge options are not set appropriately, a data source may store too many observations in its local data cache and cause performance and memory issues for the application. Use the property to control app data storage for the local cache.
This property must be set before loading the data source and cannot be changed once the data source is loaded.
By default, purge options are set to remove observations from the data cache when a maximum limit of 100,000 observations is reached.
Note that you can clear all observations from the cache using
purgeAllAsync()
. This clears all data from the local data cache, but does not disconnect from the stream. Dynamic entities and observations will continue to be added to the local data cache as they come from the stream.- Since:
- 200.1.0
- See Also:
-
reconnectionInterval
The time (in seconds) to wait between attempts to reconnect.This property sets the amount of time delay between reconnection attempts after a connection fails. The default value is 10 seconds.
- Since:
- 200.1.0
- See Also:
-
loadStatus
- Specified by:
loadStatusProperty
in interfaceLoadable
- See Also:
-
loadError
- Specified by:
loadErrorProperty
in interfaceLoadable
- See Also:
-
-
Constructor Details
-
DynamicEntityDataSource
protected DynamicEntityDataSource()No argument constructor to avoid custom dynamic entity data sources having to define a no argument constructor.- Since:
- 200.2.0
-
-
Method Details
-
connectionErrorProperty
The current network connectionArcGISRuntimeException
.This property is null until an attempt to connect the data source is made. If a connection attempt succeeds, this property is set to null. If a connection fails, this property contains the platform-specific error.
If
maximumReconnectionAttemptsProperty()
is greater than 0, this property will contain the exception that caused the data source to lose the connection.- Returns:
- the
connectionError
property - Since:
- 200.1.0
- See Also:
-
getConnectionError
Gets the value of theconnectionError
property.- Property description:
- The current network connection
ArcGISRuntimeException
.This property is null until an attempt to connect the data source is made. If a connection attempt succeeds, this property is set to null. If a connection fails, this property contains the platform-specific error.
If
maximumReconnectionAttemptsProperty()
is greater than 0, this property will contain the exception that caused the data source to lose the connection. - Returns:
- the value of the
connectionError
property - Since:
- 200.1.0
- See Also:
-
connectionStatusProperty
The current network connection status of the DynamicEntityDataSource.This property contains the state of the connection throughout the lifetime of the data source. The initial value of this property is
ConnectionStatus.DISCONNECTED
.- Returns:
- the
connectionStatus
property - Since:
- 200.1.0
- See Also:
-
getConnectionStatus
Gets the value of theconnectionStatus
property.- Property description:
- The current network connection status of the DynamicEntityDataSource.
This property contains the state of the connection throughout the lifetime of the data source. The initial value of this property is
ConnectionStatus.DISCONNECTED
. - Returns:
- the value of the
connectionStatus
property - Since:
- 200.1.0
- See Also:
-
maximumReconnectionAttemptsProperty
The maximum number of attempts to reconnect after a connection fails.This property informs the data source to attempt reconnection if a connection is lost. When a connection fails, the data source attempts to reconnect the specified number of times waiting
reconnectionIntervalProperty()
between attempts.If reconnection fails on the final attempt,
connectionStatusProperty()
is set toConnectionStatus.FAILED
and theconnectionErrorProperty()
is set to the platform specific connection error.The default value is 12. The first 2 connection attempts are made without waiting the specified
DynamicEntityDataSource.reconnectionIntervalProperty()
between attempts.- Returns:
- the
maximumReconnectionAttempts
property - Since:
- 200.1.0
- See Also:
-
getMaximumReconnectionAttempts
public final int getMaximumReconnectionAttempts()Gets the value of themaximumReconnectionAttempts
property.- Property description:
- The maximum number of attempts to reconnect after a connection fails.
This property informs the data source to attempt reconnection if a connection is lost. When a connection fails, the data source attempts to reconnect the specified number of times waiting
reconnectionIntervalProperty()
between attempts.If reconnection fails on the final attempt,
connectionStatusProperty()
is set toConnectionStatus.FAILED
and theconnectionErrorProperty()
is set to the platform specific connection error.The default value is 12. The first 2 connection attempts are made without waiting the specified
DynamicEntityDataSource.reconnectionIntervalProperty()
between attempts. - Returns:
- the value of the
maximumReconnectionAttempts
property - Since:
- 200.1.0
- See Also:
-
setMaximumReconnectionAttempts
public final void setMaximumReconnectionAttempts(int maximumReconnectionAttempts) Sets the value of themaximumReconnectionAttempts
property.- Property description:
- The maximum number of attempts to reconnect after a connection fails.
This property informs the data source to attempt reconnection if a connection is lost. When a connection fails, the data source attempts to reconnect the specified number of times waiting
reconnectionIntervalProperty()
between attempts.If reconnection fails on the final attempt,
connectionStatusProperty()
is set toConnectionStatus.FAILED
and theconnectionErrorProperty()
is set to the platform specific connection error.The default value is 12. The first 2 connection attempts are made without waiting the specified
DynamicEntityDataSource.reconnectionIntervalProperty()
between attempts. - Parameters:
maximumReconnectionAttempts
- the value for themaximumReconnectionAttempts
property- Since:
- 200.1.0
- See Also:
-
purgeOptionsProperty
ADynamicEntityDataSourcePurgeOptions
that defines when observations are purged from the local data cache.Data received from the DynamicEntityDataSource is stored in memory on the client and can grow quickly depending on the number of dynamic entities and frequency of updates. If purge options are not set appropriately, a data source may store too many observations in its local data cache and cause performance and memory issues for the application. Use the property to control app data storage for the local cache.
This property must be set before loading the data source and cannot be changed once the data source is loaded.
By default, purge options are set to remove observations from the data cache when a maximum limit of 100,000 observations is reached.
Note that you can clear all observations from the cache using
purgeAllAsync()
. This clears all data from the local data cache, but does not disconnect from the stream. Dynamic entities and observations will continue to be added to the local data cache as they come from the stream.- Returns:
- the
purgeOptions
property - Since:
- 200.1.0
- See Also:
-
getPurgeOptions
Gets the value of thepurgeOptions
property.- Property description:
- A
DynamicEntityDataSourcePurgeOptions
that defines when observations are purged from the local data cache.Data received from the DynamicEntityDataSource is stored in memory on the client and can grow quickly depending on the number of dynamic entities and frequency of updates. If purge options are not set appropriately, a data source may store too many observations in its local data cache and cause performance and memory issues for the application. Use the property to control app data storage for the local cache.
This property must be set before loading the data source and cannot be changed once the data source is loaded.
By default, purge options are set to remove observations from the data cache when a maximum limit of 100,000 observations is reached.
Note that you can clear all observations from the cache using
purgeAllAsync()
. This clears all data from the local data cache, but does not disconnect from the stream. Dynamic entities and observations will continue to be added to the local data cache as they come from the stream. - Returns:
- the value of the
purgeOptions
property - Since:
- 200.1.0
- See Also:
-
reconnectionIntervalProperty
The time (in seconds) to wait between attempts to reconnect.This property sets the amount of time delay between reconnection attempts after a connection fails. The default value is 10 seconds.
- Returns:
- the
reconnectionInterval
property - Since:
- 200.1.0
- See Also:
-
getReconnectionInterval
public final double getReconnectionInterval()Gets the value of thereconnectionInterval
property.- Property description:
- The time (in seconds) to wait between attempts to reconnect.
This property sets the amount of time delay between reconnection attempts after a connection fails. The default value is 10 seconds.
- Returns:
- the value of the
reconnectionInterval
property - Since:
- 200.1.0
- See Also:
-
setReconnectionInterval
public final void setReconnectionInterval(double reconnectionInterval) Sets the value of thereconnectionInterval
property.- Property description:
- The time (in seconds) to wait between attempts to reconnect.
This property sets the amount of time delay between reconnection attempts after a connection fails. The default value is 10 seconds.
- Parameters:
reconnectionInterval
- the value for thereconnectionInterval
property- Since:
- 200.1.0
- See Also:
-
addObservation
Adds or updates the newly-received observation data in the data source store.- Parameters:
geometry
- geometry of the associated observation. Only data sources that send point geometries are supported. Can be null.attributes
- the attributes of the associated observation. Can be null.- Since:
- 200.2.0
-
connectAsync
Connects to a service that provides dynamic entity observations.Data does not start streaming from the dynamic entity data source until it's loaded and connected. Once the connection is successfully established, data begins to flow from the stream.
Use this method to explicitly connect to the data source. This call loads the data source if it is not already loaded and then initiates a persistent connection to the service that provides the observation stream. When this method completes, the
connectionStatusProperty()
is set to connected or failed.Note that a data source connection is initiated implicitly if the data source is contained by a
DynamicEntityLayer
and added to a map or scene.- Returns:
- a
ListenableFuture
that has no return value - Since:
- 200.1.0
-
deleteEntityAsync
Deletes the dynamic entity identified by the id value from the data source store.- Parameters:
entityId
- the value of the unique id field identifying an entity. For example, a track id field value for track-aware data or an object id value for discrete data.- Returns:
- a
ListenableFuture
that has no return value - Throws:
NullPointerException
- if entityId is null- Since:
- 200.2.0
-
disconnectAsync
Closes the connection to a service.Use this method to explicitly disconnect from a data source. When this method completes, the
connectionStatusProperty()
is set to disconnected or failed.If this method is called when a data source has a
DynamicEntityDataSource.ConnectionStatusProperty()
of connecting, the current connection attempt is cancelled.- Returns:
- a
ListenableFuture
that has no return value - Since:
- 200.1.0
-
onConnectAsync
Handles the connection process of a data source.Override this method to perform operations that initiate a connection and start the flow of data from an underlying data source. For instance, operations like connecting a websocket, opening a source file, or starting a polling timer are all operations that may be performed in this method.
This method is called by the ArcGIS Maps SDK when the connection is required. This can be due to an explicit call to
connectAsync()
or called implicitly when a layer that contains the data source needs to be rendered.The completable future should complete exceptionally if the connect operation fails. The exception is passed back to the data source and is available in the
connectionErrorProperty()
property.If
disconnectAsync()
is called when aconnectAsync()
is in progress the future returned here will be cancelled by completing exceptionally with aCancellationException
. The implementation ofonConnectAsync()
should check for cancellation when the future completes and take any necessary action, for example, releasing resources.- Returns:
- a
CompletableFuture
that handles the connection process of a data source - Since:
- 200.2.0
-
onDisconnectAsync
Handles the disconnection process of a data source.Override this method to perform operations that stop the flow of data from an underlying data source.
If a
connectAsync()
is in progress when this method is called the future returned byonConnectAsync()
will be cancelled by completing exceptionally.- Returns:
- a
CompletableFuture
that handles the disconnection process of a data source - Since:
- 200.2.0
-
onLoadAsync
Handles the loading process of a data source and returnsDynamicEntityDataSourceInfo
.Override this method to populate and return a
DynamicEntityDataSourceInfo
object. This object defines the schema and metadata used by the internal data cache of the DynamicEntityDataSource. If the returnedDynamicEntityDataSourceInfo
object does not contain all required values, the data source will fail to load and will not be usable.This method is called by the ArcGIS Maps SDK when loading is required. This can be due to an explicit call to load the data source using
Loadable.loadAsync()
or called implicitly when a layer that contains the data source needs to be rendered.The completable future should complete exceptionally if the load operation fails. The exception is passed back to the data source and is available in the
loadErrorProperty()
property.- Returns:
- a
CompletableFuture
that returns aDynamicEntityDataSourceInfo
- Since:
- 200.2.0
-
purgeAllAsync
Removes all dynamic entity observations from the in-memory data cache as well as from the map or scene.Sometimes, a large number of dynamic entity observations can crowd the display and make information hard to interpret. Use this method to clear (purge) all dynamic entity observations to remove stale information and limit the amount of memory consumed. This does not disconnect you from the service, so new dynamic entity observations continue to display as they become available.
The following DynamicEntityDataSource events will not be raised due to a call to this method:
- Returns:
- a
ListenableFuture
that has no return value - Since:
- 200.1.0
-
setConnectionFailed
Handles the error when the connection fails and may attempt to reconnect.Use this method when an established connection has failed. Pass the exception that caused the connection to fail and a flag that indicates whether to attempt reconnection.
This method should only be used on an established connection, or when
connectionStatusProperty()
isConnectionStatus.CONNECTED
. It should not be used when attempting to create an initial connection duringonConnectAsync()
.- Parameters:
error
- the error that was encountered during connection failurereconnect
- indicates whether reconnection should be attempted after failure- Throws:
NullPointerException
- if error is null- Since:
- 200.2.0
-
addDynamicEntityObservationPurgedListener
public final void addDynamicEntityObservationPurgedListener(DynamicEntityDataSource.DynamicEntityObservationPurgedListener listener) Registers the given DynamicEntityObservationPurgedListener to be called when an update is received from the DynamicEntityDataSource.Adding this listener on the UI thread will cause it to be invoked on the UI thread, otherwise it is not guaranteed on which thread the listener is invoked.
- Parameters:
listener
- the listener to register- Throws:
NullPointerException
- if the DynamicEntityObservationPurgedListener is null- Since:
- 200.1.0
- See Also:
-
removeDynamicEntityObservationPurgedListener
public final boolean removeDynamicEntityObservationPurgedListener(DynamicEntityDataSource.DynamicEntityObservationPurgedListener listener) Unregisters the given DynamicEntityObservationPurgedListener that was previously added usingaddDynamicEntityObservationPurgedListener(DynamicEntityObservationPurgedListener)
.- Parameters:
listener
- the listener to unregister- Returns:
- true if the listener was successfully removed; false otherwise
- Since:
- 200.1.0
-
addDynamicEntityObservationReceivedListener
public final void addDynamicEntityObservationReceivedListener(DynamicEntityDataSource.DynamicEntityObservationReceivedListener listener) Registers the given listener to be called when an update is received from the DynamicEntityDataSource.Adding this listener on the UI thread will cause it to be invoked on the UI thread, otherwise it is not guaranteed on which thread the listener is invoked.
- Parameters:
listener
- the listener to register- Throws:
IllegalArgumentException
- if the listener is null- Since:
- 200.1.0
- See Also:
-
removeDynamicEntityObservationReceivedListener
public final boolean removeDynamicEntityObservationReceivedListener(DynamicEntityDataSource.DynamicEntityObservationReceivedListener listener) Unregisters the given listener that was previously added usingaddDynamicEntityObservationReceivedListener(DynamicEntityObservationReceivedListener)
.- Parameters:
listener
- the listener to unregister- Returns:
- true if the listener was successfully removed; false otherwise
- Since:
- 200.1.0
-
addDynamicEntityPurgedListener
public final void addDynamicEntityPurgedListener(DynamicEntityDataSource.DynamicEntityPurgedListener listener) Registers the given DynamicEntityPurgedListener to be called when an update is received from the DynamicEntityDataSource.Adding this listener on the UI thread will cause it to be invoked on the UI thread, otherwise it is not guaranteed on which thread the listener is invoked.
- Parameters:
listener
- the listener to register- Throws:
NullPointerException
- if the DynamicEntityPurgedListener is null- Since:
- 200.1.0
- See Also:
-
removeDynamicEntityPurgedListener
public final boolean removeDynamicEntityPurgedListener(DynamicEntityDataSource.DynamicEntityPurgedListener listener) Unregisters the given DynamicEntityPurgedListener that was previously added usingaddDynamicEntityPurgedListener(DynamicEntityPurgedListener)
.- Parameters:
listener
- the listener to unregister- Returns:
- true if the listener was successfully removed; false otherwise
- Since:
- 200.1.0
-
addDynamicEntityReceivedListener
public final void addDynamicEntityReceivedListener(DynamicEntityDataSource.DynamicEntityReceivedListener listener) Registers the given DynamicEntityReceivedListener to be called when an update is received from the DynamicEntityDataSource.Adding this listener on the UI thread will cause it to be invoked on the UI thread, otherwise it is not guaranteed on which thread the listener is invoked.
- Parameters:
listener
- the listener to register- Throws:
NullPointerException
- if the DynamicEntityReceivedListener is null- Since:
- 200.1.0
- See Also:
-
removeDynamicEntityReceivedListener
public final boolean removeDynamicEntityReceivedListener(DynamicEntityDataSource.DynamicEntityReceivedListener listener) Unregisters the given DynamicEntityReceivedListener that was previously added usingaddDynamicEntityReceivedListener(DynamicEntityReceivedListener)
.- Parameters:
listener
- the listener to unregister- Returns:
- true if the listener was successfully removed; false otherwise
- Since:
- 200.1.0
-
getLoadError
Gets the value of theloadError
property.- Specified by:
getLoadError
in interfaceLoadable
- Property description:
- Returns:
- the value of the
loadError
property - See Also:
-
getLoadStatus
Gets the value of theloadStatus
property.- Specified by:
getLoadStatus
in interfaceLoadable
- Property description:
- Returns:
- the value of the
loadStatus
property - See Also:
-
cancelLoad
public final void cancelLoad()Description copied from interface:Loadable
Cancels loading metadata for the object.Cancels loading the metadata if the object is loading, and always invokes the done loading listener.
A load operation that is in progress (
LoadStatus.LOADING
state) can be cancelled by calling this method and the resource will transition fromLoadStatus.LOADING
toLoadStatus.FAILED_TO_LOAD
state. If the load operation was successfully cancelled, a CancellationException will be returned fromLoadable.getLoadError()
.Cancellation should be used carefully because all enqueued done loading listeners for that resource instance will get invoked with an error stating that the operation was cancelled. Thus, one component in the application can cancel the load operation initiated by other components.
This method does nothing if the resource is not in
LoadStatus.LOADING
state.- Specified by:
cancelLoad
in interfaceLoadable
-
loadAsync
public final void loadAsync()Description copied from interface:Loadable
Loads the metadata of the loadable resource asynchronously.The load status changes from
LoadStatus.NOT_LOADED
toLoadStatus.LOADING
. A listener can be added viaLoadable.addDoneLoadingListener(java.lang.Runnable)
that is invoked upon completion of the asynchronous load operation.If the load operation completes successfully, the load status will be
LoadStatus.LOADED
, which means the resource has loaded its metadata.If the load operation failed, the load status will be
LoadStatus.FAILED_TO_LOAD
and the error can be retrieved by callingLoadable.getLoadError()
.This method can be called concurrently and repeatedly, but only one attempt is ever made to perform the load operation. If a load operation is already in progress (
LoadStatus.LOADING
state) whenloadAsync
is called, it simply piggy-backs on the outstanding operation and the done loading listener added to the loadable resource is enqueued to be invoked when that operation completes. If the operation has already completed (LoadStatus.LOADED
orLoadStatus.FAILED_TO_LOAD
state) whenloadAsync
is called, the done loading listener is immediately invoked when added to the loadable resource.If a loadable resource has failed to load, calling
loadAsync
on it subsequently will not change its state. The done loading listener will be invoked immediately when added to the loadable resource. In order to retry loading the resource,Loadable.retryLoadAsync()
needs to be used.A load operation that is in progress (
LoadStatus.LOADING
state) can be cancelled by callingLoadable.cancelLoad()
. -
retryLoadAsync
public final void retryLoadAsync()Description copied from interface:Loadable
Loads or retries loading metadata for the object asynchronously.Will retry loading the metadata if the object's load status is
LoadStatus.FAILED_TO_LOAD
. Will load the object if it is not loaded. Will not retry to load the object if the object is loaded.For more details on the load process see
Loadable.loadAsync()
.- Specified by:
retryLoadAsync
in interfaceLoadable
-
addDoneLoadingListener
Description copied from interface:Loadable
Adds a listener to the loadable resource that is invoked when loading has completed.The listener may be added at any point, whether the loadable resource has already completed loading or not.
- For resources that are not loaded when the listener is added (LoadStatus is NOT_LOADED or LOADING): When the resource completes loading, the listener will be invoked on the UI thread if it is added from the UI thread, otherwise it is not guaranteed on which thread the listener is invoked.
- For resources that are already loaded when the listener is added (LoadStatus is LOADED or FAILED_TO_LOAD): The listener will be called immediately, on the current thread.
Alternatively, to be notified when there is any change in the load status, add a listener to the
Loadable.loadStatusProperty()
instead.- Specified by:
addDoneLoadingListener
in interfaceLoadable
- Parameters:
runner
- a Runnable that is invoked upon completion of the load operation
-
removeDoneLoadingListener
Description copied from interface:Loadable
Removes a done loading listener from the loadable resource.- Specified by:
removeDoneLoadingListener
in interfaceLoadable
- Parameters:
runner
- the listener to be removed- Returns:
- true if the listener was removed, otherwise false
-
addLoadStatusChangedListener
Description copied from interface:Loadable
Adds aLoadStatusChangedListener
to the loadable resource that is invoked whenever the load status changes.Adding this listener on the UI thread will cause it to be invoked on the UI thread, otherwise it is not guaranteed on which thread the listener is invoked.
The listener will not be called if added to a loadable resource that has already completed loading. To be notified when a loadable resource has completed loading, including if the resource is already loaded when the listener is added, use the
Loadable.addDoneLoadingListener(Runnable)
method.- Specified by:
addLoadStatusChangedListener
in interfaceLoadable
- Parameters:
listener
- theLoadStatusChangedListener
to be added
-
removeLoadStatusChangedListener
Description copied from interface:Loadable
Removes aLoadStatusChangedListener
from the loadable resource.- Specified by:
removeLoadStatusChangedListener
in interfaceLoadable
- Parameters:
listener
- theLoadStatusChangedListener
to be removed- Returns:
- true if the listener was removed, otherwise false
-
loadStatusProperty
Description copied from interface:Loadable
The load status.- Specified by:
loadStatusProperty
in interfaceLoadable
- Returns:
- the
loadStatus
property - See Also:
-
loadErrorProperty
Description copied from interface:Loadable
The load error.- Specified by:
loadErrorProperty
in interfaceLoadable
- Returns:
- the
loadError
property - See Also:
-
getCredential
Description copied from interface:RemoteResource
Gets theCredential
that is set on the network-enabled resource.Only applicable if the resource is secured.
- Specified by:
getCredential
in interfaceRemoteResource
- Returns:
- the Credential, or null if there is none
-
setCredential
Description copied from interface:RemoteResource
Sets aCredential
to be used by the network-enabled resource in the event of an authentication challenge. The default credential is null.Only applicable if the resource is secured.
- Specified by:
setCredential
in interfaceRemoteResource
- Parameters:
credential
- the Credential to be used for authentication
-
setRequestConfiguration
Description copied from interface:RemoteResource
Sets theRequestConfiguration
used to modify the parameters of network requests made by thisRemoteResource
. If not set, the globalRequestConfiguration
will be used (seeRequestConfiguration.getGlobalRequestConfiguration()
).- Specified by:
setRequestConfiguration
in interfaceRemoteResource
- Parameters:
requestConfiguration
- the RequestConfiguration used to modify network requests
-
getRequestConfiguration
Description copied from interface:RemoteResource
Gets theRequestConfiguration
used to modify the parameters of network requests made by thisRemoteResource
.- Specified by:
getRequestConfiguration
in interfaceRemoteResource
- Returns:
- the
RequestConfiguration
used to modify network requests
-