netx.jnlp.runtime

Class JNLPClassLoader


public class JNLPClassLoader
extends 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.20 $
Author:
Jon A. Maxwell (JAM) - initial author

Constructor Summary

JNLPClassLoader(JNLPFile file, UpdatePolicy policy)
Create a new JNLPClassLoader from the specified file.

Method Summary

protected void
activateJars(List jars)
Ensures that the list of jars have all been transferred, and makes them available to the classloader.
protected void
activateNative(JARDesc jar)
Enable the native code contained in a JAR by copying the native files into the filesystem.
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(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 Class
findClass(String name)
Find the class in this loader or any of its extension loaders.
String
findLibrary(String lib)
Return the absolute path to the native library.
protected String
findLibraryExt(String lib)
Try to find the library path from another peer classloader.
protected Class
findLoadedClassAll(String name)
Find the loaded class in this loader or any of its extension loaders.
Enumeration
findResources(String name)
Finds the resource in this, the parent, or the extension class loaders.
ApplicationInstance
getApplication()
Returns the JNLP app for this classloader
String
getExtensionHREF()
Deprecated.
String
getExtensionName()
Deprecated.
static JNLPClassLoader
getInstance(URL location, UpdatePolicy policy)
Returns a JNLP classloader for the JNLP file at the specified location.
static JNLPClassLoader
getInstance(JNLPFile file, UpdatePolicy policy)
Returns a JNLP classloader for the specified JNLP file.
JNLPFile
getJNLPFile()
Returns the JNLP file the classloader was created from.
protected File
getNativeDir()
Return the base directory to store native code files in.
protected PermissionCollection
getPermissions(CodeSource cs)
Returns the permissions for the CodeSource.
URL
getResource(String name)
Finds the resource in this, the parent, or the extension class loaders.
(package private) void
initializeExtensions()
Load the extensions specified in the JNLP file.
(package private) void
initializePermissions()
Make permission objects for the classpath.
(package private) void
initializeResources()
Load all of the JARs used in this JNLP file into the ResourceTracker for downloading.
Class
loadClass(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.

Constructor Details

JNLPClassLoader

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

Method Details

activateJars

protected void activateJars(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

activateNative

protected void activateNative(JARDesc jar)
Enable the native code contained in a JAR by copying the native files into the filesystem. Called in the security context of the classloader.

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

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.

fillInPartJars

protected void fillInPartJars(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).

findClass

protected Class findClass(String name)
            throws ClassNotFoundException
Find the class in this loader or any of its extension loaders.

findLibrary

public String findLibrary(String lib)
Return the absolute path to the native library.

findLibraryExt

protected String findLibraryExt(String lib)
Try to find the library path from another peer classloader.

findLoadedClassAll

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

findResources

public Enumeration findResources(String name)
            throws IOException
Finds the resource in this, the parent, or the extension class loaders.

getApplication

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

getExtensionHREF

public String getExtensionHREF()

Deprecated.


getExtensionName

public String getExtensionName()

Deprecated.


getInstance

public static JNLPClassLoader getInstance(URL location,
                                          UpdatePolicy policy)
            throws 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

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

getJNLPFile

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

getNativeDir

protected File getNativeDir()
Return the base directory to store native code files in. This method does not need to return the same directory across calls.

getPermissions

protected PermissionCollection getPermissions(CodeSource cs)
Returns the permissions for the CodeSource.

getResource

public URL getResource(String name)
Finds the resource in this, the parent, or the extension class loaders.

initializeExtensions

(package private)  void initializeExtensions()
Load the extensions specified in the JNLP file.

initializePermissions

(package private)  void initializePermissions()
Make permission objects for the classpath.

initializeResources

(package private)  void initializeResources()
Load all of the JARs used in this JNLP file into the ResourceTracker for downloading.

loadClass

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

setApplication

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