/*
 * This file is part of Vestige.
 *
 * Vestige is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * Vestige is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with Vestige.  If not, see <http://www.gnu.org/licenses/>.
 */

package fr.gaellalire.vestige.platform;

import java.io.File;
import java.io.IOException;
import java.net.URL;
import java.net.URLConnection;
import java.util.Map;
import java.util.jar.JarFile;

import fr.gaellalire.vestige.core.url.DelegateURLStreamHandler;
import fr.gaellalire.vestige.core.url.VestigeURLStreamHandler;

/**
 * @author Gael Lalire
 */
public class VestigeJarURLStreamHandler extends VestigeURLStreamHandler {

    private Map<File, JarFile> cache;

    public VestigeJarURLStreamHandler(final DelegateURLStreamHandler delegateURLStreamHandler, final Map<File, JarFile> cache) {
        super(delegateURLStreamHandler);
        this.cache = cache;
    }

    @Override
    protected URLConnection openConnection(final URL url) throws IOException {
        return new VestigeJarURLConnection(url, cache);
    }

}
