FileDocCategorySizeDatePackage
ClassPathManager16.javaAPI DocGlassfish v2 API5239Fri May 04 22:34:22 BST 2007com.sun.enterprise.appclient.jws.boot

ClassPathManager16

public class ClassPathManager16 extends ClassPathManager
Class Path manager for Java Web Start-aware ACC running under Java runtime 1.6.
author
tjquinn

Fields Summary
private Class
jnlpClassLoaderClass
Class object for the JNLPClassLoader class
private Method
getJarFileMethod
Method object for the getJarFile method on JNLPClassLoader - only in 1.6 and later
Constructors Summary
protected ClassPathManager16(ClassLoader loader, boolean keepJWSClassLoader)
Returns a new instance of the class path manager for use under Java 1.6

param
loader the Java Web Start-provided class loader

        super(loader, keepJWSClassLoader);
        try {
            prepareIntrospectionInfo();
        } catch (Throwable thr) {
            throw new RuntimeException(thr);
        }
    
Methods Summary
public java.io.FilefindContainingJar(java.net.URL resourceURL)

        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;
    
public java.lang.ClassLoadergetParentClassLoader()

        return (keepJWSClassLoader() ? getJnlpClassLoader() : getJNLPClassLoader().getParent());
    
private voidprepareIntrospectionInfo()
Prepares the reflection-related private variables for later use in locating classes in JARs.

throws
ClassNotFoundException if the JNLPClassLoader class cannot be found
throws
NoSuchMethodException if the getJarFile method cannot be found

        jnlpClassLoaderClass = getJNLPClassLoader().loadClass("com.sun.jnlp.JNLPClassLoader");
        getJarFileMethod = jnlpClassLoaderClass.getDeclaredMethod("getJarFile", URL.class);
        getJarFileMethod.setAccessible(true);