public interface LoaderService
URL
s. Initial version are
loaded from the classpath, or other fallback URL.
This class is used for managing/updating/reloading of data sources, e.g. data streams for exchange rates, additional currency data, historical currency data and so on.
Note: this class is implementation specific and not part of the official JSR's API.
Modifier and Type | Interface and Description |
---|---|
static interface |
LoaderService.LoaderListener
Callback that can be registered to be informed, when a data item was
loaded/updated or reset.
|
static class |
LoaderService.UpdatePolicy
Platform RI: The update policy defines how and when the
LoaderService tries to update the local cache with newest version of
the registered data resources, accessing the configured remote
URL s. |
Modifier and Type | Method and Description |
---|---|
void |
addLoaderListener(LoaderService.LoaderListener l,
java.lang.String... resourceIds)
Add a
LoaderService.LoaderListener callback that is informed when a data
resource was update from remote, or reset. |
java.io.InputStream |
getData(java.lang.String resourceId)
Access the input stream of the given data resource.
|
java.util.Set<java.lang.String> |
getResourceIds()
Get a
Set of all registered data resource identifiers. |
java.util.Map<java.lang.String,java.lang.String> |
getUpdateConfiguration(java.lang.String resourceId)
Get the update configuration for the given dataId.
|
LoaderService.UpdatePolicy |
getUpdatePolicy(java.lang.String resourceId)
Get the
LoaderService.UpdatePolicy in place for the given dataId. |
boolean |
isResourceRegistered(java.lang.String resourceId)
Allows to check if a data resource with the given dataId is registered.
|
boolean |
loadData(java.lang.String resourceId)
Explicitly triggers the remote loading of the registered data, regardless
of its current
LoaderService.UpdatePolicy configured. |
java.util.concurrent.Future<java.lang.Boolean> |
loadDataAsync(java.lang.String resourceId)
Explicitly asynchronously triggers the remote loading of the registered
data, regardless of its current
LoaderService.UpdatePolicy configured. |
boolean |
loadDataLocal(java.lang.String resourceId)
Explicitly triggers the loading of the registered data, regardless of its
current
LoaderService.UpdatePolicy configured, from the fallback/local
resource. |
void |
registerData(java.lang.String resourceId,
LoaderService.UpdatePolicy updatePolicy,
java.util.Map<java.lang.String,java.lang.String> properties,
java.net.URL backupResource,
java.net.URL... resourceLocations)
Programmatically registers a remote resource
resourceLocation ,
backed up by a classpath resource backupResource , reachable as
dataId . |
void |
removeLoaderListener(LoaderService.LoaderListener l,
java.lang.String... resourceIds)
Remove a registered
LoaderService.LoaderListener callback. |
void |
resetData(java.lang.String resourceId)
Explicitly triggers the reset (loading of the registered data from the
classpath backup resource).
|
void addLoaderListener(LoaderService.LoaderListener l, java.lang.String... resourceIds)
LoaderService.LoaderListener
callback that is informed when a data
resource was update from remote, or reset. Passing an empty String or
null
sa dataId
allows to register a listener for all data
resources registered. loadData(String)
resetData(String)
resourceIds
- The unique identifiers of the resource, not null
.l
- The listener to be addedremoveLoaderListener(LoaderListener,String...)
java.io.InputStream getData(java.lang.String resourceId) throws java.io.IOException
resourceId
- The unique identifier of the resource, not null
.InputStream
for reading the data.java.io.IOException
- if a problem occurred.java.util.Set<java.lang.String> getResourceIds()
Set
of all registered data resource identifiers.Set
of all registered data resource identifiers, never
null
.java.util.Map<java.lang.String,java.lang.String> getUpdateConfiguration(java.lang.String resourceId)
resourceId
- the dataId, not null
null
java.lang.IllegalArgumentException
- if no such dataId is available.LoaderService.UpdatePolicy getUpdatePolicy(java.lang.String resourceId)
LoaderService.UpdatePolicy
in place for the given dataId.resourceId
- the resource's id, not null
LoaderService.UpdatePolicy
, not null
java.lang.IllegalArgumentException
- if no such dataId is available.boolean isResourceRegistered(java.lang.String resourceId)
resourceId
- The unique identifier of the resource, not null
.true
, if such a data resource is registered.boolean loadData(java.lang.String resourceId) throws java.io.IOException
LoaderService.UpdatePolicy
configured.resourceId
- The unique identifier of the resource, not null
.java.io.IOException
- if a problem occurred.java.util.concurrent.Future<java.lang.Boolean> loadDataAsync(java.lang.String resourceId)
LoaderService.UpdatePolicy
configured.resourceId
- The unique identifier of the resource, not null
.boolean loadDataLocal(java.lang.String resourceId)
LoaderService.UpdatePolicy
configured, from the fallback/local
resource.resourceId
- The unique identifier of the resource, not null
.java.io.IOException
- if a problem occurred.void registerData(java.lang.String resourceId, LoaderService.UpdatePolicy updatePolicy, java.util.Map<java.lang.String,java.lang.String> properties, java.net.URL backupResource, java.net.URL... resourceLocations)
resourceLocation
,
backed up by a classpath resource backupResource
, reachable as
dataId
.resourceId
- The unique identifier of the resource that must also be used
for accessing the resource, not null
.resourceLocations
- The remote resource locations, not null
.backupResource
- The backup resource location in the classpath, not
null
.void removeLoaderListener(LoaderService.LoaderListener l, java.lang.String... resourceIds)
LoaderService.LoaderListener
callback.resourceIds
- The unique identifier of the resource, not null
.l
- The listener to be removedaddLoaderListener(LoaderListener, String...)
void resetData(java.lang.String resourceId) throws java.io.IOException
resourceId
- The unique identifier of the resource, not null
.java.io.IOException
- if a problem occurred.