Class AbstractJPPFClassLoaderLifeCycle

All Implemented Interfaces:
Closeable, AutoCloseable
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
  • Field Details

    • 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.
    • resourceCache

      protected ResourceCache resourceCache
      The cache handling resources temporarily stored to file.
    • notFoundCache

      protected final org.jppf.caching.JPPFCollectionCache<String> notFoundCache
      The cache handling resources that were not found by this class loader.
    • instanceNumber

      protected final int instanceNumber
      Uniquely identifies this class loader instance.
    • connection

      protected ClassLoaderConnection<?> connection
      The connection to the driver.
    • offline

      protected final boolean offline
      Determines whether this class laoder is in connected mode or not.
    • remoteClassLoadingDisabled

      protected final AtomicBoolean remoteClassLoadingDisabled
      Determines whether this remote class loading is enabled.
      Since:
      4.2
    • hookFactory

      protected final org.jppf.utils.hooks.HookFactory hookFactory
      To create and invoke hook instances.
  • Constructor Details

    • AbstractJPPFClassLoaderLifeCycle

      protected AbstractJPPFClassLoaderLifeCycle(ClassLoaderConnection<?> connection, ClassLoader parent, List<String> uuidPath, org.jppf.utils.hooks.HookFactory hookFactory)
      Initialize this class loader with a parent class loader.
      Parameters:
      parent - a ClassLoader instance.
      connection - the connection to the driver.
      uuidPath - unique identifier for the submitting application.
      hookFactory - a HookFactory instance.
  • Method Details

    • init

      protected void init()
      Initialize the connection to the driver.
    • reset

      protected abstract void reset()
      Reset and reinitialize the connection to the server.
    • loadResource

      protected org.jppf.classloader.JPPFResourceWrapper loadResource(Map<org.jppf.classloader.ResourceIdentifier,Object> map) throws ClassNotFoundException
      Load the specified class from a socket connection.
      Parameters:
      map - contains the necessary resource request data.
      Returns:
      a JPPFResourceWrapper containing the resource content.
      Throws:
      ClassNotFoundException - if the class could not be loaded from the remote server.
    • addURL

      public void addURL(URL url)
      Overrides:
      addURL in class URLClassLoader
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • findMultipleResources

      protected URL[] findMultipleResources(String... names)
      Get multiple resources, 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 resources, 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.
    • getConnection

      public ClassLoaderConnection<?> getConnection()
      Get the connection to the driver.
      Returns:
      a ClassLoaderConnection instance.
    • getClientUuid

      public String getClientUuid()
      Get the uuid of the JPPF client this class loader gets resources from.
      Returns:
      a client uuid as a string, or null if this class cloader is not a client class loader.
    • resetResourceCache

      public void resetResourceCache()
      Reset this class loader's resource cache. This method actually clears the cache, including removing the locally stored temp files, then creates a new cache instance.
    • close

      public void close()
      Specified by:
      close in interface AutoCloseable
      Specified by:
      close in interface Closeable
      Overrides:
      close in class URLClassLoader
    • isOffline

      public boolean isOffline()
      Determine whether this class loader is in offline mode or not.
      Returns:
      true if this class loader is offline, false otherwise.
    • setRemoteClassLoadingDisabled

      public void setRemoteClassLoadingDisabled(boolean disabled)
      Specify whether remote class loading is disabled.
      Parameters:
      disabled - true to disable remote class loading, false to enable it.
      Since:
      4.2
    • isRemoteClassLoadingDisabled

      public boolean isRemoteClassLoadingDisabled()
      Detrmine whether remote class loading is enabled.
      Returns:
      true if remote class loading is disabled, false if enabled.
      Since:
      4.2
    • getResourceCache

      public ResourceCache getResourceCache()
      Get the resource cache handled by this class loader.
      Returns:
      an instance of ResourceCache.
    • getHookFactory

      public org.jppf.utils.hooks.HookFactory getHookFactory()
      Get the factory that creates and invoke hook instances for this node.
      Returns:
      a HookFactory instance.