aboutsummaryrefslogtreecommitdiffstats
path: root/src/java/com/jogamp/common/net/asset/Handler.java
blob: 74fb015efb2667ba3a589d3ff6e26571c2286ec7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
package com.jogamp.common.net.asset;

import java.io.IOException;
import java.net.URL;
import java.net.URLConnection;
import java.net.URLStreamHandler;

import com.jogamp.common.net.AssetURLConnection;
import com.jogamp.common.net.AssetURLContext;

/**
 * {@link URLStreamHandler} to handle the asset protocol.
 *
 * <p>
 * This is the <i>asset</i> URLStreamHandler variation
 * using this class ClassLoader for the pkg factory model.
 * </p>
 */
public class Handler extends URLStreamHandler {
    static final AssetURLContext localCL = new AssetURLContext() {
            @Override
            public ClassLoader getClassLoader() {
                return Handler.class.getClassLoader();
            }
        };

    public Handler() {
        super();
    }

    @Override
    protected URLConnection openConnection(final URL u) throws IOException {
        final AssetURLConnection c = new AssetURLConnection(u, localCL);
        c.connect();
        return c;
    }

}