Use the AttachableURLFactory.

git-svn-id: svn+ssh://src.earth.threerings.net/narya/trunk@2696 542714f4-19e9-0310-aa3c-eee0fc999fb1
This commit is contained in:
Ray Greenwell
2003-07-09 18:44:52 +00:00
parent 4c342c28f3
commit e140fd6301
+7 -14
View File
@@ -1,5 +1,5 @@
// //
// $Id: Handler.java,v 1.4 2003/05/07 05:31:09 mdb Exp $ // $Id: Handler.java,v 1.5 2003/07/09 18:44:52 ray Exp $
package com.threerings.resource; package com.threerings.resource;
@@ -9,7 +9,8 @@ import java.io.InputStream;
import java.net.URL; import java.net.URL;
import java.net.URLConnection; import java.net.URLConnection;
import java.net.URLStreamHandler; import java.net.URLStreamHandler;
import java.net.URLStreamHandlerFactory;
import com.samskivert.net.AttachableURLFactory;
/** /**
* This class is not used directly, except by a registering ResourceManager * This class is not used directly, except by a registering ResourceManager
@@ -35,18 +36,10 @@ public class Handler extends URLStreamHandler
// There are two ways to do this. // There are two ways to do this.
// Method 1, which is the only one that seems to work under // Method 1, which is the only one that seems to work under
// Java Web Start, is to register a factory. This is kind of // Java Web Start, is to register a factory.
// scary because there can only be one factory. // This *used* to be scary to me, because you could only have one
URL.setURLStreamHandlerFactory(new URLStreamHandlerFactory() { // factory, but now we have the attachable factory!
public URLStreamHandler createURLStreamHandler (String protocol) AttachableURLFactory.attachHandler("resource", Handler.class);
{
if (protocol.equalsIgnoreCase("resource")) {
return new Handler();
}
return null;
}
});
// Method 2 seems like a better idea but doesn't work under // Method 2 seems like a better idea but doesn't work under
// Java Web Start. We add on a property that registers this // Java Web Start. We add on a property that registers this