com.googlecode.mobilityrpc.session.impl
Class SessionClassLoader

java.lang.Object
  extended by java.lang.ClassLoader
      extended by com.googlecode.mobilityrpc.session.impl.SessionClassLoader

public class SessionClassLoader
extends ClassLoader

Author:
Niall Gallagher

Constructor Summary
SessionClassLoader(MobilityControllerInternal mobilityController, UUID sessionId)
           
 
Method Summary
protected  Class<?> findClass(String name)
          Tries to find classes by requesting bytecode from remote machines.
 InputStream getResourceAsStream(String name)
           
 void processResourceResponse(ResourceResponse resourceResponse)
          Called by the thread processing an incoming ResourceResponse object.
 void setThreadLocalConnectionId(ConnectionId connectionId)
          Called by threads processing an execution request from a remote machine, to indicate to this class loader that should those threads require classes to be loaded that the class loader can request those classes from the remote machine indicated.
 
Methods inherited from class java.lang.ClassLoader
clearAssertionStatus, defineClass, defineClass, defineClass, defineClass, definePackage, findLibrary, findLoadedClass, findResource, findResources, 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

SessionClassLoader

public SessionClassLoader(MobilityControllerInternal mobilityController,
                          UUID sessionId)
Method Detail

setThreadLocalConnectionId

public void setThreadLocalConnectionId(ConnectionId connectionId)
Called by threads processing an execution request from a remote machine, to indicate to this class loader that should those threads require classes to be loaded that the class loader can request those classes from the remote machine indicated.

When threads finish processing execution requests, they should call this method supplying null for the connection id.

Parameters:
connectionId - Indicates the current connection in use by a thread processing an execution request

processResourceResponse

public void processResourceResponse(ResourceResponse resourceResponse)
Called by the thread processing an incoming ResourceResponse object. This method will look up and unblock the relevant thread which is waiting for the resource to arrive.

Parameters:
resourceResponse - Contains class bytecode or other resource which this class loader previously requested from a remote machine on behalf of a thread on this machine which tried to access a class/resource which was not loaded.

findClass

protected Class<?> findClass(String name)
                      throws ClassNotFoundException
Tries to find classes by requesting bytecode from remote machines. This method will be called by the superclass implementation of ClassLoader.loadClass(java.lang.String) when the parent class loader cannot locate the required class according to the parent delegation model of class loading.

Overrides:
findClass in class ClassLoader
Parameters:
name - The binary name of the class required
Returns:
The requested class, freshly loaded into the local JVM by requesting its bytecode from a remote machine
Throws:
ClassNotFoundException - If the requested class cannot be located on remote machines

getResourceAsStream

public InputStream getResourceAsStream(String name)
Overrides:
getResourceAsStream in class ClassLoader


Copyright © 2012. All Rights Reserved.