public class TMSCachedTileLoaderJob extends JCSCachedTileLoaderJob<java.lang.String,BufferedImageCacheEntry> implements TileJob, ICachedLoaderListener
ICachedLoaderListener.LoadResult
Modifier and Type | Field and Description |
---|---|
private static java.util.concurrent.ConcurrentMap<java.lang.String,java.util.Set<TileLoaderListener>> |
inProgress |
private static LongProperty |
MAXIMUM_EXPIRES |
private static LongProperty |
MINIMUM_EXPIRES |
private static java.util.regex.Pattern |
SERVICE_EXCEPTION_PATTERN |
protected Tile |
tile |
private java.net.URL |
url |
ABSOLUTE_EXPIRE_TIME_LIMIT, attributes, cacheData, DEFAULT_EXPIRE_TIME, EXPIRE_TIME_SERVER_LIMIT, now, THREAD_LIMIT
Constructor and Description |
---|
TMSCachedTileLoaderJob(TileLoaderListener listener,
Tile tile,
org.apache.commons.jcs.access.behavior.ICacheAccess<java.lang.String,BufferedImageCacheEntry> cache,
int connectTimeout,
int readTimeout,
java.util.Map<java.lang.String,java.lang.String> headers,
java.util.concurrent.ThreadPoolExecutor downloadExecutor)
Constructor for creating a job, to get a specific tile from cache
|
Modifier and Type | Method and Description |
---|---|
protected boolean |
cacheAsEmpty()
Simple implementation.
|
protected BufferedImageCacheEntry |
createCacheEntry(byte[] content) |
java.lang.String |
getCacheKey()
returns cache entry key
|
protected java.lang.String |
getServerKey()
For TMS use BaseURL as settings discovery, so for different paths, we will have different settings (useful for developer servers)
|
java.net.URL |
getUrl()
method to get download URL for Job
|
private boolean |
handleNoTileAtZoom() |
private boolean |
isNoTileAtZoom() |
boolean |
isObjectLoadable() |
protected boolean |
isResponseLoadable(java.util.Map<java.lang.String,java.util.List<java.lang.String>> headers,
int statusCode,
byte[] content)
Check if the object is loadable.
|
void |
loadingFinished(CacheEntry object,
CacheEntryAttributes attributes,
ICachedLoaderListener.LoadResult result)
Will be called when K object processed.
|
protected CacheEntryAttributes |
parseHeaders(HttpClient.Response urlConn) |
void |
submit()
submits download job to backend.
|
void |
submit(boolean force)
submits download job to backend.
|
private boolean |
tryLoadTileImage(CacheEntry object) |
cancelOutstandingTasks, executionFinished, get, handleJobCancellation, isCacheElementValid, run, setFinishedTask, submit
private static final LongProperty MAXIMUM_EXPIRES
private static final LongProperty MINIMUM_EXPIRES
private static final java.util.regex.Pattern SERVICE_EXCEPTION_PATTERN
private volatile java.net.URL url
private static final java.util.concurrent.ConcurrentMap<java.lang.String,java.util.Set<TileLoaderListener>> inProgress
public TMSCachedTileLoaderJob(TileLoaderListener listener, Tile tile, org.apache.commons.jcs.access.behavior.ICacheAccess<java.lang.String,BufferedImageCacheEntry> cache, int connectTimeout, int readTimeout, java.util.Map<java.lang.String,java.lang.String> headers, java.util.concurrent.ThreadPoolExecutor downloadExecutor)
listener
- Tile loader listenertile
- to be fetched from cachecache
- objectconnectTimeout
- when connecting to remote resourcereadTimeout
- when connecting to remote resourceheaders
- HTTP headers to be sent together with requestdownloadExecutor
- that will be executing the jobspublic java.lang.String getCacheKey()
ICachedLoaderJob
getCacheKey
in interface ICachedLoaderJob<java.lang.String>
public java.net.URL getUrl() throws java.io.IOException
ICachedLoaderJob
getUrl
in interface ICachedLoaderJob<java.lang.String>
java.io.IOException
- when could not determine the URL of the tilepublic boolean isObjectLoadable()
isObjectLoadable
in class JCSCachedTileLoaderJob<java.lang.String,BufferedImageCacheEntry>
protected boolean isResponseLoadable(java.util.Map<java.lang.String,java.util.List<java.lang.String>> headers, int statusCode, byte[] content)
JCSCachedTileLoaderJob
isResponseLoadable
in class JCSCachedTileLoaderJob<java.lang.String,BufferedImageCacheEntry>
headers
- headers sent by serverstatusCode
- http status codecontent
- data read from serverprotected boolean cacheAsEmpty()
JCSCachedTileLoaderJob
cacheAsEmpty
in class JCSCachedTileLoaderJob<java.lang.String,BufferedImageCacheEntry>
public void submit(boolean force)
TileJob
public void loadingFinished(CacheEntry object, CacheEntryAttributes attributes, ICachedLoaderListener.LoadResult result)
ICachedLoaderListener
loadingFinished
in interface ICachedLoaderListener
object
- cache entry contentsattributes
- cache entry attributesresult
- load result (success, failure, canceled)protected java.lang.String getServerKey()
getServerKey
in class JCSCachedTileLoaderJob<java.lang.String,BufferedImageCacheEntry>
protected BufferedImageCacheEntry createCacheEntry(byte[] content)
createCacheEntry
in class JCSCachedTileLoaderJob<java.lang.String,BufferedImageCacheEntry>
public void submit()
TileJob
protected CacheEntryAttributes parseHeaders(HttpClient.Response urlConn)
parseHeaders
in class JCSCachedTileLoaderJob<java.lang.String,BufferedImageCacheEntry>
private boolean handleNoTileAtZoom()
private boolean isNoTileAtZoom()
private boolean tryLoadTileImage(CacheEntry object) throws java.io.IOException
java.io.IOException