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)
LoaderServiceLoaderService.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 LoaderServicel - 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
LoaderServicegetData in interface LoaderServiceresourceId - 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()
LoaderServiceSet of all registered data resource identifiers.getResourceIds in interface LoaderServiceSet of all registered data resource identifiers, never
null.public java.util.Map<java.lang.String,java.lang.String> getUpdateConfiguration(java.lang.String resourceId)
LoaderServicegetUpdateConfiguration in interface LoaderServiceresourceId - the dataId, not nullnullpublic LoaderService.UpdatePolicy getUpdatePolicy(java.lang.String resourceId)
LoaderServiceLoaderService.UpdatePolicy in place for the given dataId.getUpdatePolicy in interface LoaderServiceresourceId - the resource's id, not nullLoaderService.UpdatePolicy, not nullpublic boolean isResourceRegistered(java.lang.String dataId)
LoaderServiceisResourceRegistered in interface LoaderServicedataId - The unique identifier of the resource, not null.true, if such a data resource is registered.public boolean loadData(java.lang.String resourceId)
LoaderServiceLoaderService.UpdatePolicy configured.loadData in interface LoaderServiceresourceId - The unique identifier of the resource, not null.public java.util.concurrent.Future<java.lang.Boolean> loadDataAsync(java.lang.String resourceId)
LoaderServiceLoaderService.UpdatePolicy configured.loadDataAsync in interface LoaderServiceresourceId - The unique identifier of the resource, not null.public boolean loadDataLocal(java.lang.String resourceId)
LoaderServiceLoaderService.UpdatePolicy configured, from the fallback/local
resource.loadDataLocal in interface LoaderServiceresourceId - 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)
LoaderServiceresourceLocation,
backed up by a classpath resource backupResource, reachable as
dataId.registerData in interface LoaderServiceresourceId - 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)
LoaderServiceLoaderService.LoaderListener callback.removeLoaderListener in interface LoaderServicel - 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
LoaderServiceresetData in interface LoaderServicedataId - 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.Objectpublic void unload(java.lang.String resourceId)
resourceId - the resource id.