001// License: GPL. For details, see LICENSE file. 002package org.openstreetmap.josm.data.imagery; 003 004import java.util.Map; 005import java.util.concurrent.ThreadPoolExecutor; 006 007import org.apache.commons.jcs.access.behavior.ICacheAccess; 008import org.openstreetmap.gui.jmapviewer.Tile; 009import org.openstreetmap.gui.jmapviewer.interfaces.TileLoaderListener; 010import org.openstreetmap.josm.Main; 011import org.openstreetmap.josm.data.cache.BufferedImageCacheEntry; 012 013/** 014 * Separate class to handle WMS jobs, as it needs to react differently to HTTP response codes from WMS server 015 * 016 * @author Wiktor Niesiobędzki 017 * @since 8526 018 */ 019public class WMSCachedTileLoaderJob extends TMSCachedTileLoaderJob { 020 021 /** 022 * Creates a job - that will download specific tile 023 * @param listener will be notified, when tile has loaded 024 * @param tile to load 025 * @param cache to use (get/put) 026 * @param connectTimeout to tile source 027 * @param readTimeout to tile source 028 * @param headers to be sent with request 029 * @param downloadExecutor that will execute the download task (if needed) 030 */ 031 public WMSCachedTileLoaderJob(TileLoaderListener listener, Tile tile, 032 ICacheAccess<String, BufferedImageCacheEntry> cache, int connectTimeout, int readTimeout, 033 Map<String, String> headers, ThreadPoolExecutor downloadExecutor) { 034 super(listener, tile, cache, connectTimeout, readTimeout, headers, downloadExecutor); 035 } 036 037 @Override 038 public String getCacheKey() { 039 // include projection in cache key, as with different projections different response will be returned from server 040 String key = super.getCacheKey(); 041 if (key != null) { 042 return key + Main.getProjection().toCode(); 043 } 044 return null; 045 } 046}