Dépôt officiel du code source de l'ERP OpenConcerto
/trunk/OpenConcerto/src/org/openconcerto/utils/protocol/Helper.java |
---|
26,11 → 26,16 |
static private final PropertyList PL = new PropertyList("java.protocol.handler.pkgs", "|"); |
static final public void register() { |
// works even if setURLStreamHandlerFactory() is called (as long as the factoy returns null |
// Works even if setURLStreamHandlerFactory() is called (as long as the factory returns null |
// for our protocols) |
// On Java 11, there's also URLStreamHandlerProvider |
PL.add(Helper.class.getPackage().getName()); |
} |
static final public void unregister() { |
PL.remove(Helper.class.getPackage().getName()); |
} |
/** |
* Set the {@link URL#setURLStreamHandlerFactory(URLStreamHandlerFactory) factory} to add our |
* protocols. This is needed for example in web start when one of our url is embedded into a |
59,10 → 64,14 |
* "jar:jarjar:file:/C:/mylibs/Outer.jar^/Inner.jar!/". |
*/ |
public static final URL toJarJar(URL u) { |
return toJarJar(u, ""); |
} |
public static final URL toJarJar(final URL u, final String s) { |
// if it's a jar inside another jar |
if ("jar".equals(u.getProtocol()) && u.getPath().endsWith(".jar")) { |
try { |
return new URL("jar:jar" + u.toString().replace('!', '^') + "!/"); |
return new URL("jar:jar" + u.toString().replace('!', '^') + "!/" + s); |
} catch (MalformedURLException e) { |
// shouldn't happen since we modify a valid URL |
throw new IllegalStateException("Couldn't transform " + u, e); |