org.jppf.classloader
Class AbstractJPPFClassLoaderLifeCycle

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

public abstract class AbstractJPPFClassLoaderLifeCycle
extends URLClassLoader

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
protected  class AbstractJPPFClassLoaderLifeCycle.AbstractResourceRequest
          Encapsulates a remote resource request submitted asynchronously via the single-thread executor.
 
Field Summary
protected  org.jppf.classloader.ResourceCache cache
          The cache handling resources temporarily stored to file.
protected  boolean dynamic
          Determines whether this class loader should handle dynamic class updating.
protected static ExecutorService executor
          The executor that handles asynchronous resource requests.
protected static AtomicBoolean INITIALIZING
          Determines whether this class loader should handle dynamic class updating.
protected static ReentrantLock LOCK
          Used to synchronize access to the underlying socket from multiple threads.
protected  String requestUuid
          Uuid of the orignal task bundle that triggered a resource loading request.
protected  ObjectSerializer serializer
          The object used to serialize and deserialize resources.
protected  List<String> uuidPath
          The unique identifier for the submitting application.
 
Constructor Summary
protected AbstractJPPFClassLoaderLifeCycle(ClassLoader parent)
          Initialize this class loader with a parent class loader.
protected AbstractJPPFClassLoaderLifeCycle(ClassLoader parent, List<String> uuidPath)
          Initialize this class loader with a parent class loader.
 
Method Summary
 void addURL(URL url)
          
abstract  void close()
          Terminate this classloader and clean the resources it uses.
protected  ObjectSerializer getSerializer()
          Get the object used to serialize and deserialize resources.
protected abstract  void init()
          Initialize the underlying socket connection.
protected abstract  JPPFResourceWrapper loadRemoteData(Map<String,Object> map, boolean asResource)
          Load the specified class from a socket connection.
protected  JPPFResourceWrapper loadResourceData(Map<String,Object> map, boolean asResource)
          Load the specified class from a socket connection.
protected  JPPFResourceWrapper loadResourceData0(Map<String,Object> map, boolean asResource)
          Load the specified class from a socket connection.
abstract  void reset()
          Reset and reinitialize the connection ot the server.
 void setRequestUuid(String requestUuid)
          Set the uuid for the orignal task bundle that triggered this resource request.
 
Methods inherited from class java.net.URLClassLoader
definePackage, findClass, findResource, findResources, 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, getResourceAsStream, 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
 

Field Detail

LOCK

protected static final ReentrantLock LOCK
Used to synchronize access to the underlying socket from multiple threads.


INITIALIZING

protected static final AtomicBoolean INITIALIZING
Determines whether this class loader should handle dynamic class updating.


executor

protected static ExecutorService executor
The executor that handles asynchronous resource requests.


dynamic

protected boolean dynamic
Determines whether this class loader should handle dynamic class updating.


uuidPath

protected List<String> uuidPath
The unique identifier for the submitting application.


requestUuid

protected String requestUuid
Uuid of the orignal task bundle that triggered a resource loading request.


cache

protected org.jppf.classloader.ResourceCache cache
The cache handling resources temporarily stored to file.


serializer

protected ObjectSerializer serializer
The object used to serialize and deserialize resources.

Constructor Detail

AbstractJPPFClassLoaderLifeCycle

protected AbstractJPPFClassLoaderLifeCycle(ClassLoader parent)
Initialize this class loader with a parent class loader.

Parameters:
parent - a ClassLoader instance.

AbstractJPPFClassLoaderLifeCycle

protected AbstractJPPFClassLoaderLifeCycle(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

init

protected abstract void init()
Initialize the underlying socket connection.


reset

public abstract void reset()
Reset and reinitialize the connection ot the server.


loadResourceData

protected JPPFResourceWrapper loadResourceData(Map<String,Object> map,
                                               boolean asResource)
                                        throws ClassNotFoundException
Load the specified class from a socket connection.

Parameters:
map - contains the necessary resource request data.
asResource - true if the resource is loaded using getResource(), false otherwise.
Returns:
a JPPFResourceWrapper containing the resource content.
Throws:
ClassNotFoundException - if the class could not be loaded from the remote server.

loadResourceData0

protected JPPFResourceWrapper loadResourceData0(Map<String,Object> map,
                                                boolean asResource)
                                         throws Exception
Load the specified class from a socket connection.

Parameters:
map - contains the necessary resource request data.
asResource - true if the resource is loaded using getResource(), false otherwise.
Returns:
a JPPFResourceWrapper containing the resource content.
Throws:
Exception - if the connection was lost and could not be reestablished.

loadRemoteData

protected abstract JPPFResourceWrapper loadRemoteData(Map<String,Object> map,
                                                      boolean asResource)
                                               throws Exception
Load the specified class from a socket connection.

Parameters:
map - contains the necessary resource request data.
asResource - true if the resource is loaded using getResource(), false otherwise.
Returns:
a JPPFResourceWrapper containing the resource content.
Throws:
Exception - if the connection was lost and could not be reestablished.

setRequestUuid

public void setRequestUuid(String requestUuid)
Set the uuid for the orignal task bundle that triggered this resource request.

Parameters:
requestUuid - the uuid as a string.

close

public abstract void close()
Terminate this classloader and clean the resources it uses.


getSerializer

protected ObjectSerializer getSerializer()
                                  throws Exception
Get the object used to serialize and deserialize resources.

Returns:
an ObjectSerializer instance.
Throws:
Exception - if any error occurs.

addURL

public void addURL(URL url)

Overrides:
addURL in class URLClassLoader


Copyright © 2005-2010 JPPF Team.