File result = null;
if (resourceURL != null) {
/*
*The URL will be similar to http://host:port/...path-in-server-namespace!resource-spec
*Extract the part preceding the ! and ask the Java Web Start loader to
*find the locally-cached JAR file corresponding to that part of the URL.
*/
URI resourceURI = resourceURL.toURI();
String ssp = resourceURI.getSchemeSpecificPart();
String jarOnlySSP = ssp.substring(0, ssp.indexOf('!"));
URL jarOnlyURL = new URL(jarOnlySSP).toURI().toURL();
/*
*Use introspection to invoke the method. This avoids complications
*in building the app server under Java 1.5 in which the JNLPClassLoader
*does not provide the getJarFile method.
*/
JarFile jarFile = (JarFile) getJarFileMethod.invoke(getJNLPClassLoader(), jarOnlyURL);
if (jarFile == null) {
throw new IllegalArgumentException(resourceURL.toExternalForm());
}
result = new File(jarFile.getName());
}
return result;