public class TMSCachedTileLoader extends Object implements TileLoader, CachedTileLoader
Modifier and Type | Field and Description |
---|---|
protected org.apache.commons.jcs.access.behavior.ICacheAccess<String,BufferedImageCacheEntry> |
cache |
protected int |
connectTimeout |
private static ThreadPoolExecutor |
DEFAULT_DOWNLOAD_JOB_DISPATCHER
separate from JCS thread pool for TMS loader, so we can have different thread pools for default JCS
and for TMS imagery
|
private ThreadPoolExecutor |
downloadExecutor |
protected Map<String,String> |
headers |
static IntegerProperty |
HOST_LIMIT
Limit definition for per host concurrent connections
|
protected TileLoaderListener |
listener |
protected int |
readTimeout |
static IntegerProperty |
THREAD_LIMIT
overrides the THREAD_LIMIT in superclass, as we want to have separate limit and pool for TMS
|
Constructor and Description |
---|
TMSCachedTileLoader(TileLoaderListener listener,
org.apache.commons.jcs.access.behavior.ICacheAccess<String,BufferedImageCacheEntry> cache,
int connectTimeout,
int readTimeout,
Map<String,String> headers)
Constructor
|
Modifier and Type | Method and Description |
---|---|
void |
cancelOutstandingTasks()
cancels all outstanding tasks in the queue.
|
void |
clearCache(TileSource source) |
TileJob |
createTileLoaderJob(Tile tile)
A typical implementation of this function should create and return a
new
TileJob instance that performs the load action. |
ThreadPoolExecutor |
getDownloadExecutor() |
static ThreadPoolExecutor |
getNewThreadPoolExecutor(String name) |
static ThreadPoolExecutor |
getNewThreadPoolExecutor(String nameFormat,
int workers) |
String |
getStats() |
void |
setDownloadExecutor(ThreadPoolExecutor downloadExecutor)
Sets the download executor that will be used to download tiles instead of default one.
|
protected final org.apache.commons.jcs.access.behavior.ICacheAccess<String,BufferedImageCacheEntry> cache
protected final int connectTimeout
protected final int readTimeout
protected final TileLoaderListener listener
public static final IntegerProperty THREAD_LIMIT
public static final IntegerProperty HOST_LIMIT
private static ThreadPoolExecutor DEFAULT_DOWNLOAD_JOB_DISPATCHER
private ThreadPoolExecutor downloadExecutor
public TMSCachedTileLoader(TileLoaderListener listener, org.apache.commons.jcs.access.behavior.ICacheAccess<String,BufferedImageCacheEntry> cache, int connectTimeout, int readTimeout, Map<String,String> headers) throws IOException
listener
- called when tile loading has finishedcache
- of the cacheconnectTimeout
- to remote resourcereadTimeout
- to remote resourceheaders
- HTTP headers to be sent along with requestIOException
- when cache initialization failspublic static ThreadPoolExecutor getNewThreadPoolExecutor(String nameFormat, int workers)
nameFormat
- see Utils.newThreadFactory(String, int)
workers
- number of worker thread to keeppublic static ThreadPoolExecutor getNewThreadPoolExecutor(String name)
name
- name of threadspublic TileJob createTileLoaderJob(Tile tile)
TileLoader
TileJob
instance that performs the load action.createTileLoaderJob
in interface TileLoader
tile
- the tile to be loadedTileJob
implementation that performs the desired load
action.public void clearCache(TileSource source)
clearCache
in interface CachedTileLoader
public void cancelOutstandingTasks()
cancelOutstandingTasks
in interface TileLoader
public void setDownloadExecutor(ThreadPoolExecutor downloadExecutor)
getNewThreadPoolExecutor(java.lang.String, int)
to create a new download executor with separate
queue from default.downloadExecutor
- download executor that will be used to download tilespublic ThreadPoolExecutor getDownloadExecutor()