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