Class NodeClassLoader

java.lang.Object
java.lang.ClassLoader
org.jcsp.net.dynamic.NodeClassLoader

class NodeClassLoader extends ClassLoader
Custom class loader for retrieving class files from a JFTP process on another node. Each instance will spawn a child process that will keep running. When a class is requested from the loader, it will synchronize with the child process which will contact a JFTP process and wait for data. When the class arrives the original caller will resume and register the class. Using a separate thread allows the JFTP process to push other classes to the class loader. Any classes pushed in this manner will be registered when the next class is requested from the class loader.
  • Field Details

    • classReq

      private final One2OneChannel classReq
      Channel for passing requests from the findClass method to the child process.
    • classResp

      private final One2OneChannel classResp
      Channel for returning data from the child process to the findClass method.
    • classManager

      private final ClassManager classManager
      The class manager responsible for managing dynamically loaded classes at this node.
  • Constructor Details

    • NodeClassLoader

      public NodeClassLoader(NetChannelLocation sourceChannelLocation, ClassManager cm)
      Constructs a new NodeClassLoader for loading classes held by a JFTP process at another node. On construction a child thread is spawned.
      Parameters:
      sourceChannelLocation - location of the request channel of a remote JFTP process.
      cm - class manager responsible for dynamically loaded classes at this node.
  • Method Details

    • findClass

      public Class findClass(String name) throws ClassNotFoundException
      Issues a request to the child process to get a class definition from the remote JFTP process. If the JFTP process has been pushing class definitions to this node the child process may return multiple results. One of them will be the requested class. All will be registered and a note is taken of the one requested so that it can be returned.
      Overrides:
      findClass in class ClassLoader
      Parameters:
      name - name of the class to load.
      Returns:
      the class instance.
      Throws:
      ClassNotFoundException - if the remote node did not have the class.