summaryrefslogtreecommitdiffstats
path: root/src/java/com/jogamp/common/net/asset
diff options
context:
space:
mode:
Diffstat (limited to 'src/java/com/jogamp/common/net/asset')
-rw-r--r--src/java/com/jogamp/common/net/asset/Handler.java38
1 files changed, 38 insertions, 0 deletions
diff --git a/src/java/com/jogamp/common/net/asset/Handler.java b/src/java/com/jogamp/common/net/asset/Handler.java
new file mode 100644
index 0000000..1063797
--- /dev/null
+++ b/src/java/com/jogamp/common/net/asset/Handler.java
@@ -0,0 +1,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(URL u) throws IOException {
+ final AssetURLConnection c = new AssetURLConnection(u, localCL);
+ c.connect();
+ return c;
+ }
+
+}