public class CachingURLResourceHandle extends Object implements ResourceHandle
This resource handler downloads remote resources on demand, and caches them
as local files. Resources that are already local (i.e. file:...
URLs) are returned directly.
Two alternative caching modes are available. When the mode is
CachingURLResourceHandle.CachingMode.PreferCache
, the cached file will always be returned if
it exists; therefore to refresh from the remote resource it will be necessary
to delete the cache. When the mode is CachingURLResourceHandle.CachingMode.PreferRemote
, the
first call to request()
will always attempt to download the remote
resource, and only uses the pre-downloaded cache if the remote could not be
downloaded (e.g. because the network is offline).
Modifier and Type | Class and Description |
---|---|
static class |
CachingURLResourceHandle.CachingMode |
ResourceHandle.Location
Constructor and Description |
---|
CachingURLResourceHandle(String url,
String baseUrl,
File cacheDir,
CachingURLResourceHandle.CachingMode mode) |
CachingURLResourceHandle(String url,
String baseUrl,
File cacheDir,
URLConnector connector,
CachingURLResourceHandle.CachingMode mode) |
Modifier and Type | Method and Description |
---|---|
ResourceHandle.Location |
getLocation() |
String |
getName() |
URL |
getResolvedUrl() |
File |
request() |
void |
setReporter(Reporter reporter) |
public CachingURLResourceHandle(String url, String baseUrl, File cacheDir, CachingURLResourceHandle.CachingMode mode) throws IOException
IOException
public CachingURLResourceHandle(String url, String baseUrl, File cacheDir, URLConnector connector, CachingURLResourceHandle.CachingMode mode) throws IOException
IOException
public void setReporter(Reporter reporter)
public String getName()
getName
in interface ResourceHandle
public ResourceHandle.Location getLocation()
getLocation
in interface ResourceHandle
public File request() throws IOException
request
in interface ResourceHandle
IOException
public URL getResolvedUrl()
Copyright © 2012 aQute SARL. All Rights Reserved.