org.jppf.classloader
Class AbstractJPPFClassLoader

java.lang.Object
  extended by java.lang.ClassLoader
      extended by java.security.SecureClassLoader
          extended by java.net.URLClassLoader
              extended by org.jppf.classloader.AbstractJPPFClassLoaderLifeCycle
                  extended by org.jppf.classloader.AbstractJPPFClassLoader
Direct Known Subclasses:
JPPFClassLoader, JPPFLocalClassLoader

public abstract class AbstractJPPFClassLoader
extends AbstractJPPFClassLoaderLifeCycle

This class is a custom class loader serving the purpose of dynamically loading the JPPF classes and the client application classes, to avoid costly redeployment system-wide.

Author:
Laurent Cohen

Nested Class Summary
 
Nested classes/interfaces inherited from class org.jppf.classloader.AbstractJPPFClassLoaderLifeCycle
AbstractJPPFClassLoaderLifeCycle.AbstractResourceRequest
 
Field Summary
 
Fields inherited from class org.jppf.classloader.AbstractJPPFClassLoaderLifeCycle
cache, dynamic, executor, INITIALIZING, LOCK, requestUuid, serializer, uuidPath
 
Constructor Summary
AbstractJPPFClassLoader(ClassLoader parent)
          Initialize this class loader with a parent class loader.
AbstractJPPFClassLoader(ClassLoader parent, List<String> uuidPath)
          Initialize this class loader with a parent class loader.
 
Method Summary
 byte[] computeRemoteData(byte[] callable)
          Request the remote computation of a JPPFCallable on the client.
 Class<?> findClass(String name)
          Find a class in this class loader's classpath.
protected  URL[] findMultipleResources(String... names)
          Get multiple reources, specified by their names, from the classpath.
 URL findResource(String name)
          Finds the resource with the specified name.
 Enumeration<URL> findResources(String name)
          Find all resources with the specified name.
 URL[] getMultipleResources(String... names)
          Get multiple reources, specified by their names, from the classpath.
 InputStream getResourceAsStream(String name)
          Get a stream from a resource file accessible form this class loader.
 Class<?> loadJPPFClass(String name)
          Load a JPPF class from the server.
 
Methods inherited from class org.jppf.classloader.AbstractJPPFClassLoaderLifeCycle
addURL, close, getSerializer, init, loadRemoteData, loadResourceData, loadResourceData0, reset, setRequestUuid
 
Methods inherited from class java.net.URLClassLoader
definePackage, getPermissions, getURLs, newInstance, newInstance
 
Methods inherited from class java.security.SecureClassLoader
defineClass, defineClass
 
Methods inherited from class java.lang.ClassLoader
clearAssertionStatus, defineClass, defineClass, defineClass, defineClass, definePackage, findLibrary, findLoadedClass, findSystemClass, getPackage, getPackages, getParent, getResource, getResources, getSystemClassLoader, getSystemResource, getSystemResourceAsStream, getSystemResources, loadClass, loadClass, resolveClass, setClassAssertionStatus, setDefaultAssertionStatus, setPackageAssertionStatus, setSigners
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AbstractJPPFClassLoader

public AbstractJPPFClassLoader(ClassLoader parent)
Initialize this class loader with a parent class loader.

Parameters:
parent - a ClassLoader instance.

AbstractJPPFClassLoader

public AbstractJPPFClassLoader(ClassLoader parent,
                               List<String> uuidPath)
Initialize this class loader with a parent class loader.

Parameters:
parent - a ClassLoader instance.
uuidPath - unique identifier for the submitting application.
Method Detail

loadJPPFClass

public Class<?> loadJPPFClass(String name)
                       throws ClassNotFoundException
Load a JPPF class from the server.

Parameters:
name - the binary name of the class
Returns:
the resulting Class object
Throws:
ClassNotFoundException - if the class could not be found

findClass

public Class<?> findClass(String name)
                   throws ClassNotFoundException
Find a class in this class loader's classpath.

Overrides:
findClass in class URLClassLoader
Parameters:
name - binary name of the resource to find.
Returns:
a defined Class instance.
Throws:
ClassNotFoundException - if the class could not be loaded.
See Also:
ClassLoader.findClass(java.lang.String)

computeRemoteData

public byte[] computeRemoteData(byte[] callable)
                         throws Exception
Request the remote computation of a JPPFCallable on the client.

Parameters:
callable - the serialized callable to execute remotely.
Returns:
an array of bytes containing the result of the callable's execution.
Throws:
Exception - if the connection was lost and could not be reestablished.

findResource

public URL findResource(String name)
Finds the resource with the specified name. The resource lookup order is the same as the one specified by getResourceAsStream(String)

Overrides:
findResource in class URLClassLoader
Parameters:
name - the name of the resource to find.
Returns:
the URL of the resource.
See Also:
ClassLoader.findResource(java.lang.String)

getResourceAsStream

public InputStream getResourceAsStream(String name)
Get a stream from a resource file accessible form this class loader. The lookup order is defined as follows:

Overrides:
getResourceAsStream in class ClassLoader
Parameters:
name - name of the resource to obtain a stream from.
Returns:
an InputStream instance, or null if the resource was not found.
See Also:
ClassLoader.getResourceAsStream(java.lang.String)

findResources

public Enumeration<URL> findResources(String name)
                               throws IOException
Find all resources with the specified name.

Overrides:
findResources in class URLClassLoader
Parameters:
name - name of the resources to find in the clas loader's classpath.
Returns:
An enumeration of URLs pointing to the resources found.
Throws:
IOException - if an error occurs.
See Also:
ClassLoader.findResources(java.lang.String)

findMultipleResources

protected URL[] findMultipleResources(String... names)
Get multiple reources, specified by their names, from the classpath. This method functions like #getResource(String), except that it look up and returns multiple URLs.

Parameters:
names - the names of te resources to find.
Returns:
an array of URLs, one for each looked up resources. Some URLs may be null, however the returned array is never null, and results are in the same order as the specified resource names.

getMultipleResources

public URL[] getMultipleResources(String... names)
Get multiple reources, specified by their names, from the classpath. This method functions like #getResource(String), except that it looks up and returns multiple URLs.

Parameters:
names - the names of te resources to find.
Returns:
an array of URLs, one for each looked up resources. Some URLs may be null, however the returned array is never null, and results are in the same order as the specified resource names.


Copyright © 2005-2010 JPPF Team.