1 23 package com.sun.enterprise.appclient.jws.boot; 24 25 import java.io.File ; 26 import java.lang.reflect.InvocationTargetException ; 27 import java.lang.reflect.Method ; 28 import java.net.MalformedURLException ; 29 import java.net.URI ; 30 import java.net.URISyntaxException ; 31 import java.net.URL ; 32 import java.util.Arrays ; 33 import java.util.jar.JarFile ; 34 35 40 public class ClassPathManager16 extends ClassPathManager { 41 42 43 private Class jnlpClassLoaderClass; 44 45 46 private Method getJarFileMethod; 47 48 52 protected ClassPathManager16(ClassLoader loader) { 53 super(loader); 54 try { 55 prepareIntrospectionInfo(); 56 } catch (Throwable thr) { 57 throw new RuntimeException (thr); 58 } 59 } 60 61 67 private void prepareIntrospectionInfo() throws ClassNotFoundException , NoSuchMethodException { 68 jnlpClassLoaderClass = getJNLPClassLoader().loadClass("com.sun.jnlp.JNLPClassLoader"); 69 getJarFileMethod = jnlpClassLoaderClass.getDeclaredMethod("getJarFile", URL .class); 70 getJarFileMethod.setAccessible(true); 71 } 72 73 public ClassLoader getParentClassLoader() { 74 return getJNLPClassLoader().getParent(); 75 } 76 77 public File findContainingJar(URL resourceURL) throws IllegalArgumentException , URISyntaxException , MalformedURLException , IllegalAccessException , InvocationTargetException { 78 83 URI resourceURI = resourceURL.toURI(); 84 String ssp = resourceURI.getSchemeSpecificPart(); 85 String jarOnlySSP = ssp.substring(0, ssp.indexOf('!')); 86 87 URL jarOnlyURL = new URL (jarOnlySSP).toURI().toURL(); 88 89 94 JarFile jarFile = (JarFile ) getJarFileMethod.invoke(getJNLPClassLoader(), jarOnlyURL); 95 File f = new File (jarFile.getName()); 96 return f; 97 } 98 } 99 | Popular Tags |