public class LoadableResource extends Object
Constructor and Description |
---|
LoadableResource(String resourceId,
ResourceCache cache,
LoaderService.UpdatePolicy updatePolicy,
Map<String,String> properties,
URI fallbackLocation,
URI... locations)
Create a new instance.
|
Modifier and Type | Method and Description |
---|---|
protected void |
clearCache()
This method is called when the cached data should be removed, e.g. after an explicit fallback reload, or
a clear operation.
|
int |
getAccessCount()
Get the number of successful accesses.
|
byte[] |
getData()
Get the resource data.
|
protected byte[] |
getData(boolean loadIfNeeded) |
InputStream |
getDataStream()
Get the resource data as input stream.
|
URI |
getFallbackResource()
Return the fallback location.
|
long |
getLastLoaded()
Get the timestamp of the last succesful load.
|
int |
getLoadCount()
Get the number of active loads of this resource (InputStream).
|
Map<String,String> |
getProperties()
Get the configuration properties of this resource.
|
List<URI> |
getRemoteResources()
Get the remote locations.
|
String |
getResourceId()
Get the resourceId.
|
LoaderService.UpdatePolicy |
getUpdatePolicy()
Get the UpdatePolicy of this resource.
|
boolean |
load()
Loads the resource, first from the remote resources, if that fails from
the fallback location.
|
protected boolean |
load(URI itemToLoad,
boolean fallbackLoad)
Tries to load the data from the given location.
|
boolean |
loadFallback()
Try to load the resource from the fallback resources.
|
boolean |
loadRemote()
Try to load the resource from the remote locations.
|
protected boolean |
readCache()
This method is called when the data should be loaded from the cache.
|
boolean |
resetToFallback()
Explicitly override the resource wih the fallback context and resets the
load counter.
|
protected void |
setData(byte[] bytes) |
String |
toString() |
void |
unload() |
protected void |
writeCache()
This method is called after data could be successfully loaded from a non fallback resource.
|
public LoadableResource(String resourceId, ResourceCache cache, LoaderService.UpdatePolicy updatePolicy, Map<String,String> properties, URI fallbackLocation, URI... locations)
resourceId
- The dataId.cache
- The cache to be used for storing remote data locally.properties
- The configuration properties.fallbackLocation
- teh fallback ULR, not null.locations
- the remote locations, not null (but may be empty!)public LoaderService.UpdatePolicy getUpdatePolicy()
public Map<String,String> getProperties()
public boolean load()
public final String getResourceId()
public final List<URI> getRemoteResources()
public final URI getFallbackResource()
public final int getLoadCount()
public final int getAccessCount()
public InputStream getDataStream()
public final long getLastLoaded()
public boolean loadRemote()
public boolean loadFallback()
protected void clearCache()
protected boolean readCache()
protected void writeCache() throws IOException
IOException
protected boolean load(URI itemToLoad, boolean fallbackLoad)
itemToLoad
- the target URL
fallbackLoad
- true, for a fallback URL.public final byte[] getData()
protected byte[] getData(boolean loadIfNeeded)
protected final void setData(byte[] bytes)
public void unload()
public boolean resetToFallback()
IOException
Copyright © 2012-2015 JavaMoney. All Rights Reserved.