public class DefaultLoaderService extends java.lang.Object implements LoaderService
UpdatePolicy
loads/updates the resources from arbitrary locations and stores it to the
interal file cache.LoaderService.LoaderListener, LoaderService.UpdatePolicy
Constructor and Description |
---|
DefaultLoaderService()
Constructor, initializing from config.
|
Modifier and Type | Method and Description |
---|---|
void |
addLoaderListener(LoaderService.LoaderListener l,
java.lang.String... dataIds)
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 dataId)
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. |
protected long |
parseDuration(java.lang.String value)
Parse a duration of the form HH:mm:ss:nnn, whereas only hours are non
optional.
|
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... dataIds)
Remove a registered
LoaderService.LoaderListener callback. |
void |
resetData(java.lang.String dataId)
Explicitly triggers the reset (loading of the registered data from the
classpath backup resource).
|
java.lang.String |
toString() |
void |
unload(java.lang.String resourceId)
Removes a resource managed.
|
public DefaultLoaderService()
public void addLoaderListener(LoaderService.LoaderListener l, java.lang.String... dataIds)
LoaderService
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. LoaderService.loadData(String)
LoaderService.resetData(String)
addLoaderListener
in interface LoaderService
l
- The listener to be addeddataIds
- The unique identifiers of the resource, not null
.LoaderService.removeLoaderListener(LoaderListener,String...)
public java.io.InputStream getData(java.lang.String resourceId) throws java.io.IOException
LoaderService
getData
in interface LoaderService
resourceId
- The unique identifier of the resource, not null
.InputStream
for reading the data.java.io.IOException
- if a problem occurred.public java.util.Set<java.lang.String> getResourceIds()
LoaderService
Set
of all registered data resource identifiers.getResourceIds
in interface LoaderService
Set
of all registered data resource identifiers, never
null
.public java.util.Map<java.lang.String,java.lang.String> getUpdateConfiguration(java.lang.String resourceId)
LoaderService
getUpdateConfiguration
in interface LoaderService
resourceId
- the dataId, not null
null
public LoaderService.UpdatePolicy getUpdatePolicy(java.lang.String resourceId)
LoaderService
LoaderService.UpdatePolicy
in place for the given dataId.getUpdatePolicy
in interface LoaderService
resourceId
- the resource's id, not null
LoaderService.UpdatePolicy
, not null
public boolean isResourceRegistered(java.lang.String dataId)
LoaderService
isResourceRegistered
in interface LoaderService
dataId
- The unique identifier of the resource, not null
.true
, if such a data resource is registered.public boolean loadData(java.lang.String resourceId)
LoaderService
LoaderService.UpdatePolicy
configured.loadData
in interface LoaderService
resourceId
- The unique identifier of the resource, not null
.public java.util.concurrent.Future<java.lang.Boolean> loadDataAsync(java.lang.String resourceId)
LoaderService
LoaderService.UpdatePolicy
configured.loadDataAsync
in interface LoaderService
resourceId
- The unique identifier of the resource, not null
.public boolean loadDataLocal(java.lang.String resourceId)
LoaderService
LoaderService.UpdatePolicy
configured, from the fallback/local
resource.loadDataLocal
in interface LoaderService
resourceId
- The unique identifier of the resource, not null
.protected long parseDuration(java.lang.String value)
value
- the input valuepublic 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)
LoaderService
resourceLocation
,
backed up by a classpath resource backupResource
, reachable as
dataId
.registerData
in interface LoaderService
resourceId
- The unique identifier of the resource that must also be used
for accessing the resource, not null
.backupResource
- The backup resource location in the classpath, not
null
.resourceLocations
- The remote resource locations, not null
.public void removeLoaderListener(LoaderService.LoaderListener l, java.lang.String... dataIds)
LoaderService
LoaderService.LoaderListener
callback.removeLoaderListener
in interface LoaderService
l
- The listener to be removeddataIds
- The unique identifier of the resource, not null
.LoaderService.addLoaderListener(LoaderListener, String...)
public void resetData(java.lang.String dataId) throws java.io.IOException
LoaderService
resetData
in interface LoaderService
dataId
- The unique identifier of the resource, not null
.java.io.IOException
- if a problem occurred.public java.lang.String toString()
toString
in class java.lang.Object
public void unload(java.lang.String resourceId)
resourceId
- the resource id.