edu.rit.m2mi
Class M2MIClassLoader

java.lang.Object
  extended by java.lang.ClassLoader
      extended by edu.rit.m2mi.M2MIClassLoader

public class M2MIClassLoader
extends ClassLoader

Class M2MIClassLoader provides a class loader for the M2MI Layer's synthesized handle classes and method invoker classes.

When you create an instance of class M2MIClassLoader, you can specify the new M2MI class loader's parent class loader. If you do not specify the parent class loader, the system class loader is used by default.

When you create an instance of class M2MIClassLoader, you can specify the protection domain to be associated with all the synthesized handle classes and method invoker classes. This protection domain determines which security permissions apply to the handle and method invoker classes. If you do not specify the protection domain, the protection domain of class M2MIClassLoader itself is used by default; in other words, the handle and method invoker classes will get the same security permissions as the M2MI Library classes.

Note: Class M2MIClassLoader is multiple thread safe.


Constructor Summary
M2MIClassLoader()
          Construct a new M2MI class loader.
M2MIClassLoader(ClassLoader theParent)
          Construct a new M2MI class loader.
M2MIClassLoader(ClassLoader theParent, ProtectionDomain theProtectionDomain)
          Construct a new M2MI class loader.
M2MIClassLoader(ProtectionDomain theProtectionDomain)
          Construct a new M2MI class loader.
 
Method Summary
protected  Class findClass(String theClassName)
          Finds the class with the given name in this M2MI class loader.
 byte[] getClassFile(String theClassName)
          Obtain the class file for the class with the given name in this M2MI class loader.
 Class getMethodInvokerClass(MethodDescriptor theMethodDescriptor)
          Obtain the method invoker class for the given method descriptor.
 String getMethodInvokerClassName(MethodDescriptor theMethodDescriptor)
          Obtain the name of the method invoker class for the given method descriptor.
 Class getMultihandleClass(Class theTargetInterface)
          Obtain the multihandle class for the given target interface.
 String getMultihandleClassName(Class theTargetInterface)
          Obtain the name of the multihandle class for the given target interface.
 Class getOmnihandleClass(Class theTargetInterface)
          Obtain the omnihandle class for the given target interface.
 String getOmnihandleClassName(Class theTargetInterface)
          Obtain the name of the omnihandle class for the given target interface.
 Class getUnihandleClass(Class theTargetInterface)
          Obtain the unihandle class for the given target interface.
 String getUnihandleClassName(Class theTargetInterface)
          Obtain the name of the unihandle class for the given target interface.
 
Methods inherited from class java.lang.ClassLoader
clearAssertionStatus, defineClass, defineClass, defineClass, defineClass, definePackage, findLibrary, findLoadedClass, findResource, findResources, 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
 

Constructor Detail

M2MIClassLoader

public M2MIClassLoader()
Construct a new M2MI class loader. The system class loader is used as the parent class loader. The protection domain of class M2MIClassLoader will be associated with all synthesized handle and method invoker classes.

Throws:
SecurityException - (unchecked exception) Thrown if there is a security manager and it doesn't allow creation of a new class loader or it doesn't allow obtaining the protection domain of class M2MIClassLoader.

M2MIClassLoader

public M2MIClassLoader(ClassLoader theParent)
Construct a new M2MI class loader. The given class loader is used as the parent class loader. The protection domain of class M2MIClassLoader will be associated with all synthesized handle and method invoker classes.

Parameters:
theParent - Parent class loader for delegation.
Throws:
SecurityException - (unchecked exception) Thrown if there is a security manager and it doesn't allow creation of a new class loader or it doesn't allow obtaining the protection domain of class M2MIClassLoader.

M2MIClassLoader

public M2MIClassLoader(ProtectionDomain theProtectionDomain)
Construct a new M2MI class loader. The system class loader is used as the parent class loader. The given protection domain will be associated with all synthesized handle and method invoker classes.

Parameters:
theProtectionDomain - Protection domain for all handle and method invoker classes.
Throws:
SecurityException - (unchecked exception) Thrown if there is a security manager and it doesn't allow creation of a new class loader.

M2MIClassLoader

public M2MIClassLoader(ClassLoader theParent,
                       ProtectionDomain theProtectionDomain)
Construct a new M2MI class loader. The given class loader is used as the parent class loader. The given protection domain will be associated with all synthesized handle and method invoker classes.

Parameters:
theParent - Parent class loader for delegation.
theProtectionDomain - Protection domain for all handle and method invoker classes.
Throws:
SecurityException - (unchecked exception) Thrown if there is a security manager and it doesn't allow creation of a new class loader.
Method Detail

getMethodInvokerClass

public Class getMethodInvokerClass(MethodDescriptor theMethodDescriptor)
Obtain the method invoker class for the given method descriptor. The method invoker class is synthesized and loaded if necessary, then the class is returned.

Parameters:
theMethodDescriptor - Method descriptor.
Returns:
Method invoker class.
Throws:
NullPointerException - (unchecked exception) Thrown if theMethodDescriptor is null.
SynthesisException - (unchecked exception) Thrown if there was a problem synthesizing or loading the class.

getMethodInvokerClassName

public String getMethodInvokerClassName(MethodDescriptor theMethodDescriptor)
Obtain the name of the method invoker class for the given method descriptor. The method invoker class itself is not synthesized or loaded at this time, just the class name and method descriptor are recorded for later use. To synthesize the class file but not load it, call getClassFile(), passing in the class name. To synthesize the class file and load the class, call loadClass(), passing in the class name.

Parameters:
theMethodDescriptor - Method descriptor.
Returns:
Fully-qualified class name of the method invoker class.
Throws:
NullPointerException - (unchecked exception) Thrown if theMethodDescriptor is null.

getOmnihandleClass

public Class getOmnihandleClass(Class theTargetInterface)
Obtain the omnihandle class for the given target interface. The omnihandle class is synthesized and loaded if necessary, then the class is returned.

Parameters:
theTargetInterface - Target interface.
Returns:
Omnihandle class.
Throws:
NullPointerException - (unchecked exception) Thrown if theTargetInterface is null.
InvalidMethodException - (unchecked exception) Thrown if the target interface is a class rather than an interface, if any method in the target interface returns a value, or if any method in the target interface throws any checked exceptions.
SynthesisException - (unchecked exception) Thrown if there was a problem synthesizing or loading the class.

getOmnihandleClassName

public String getOmnihandleClassName(Class theTargetInterface)
Obtain the name of the omnihandle class for the given target interface. The omnihandle class itself is not synthesized or loaded at this time, just the class name and method descriptor are recorded for later use. To synthesize the class file but not load it, call getClassFile(), passing in the class name. To synthesize the class file and load the class, call loadClass(), passing in the class name.

Parameters:
theTargetInterface - Target interface.
Returns:
Fully-qualified class name of the omnihandle class.
Throws:
NullPointerException - (unchecked exception) Thrown if theTargetInterface is null.

getMultihandleClass

public Class getMultihandleClass(Class theTargetInterface)
Obtain the multihandle class for the given target interface. The multihandle class is synthesized and loaded if necessary, then the class is returned.

Parameters:
theTargetInterface - Target interface.
Returns:
Multihandle class.
Throws:
NullPointerException - (unchecked exception) Thrown if theTargetInterface is null.
InvalidMethodException - (unchecked exception) Thrown if the target interface is a class rather than an interface, if any method in the target interface returns a value, or if any method in the target interface throws any checked exceptions.
SynthesisException - (unchecked exception) Thrown if there was a problem synthesizing or loading the class.

getMultihandleClassName

public String getMultihandleClassName(Class theTargetInterface)
Obtain the name of the multihandle class for the given target interface. The multihandle class itself is not synthesized or loaded at this time, just the class name and method descriptor are recorded for later use. To synthesize the class file but not load it, call getClassFile(), passing in the class name. To synthesize the class file and load the class, call loadClass(), passing in the class name.

Parameters:
theTargetInterface - Target interface.
Returns:
Fully-qualified class name of the multihandle class.
Throws:
NullPointerException - (unchecked exception) Thrown if theTargetInterface is null.

getUnihandleClass

public Class getUnihandleClass(Class theTargetInterface)
Obtain the unihandle class for the given target interface. The unihandle class is synthesized and loaded if necessary, then the class is returned.

Parameters:
theTargetInterface - Target interface.
Returns:
Unihandle class.
Throws:
NullPointerException - (unchecked exception) Thrown if theTargetInterface is null.
InvalidMethodException - (unchecked exception) Thrown if the target interface is a class rather than an interface, if any method in the target interface returns a value, or if any method in the target interface throws any checked exceptions.
SynthesisException - (unchecked exception) Thrown if there was a problem synthesizing or loading the class.

getUnihandleClassName

public String getUnihandleClassName(Class theTargetInterface)
Obtain the name of the unihandle class for the given target interface. The unihandle class itself is not synthesized or loaded at this time, just the class name and method descriptor are recorded for later use. To synthesize the class file but not load it, call getClassFile(), passing in the class name. To synthesize the class file and load the class, call loadClass(), passing in the class name.

Parameters:
theTargetInterface - Target interface.
Returns:
Fully-qualified class name of the unihandle class.
Throws:
NullPointerException - (unchecked exception) Thrown if theTargetInterface is null.

getClassFile

public byte[] getClassFile(String theClassName)
Obtain the class file for the class with the given name in this M2MI class loader. If the class name is one that was previously returned by getMethodInvokerClassName(), getOmnihandleClassName(), getMultihandleClassName(), or getUnihandleClassName(), the class file is synthesized and returned, otherwise a SynthesisException is thrown. The class file is not loaded at this time.

Parameters:
theClassName - Fully-qualified class name.
Returns:
Synthesized class file.
Throws:
InvalidMethodException - (unchecked exception) Thrown if the target interface is a class rather than an interface, if any method in the target interface returns a value, or if any method in the target interface throws any checked exceptions.
SynthesisException - (unchecked exception) Thrown if theClassName was not returned by a previous call of getMethodInvokerClassName(), getOmnihandleClassName(), getMultihandleClassName(), or getOmnihandleClassName(). Thrown if there was a problem synthesizing the class.

findClass

protected Class findClass(String theClassName)
Finds the class with the given name in this M2MI class loader. If the class name is one that was previously returned by getMethodInvokerClassName(), getOmnihandleClassName(), getMultihandleClassName(), or getUnihandleClassName(), the class file is synthesized and the class is defined, otherwise a ClassNotFoundException is thrown.

Overrides:
findClass in class ClassLoader
Parameters:
theClassName - Fully-qualified class name.
Returns:
Class with the given name.
Throws:
InvalidMethodException - (unchecked exception) Thrown if the target interface is a class rather than an interface, if any method in the target interface returns a value, or if any method in the target interface throws any checked exceptions.
SynthesisException - (unchecked exception) Thrown if theClassName was not returned by a previous call of getMethodInvokerClassName(), getOmnihandleClassName(), getMultihandleClassName(), or getOmnihandleClassName(). Thrown if there was a problem synthesizing the class.


Copyright © 2001-2006 by Alan Kaminsky. All rights reserved. Send comments to ark­@­cs.rit.edu.