netx.jnlp.runtime
Class JNLPClassLoader

java.lang.Object
  |
  +--java.lang.ClassLoader
        |
        +--java.security.SecureClassLoader
              |
              +--java.net.URLClassLoader
                    |
                    +--netx.jnlp.runtime.JNLPClassLoader

public class JNLPClassLoader
extends java.net.URLClassLoader

Classloader that takes it's resources from a JNLP file. If the JNLP file defines extensions, separate classloaders for these will be created automatically. Classes are loaded with the security context when the classloader was created.

Version:
$Revision: 1.14 $
Author:
Jon A. Maxwell (JAM) - initial author

Constructor Summary
protected JNLPClassLoader(JNLPFile file, UpdatePolicy policy)
          Create a new JNLPClassLoader from the specified file.
 
Method Summary
protected  void activateJars(java.util.List jars)
          Ensures that the list of jars have all been transferred, and makes them available to the classloader.
protected  void addAvailable()
          Adds whatever resources have already been downloaded in the background.
protected  JNLPClassLoader addNextResource()
          Adds the next unused resource to the classloader.
 void enableCodeBase()
          Add applet's codebase URL.
protected  void fillInPartJars(java.util.List jars)
          Adds to the specified list of JARS any other JARs that need to be loaded at the same time as the JARs specified (ie, are in the same part).
protected  java.lang.Class findClass(java.lang.String name)
          Find the class in this loader or any of its extension loaders.
protected  java.lang.Class findLoadedClassAll(java.lang.String name)
          Find the loaded class in this loader or any of its extension loaders.
 java.util.Enumeration findResources(java.lang.String name)
          Finds the resource in this, the parent, or the extension class loaders.
 ApplicationInstance getApplication()
          Returns the JNLP app for this classloader
 java.lang.String getExtensionHREF()
           
 java.lang.String getExtensionName()
           
static JNLPClassLoader getInstance(JNLPFile file, UpdatePolicy policy)
          Returns a JNLP classloader for the specified JNLP file.
static JNLPClassLoader getInstance(java.net.URL location, UpdatePolicy policy)
          Returns a JNLP classloader for the JNLP file at the specified location.
 JNLPFile getJNLPFile()
          Returns the JNLP file the classloader was created from.
protected  java.security.PermissionCollection getPermissions(java.security.CodeSource cs)
          Returns the permissions for the CodeSource.
 java.net.URL getResource(java.lang.String name)
          Finds the resource in this, the parent, or the extension class loaders.
 java.lang.Class loadClass(java.lang.String name)
          Find a JAR in the shared 'extension' classloaders, this classloader, or one of the classloaders for the JNLP file's extensions.
 void setApplication(ApplicationInstance app)
          Sets the JNLP app this group is for; can only be called once.
 
Methods inherited from class java.net.URLClassLoader
addURL, definePackage, findResource, getURLs, newInstance, newInstance
 
Methods inherited from class java.security.SecureClassLoader
defineClass
 
Methods inherited from class java.lang.ClassLoader
defineClass, defineClass, defineClass, definePackage, findLibrary, findLoadedClass, findSystemClass, getPackage, getPackages, getParent, getResourceAsStream, getResources, getSystemClassLoader, getSystemResource, getSystemResourceAsStream, getSystemResources, loadClass, resolveClass, setSigners
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

JNLPClassLoader

protected JNLPClassLoader(JNLPFile file,
                          UpdatePolicy policy)
Create a new JNLPClassLoader from the specified file.
Parameters:
file - the JNLP file
Method Detail

getInstance

public static JNLPClassLoader getInstance(JNLPFile file,
                                          UpdatePolicy policy)
Returns a JNLP classloader for the specified JNLP file.
Parameters:
file - the file to load classes for
policy - the update policy to use when downloading resources

getInstance

public static JNLPClassLoader getInstance(java.net.URL location,
                                          UpdatePolicy policy)
                                   throws java.io.IOException,
                                          ParseException
Returns a JNLP classloader for the JNLP file at the specified location.
Parameters:
location - the file's location
policy - the update policy to use when downloading resources

enableCodeBase

public void enableCodeBase()
Add applet's codebase URL. This allows compatibility with applets that load resources from their codebase instead of through JARs, but can slow down resource loading. Resources loaded from the codebase are not cached.

setApplication

public void setApplication(ApplicationInstance app)
Sets the JNLP app this group is for; can only be called once.

getApplication

public ApplicationInstance getApplication()
Returns the JNLP app for this classloader

getJNLPFile

public JNLPFile getJNLPFile()
Returns the JNLP file the classloader was created from.

getPermissions

protected java.security.PermissionCollection getPermissions(java.security.CodeSource cs)
Returns the permissions for the CodeSource.
Overrides:
getPermissions in class java.net.URLClassLoader

fillInPartJars

protected void fillInPartJars(java.util.List jars)
Adds to the specified list of JARS any other JARs that need to be loaded at the same time as the JARs specified (ie, are in the same part).

activateJars

protected void activateJars(java.util.List jars)
Ensures that the list of jars have all been transferred, and makes them available to the classloader. If a jar contains native code, the libraries will be extracted and placed in the path.
Parameters:
jars - the list of jars to load

findLoadedClassAll

protected java.lang.Class findLoadedClassAll(java.lang.String name)
Find the loaded class in this loader or any of its extension loaders.

loadClass

public java.lang.Class loadClass(java.lang.String name)
                          throws java.lang.ClassNotFoundException
Find a JAR in the shared 'extension' classloaders, this classloader, or one of the classloaders for the JNLP file's extensions.
Overrides:
loadClass in class java.lang.ClassLoader

findClass

protected java.lang.Class findClass(java.lang.String name)
                             throws java.lang.ClassNotFoundException
Find the class in this loader or any of its extension loaders.
Overrides:
findClass in class java.net.URLClassLoader

getResource

public java.net.URL getResource(java.lang.String name)
Finds the resource in this, the parent, or the extension class loaders.
Overrides:
getResource in class java.lang.ClassLoader

findResources

public java.util.Enumeration findResources(java.lang.String name)
                                    throws java.io.IOException
Finds the resource in this, the parent, or the extension class loaders.
Overrides:
findResources in class java.net.URLClassLoader

addAvailable

protected void addAvailable()
Adds whatever resources have already been downloaded in the background.

addNextResource

protected JNLPClassLoader addNextResource()
Adds the next unused resource to the classloader. That resource and all those in the same part will be downloaded and added to the classloader before returning. If there are no more resources to add, the method returns immediately.
Returns:
the classloader that resources were added to, or null

getExtensionName

public java.lang.String getExtensionName()

getExtensionHREF

public java.lang.String getExtensionHREF()