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

ClassPathManager

public abstract class ClassPathManager extends Object
Abstract superclass of classes that manage the class path needed to run the Java Web Start-aware ACC.

Some details vary among releases of the Java runtime This abstract class and its concrete implementation subclasses isolate those dependencies.

author
tjquinn

Fields Summary
public static final String
PERSISTENCE_JAR_CLASSES
private static ClassPathManager
mgr
instance of appropriate type of class path manager, depending on the Java runtime version
private final boolean
keepJWSClassLoader
private ClassLoader
jnlpClassLoader
the JNLP class loader active during the instantiation of this mgr
Constructors Summary
protected ClassPathManager(ClassLoader loader, boolean keepJWSClassLoader)
Returns a new instance of the manager.

param
loader the class loader provided by Java Web Start


                        
         
        jnlpClassLoader = loader;
        this.keepJWSClassLoader = keepJWSClassLoader;
    
Methods Summary
protected java.lang.StringclassNameToResourceName(java.lang.String className)
Converts a class name to a resource name.

param
className the name of the class of interest in x.y.z format
return
the resource name in x/y/z.class format

        return className.replace(".", "/") + ".class";
    
public abstract java.io.FilefindContainingJar(java.net.URL resourceURL)

public static com.sun.enterprise.appclient.jws.boot.ClassPathManagergetClassPathManager(boolean keepJWSClassLoader)
Returns the appropriate type of ClassPathManager.

return
an instance of the correct implementation subclass class path manager

    
                        
         
        if (mgr == null) {
            ClassLoader loader = Thread.currentThread().getContextClassLoader();
            /*
             *Distinguish between 1.6 and earlier by seeing if the curent
             *class loader - the JNLP class loader - is also a URLClassLoader
             *or not.
             */
            if (loader instanceof URLClassLoader) {
                mgr = new ClassPathManager16(loader, keepJWSClassLoader);
            } else {
                mgr = new ClassPathManager15(loader, keepJWSClassLoader);
            }
        }
        return mgr;
    
protected java.lang.ClassLoadergetJNLPClassLoader()
Returns the Java Web Start-provided class loader recorded when the class path manager was created.

return
the Java Web Start class loader

        return jnlpClassLoader;
    
protected java.lang.ClassLoadergetJnlpClassLoader()

        return jnlpClassLoader;
    
public abstract java.lang.ClassLoadergetParentClassLoader()
Returns the appropriate parent class loader for the ACC.

return
the correct class loader instance

protected booleankeepJWSClassLoader()

        return keepJWSClassLoader;
    
public java.net.URIlocateClass(java.lang.String className)
Locates the URI for the JAR containing the specified class

param
className the name of the class to be located
return
the URI for the JAR file containing the class of interest

        String resourceName = classNameToResourceName(className);
        URL classURL = locateResource(resourceName);
        File f = findContainingJar(classURL);
        if (f == null) {
            /*
             *Could not locate the class we expected.
             */
            throw new ClassNotFoundException(className + "->" + resourceName);
        }
        return f.toURI();
    
public java.net.URL[]locateDownloadedJars()
Reports URLs for the locally-cached copies of the JARs downloaded by Java Web Start needed for the ACC's class path and policy settings.

return
array of URLs, one entry for each downloaded JAR

        /*
         *For each downloaded unsigned app client jar, get a URL that locates
         *it and add the URL to the list.
         *
         *This set of values should be automated on the server side and 
         *communicated via a property setting in the JNLP document so 
         *any changes in the list of downloaded files does not need to be made
         *there and here.  
         */
        String probeClassNames = System.getProperty("com.sun.aas.jar.probe.class.names",
                "com.sun.enterprise.appclient.jws.boot.JWSACCMain," /* appserv-jwsacc */ +
                "com.sun.enterprise.appclient.Main," /* appserv-rt */ +
                "com.sun.jdo.api.persistence.enhancer.ByteCodeEnhancer," /* appserv-cmp */ +
                "com.sun.enterprise.admin.servermgmt.DomainConfig," /* appserv-admin */ +
                "com.sun.enterprise.deployment.client.DeploymentClientUtils," /* appserv-deployment-client */ +
                "javax.ejb.EJB," /* javaee */ +
                "javax.security.auth.message.module.ServerAuthModule," /* jmac-api */ +
                "com.sun.appserv.management.ext.logging.LogAnalyzer," /* appserv-ext */ + 
                "com.sun.mail.iap.Argument," /* mail */ +
                "com.sun.activation.viewers.ImageViewer," /* activation */ +
                "com.sun.xml.ws.api.server.WSEndpoint," /* webservices-rt */ +
                "com.sun.tools.ws.wsdl.parser.W3CAddressingExtensionHandler," /* webservices-tools */ +
                "com.sun.jms.spi.xa.JMSXAConnection," /* imqjmsra */ +
                "com.sun.jndi.fscontext.FSContext" /* fscontext */
                );

        return locateJARs(probeClassNames);
    
public java.net.URL[]locateJARs(java.lang.String classNamesString)

        
        String [] classNames = classNamesString.split(",");

        /*
         *For each class name, find the jar that contains it by getting a URL
         *to the class and then using that URL to find the jar.
         */
        URL [] urls = new URL[classNames.length];
        int nextURL = 0;

        for (String className : classNames) {
            URI jarFileURI = locateClass(className);
            URL url = jarFileURI.toURL();
            urls[nextURL++] = url;
        }
        return urls;
    
public java.net.URL[]locatePersistenceJARs()

        return locateJARs(PERSISTENCE_JAR_CLASSES);
    
protected java.net.URLlocateResource(java.lang.String resourceName)
Finds a resource using the class's class loader.

param
resourceName the class to find
return
URL for the resource; null if not found

        URL resourceURL = getClass().getClassLoader().getResource(resourceName);
        return resourceURL;