public class DefaultLoaderService extends 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,
String... dataIds)
Add a
LoaderService.LoaderListener callback that is informed when a data
resource was update from remote, or reset. |
InputStream |
getData(String resourceId)
Access the input stream of the given data resource.
|
Set<String> |
getResourceIds()
Get a
Set of all registered data resource identifiers. |
Map<String,String> |
getUpdateConfiguration(String resourceId)
Get the update configuration for the given dataId.
|
LoaderService.UpdatePolicy |
getUpdatePolicy(String resourceId)
Get the
LoaderService.UpdatePolicy in place for the given dataId. |
boolean |
isResourceRegistered(String dataId)
Allows to check if a data resource with the given dataId is registered.
|
boolean |
loadData(String resourceId)
Explicitly triggers the remote loading of the registered data, regardless
of its current
LoaderService.UpdatePolicy configured. |
Future<Boolean> |
loadDataAsync(String resourceId)
Explicitly asynchronously triggers the remote loading of the registered
data, regardless of its current
LoaderService.UpdatePolicy configured. |
boolean |
loadDataLocal(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(String value)
Parse a duration of the form HH:mm:ss:nnn, whereas only hours are non
optional.
|
void |
registerData(String resourceId,
LoaderService.UpdatePolicy updatePolicy,
Map<String,String> properties,
URL backupResource,
URL... resourceLocations)
Programmatically registers a remote resource
resourceLocation,
backed up by a classpath resource backupResource, reachable as
dataId. |
void |
removeLoaderListener(LoaderService.LoaderListener l,
String... dataIds)
Remove a registered
LoaderService.LoaderListener callback. |
void |
resetData(String dataId)
Explicitly triggers the reset (loading of the registered data from the
classpath backup resource).
|
String |
toString() |
void |
unload(String resourceId)
Removes a resource managed.
|
public DefaultLoaderService()
public void unload(String resourceId)
resourceId - the resource id.public void registerData(String resourceId, LoaderService.UpdatePolicy updatePolicy, Map<String,String> properties, URL backupResource, 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 Map<String,String> getUpdateConfiguration(String resourceId)
LoaderServicegetUpdateConfiguration in interface LoaderServiceresourceId - the dataId, not nullnullpublic boolean isResourceRegistered(String dataId)
LoaderServiceisResourceRegistered in interface LoaderServicedataId - The unique identifier of the resource, not null.true, if such a data resource is registered.public Set<String> getResourceIds()
LoaderServiceSet of all registered data resource identifiers.getResourceIds in interface LoaderServiceSet of all registered data resource identifiers, never
null.public InputStream getData(String resourceId) throws IOException
LoaderServicegetData in interface LoaderServiceresourceId - The unique identifier of the resource, not null.InputStream for reading the data.IOException - if a problem occurred.public boolean loadData(String resourceId)
LoaderServiceLoaderService.UpdatePolicy configured.loadData in interface LoaderServiceresourceId - The unique identifier of the resource, not null.public Future<Boolean> loadDataAsync(String resourceId)
LoaderServiceLoaderService.UpdatePolicy configured.loadDataAsync in interface LoaderServiceresourceId - The unique identifier of the resource, not null.public boolean loadDataLocal(String resourceId)
LoaderServiceLoaderService.UpdatePolicy configured, from the fallback/local
resource.loadDataLocal in interface LoaderServiceresourceId - The unique identifier of the resource, not null.public void resetData(String dataId) throws IOException
LoaderServiceresetData in interface LoaderServicedataId - The unique identifier of the resource, not null.IOException - if a problem occurred.public void addLoaderListener(LoaderService.LoaderListener l, 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 void removeLoaderListener(LoaderService.LoaderListener l, 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 LoaderService.UpdatePolicy getUpdatePolicy(String resourceId)
LoaderServiceLoaderService.UpdatePolicy in place for the given dataId.getUpdatePolicy in interface LoaderServiceresourceId - the resource's id, not nullLoaderService.UpdatePolicy, not nullprotected long parseDuration(String value)
value - the input valueCopyright © 2012-2014 JavaMoney. All Rights Reserved.