org.objectweb.dsrg.sofa
Class SOFAClassLoader

java.lang.Object
  extended by java.lang.ClassLoader
      extended by org.objectweb.dsrg.sofa.SOFAClassLoader

public class SOFAClassLoader
extends java.lang.ClassLoader

SOFA2 custom classloader aware of the CodeBundle concept.

Use this classloader to load classes stored in CodeBundle in sofa repository.

There is only one instance of this classloader in JVM accessible with static method.


Method Summary
 CodeBundle getCodeBundle(java.lang.Class<?> cl)
          Returns CodeBundle the specified class originates from.
static SOFAClassLoader getSOFAClassLoader()
          Returns systemwide instance of SOFAClassLoader.
 java.lang.Class<?> loadClass(byte[] b, java.lang.String name)
          Loads class stored in byte array in classfile format.
 java.lang.Class<?> loadClass(CodeBundle bundle, java.lang.String className)
          Loads class stored in CodeBundle and its dependancies.
 java.lang.Class<?> loadClass(java.lang.String className)
          Loads class of given name.
 
Methods inherited from class java.lang.ClassLoader
clearAssertionStatus, defineClass, defineClass, defineClass, defineClass, definePackage, findClass, findLibrary, findLoadedClass, findResource, findResources, findSystemClass, getPackage, getPackages, getParent, getResource, getResourceAsStream, getResources, getSystemClassLoader, getSystemResource, getSystemResourceAsStream, getSystemResources, loadClass, resolveClass, setClassAssertionStatus, setDefaultAssertionStatus, setPackageAssertionStatus, setSigners
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

getSOFAClassLoader

public static SOFAClassLoader getSOFAClassLoader()
Returns systemwide instance of SOFAClassLoader. Use this instance for all clases.

Returns:
SOFAClassLoader instance.

getCodeBundle

public CodeBundle getCodeBundle(java.lang.Class<?> cl)
Returns CodeBundle the specified class originates from.

Parameters:
cl - Class you want to know originating CodeBundle.
Returns:
CodeBundle containing specified class.

loadClass

public java.lang.Class<?> loadClass(java.lang.String className)
                             throws java.lang.ClassNotFoundException
Loads class of given name. If such class not found ClassNotFoundException exception is thrown.

Primarily class is searched in standard locations. See SystemClassLoader.

If called from code loaded from CodeBundle then this CodeBundle is searched for given class.

Overrides:
loadClass in class java.lang.ClassLoader
Parameters:
className - Name of the class you want to load.
Returns:
Loaded class or exception if failed.
Throws:
java.lang.ClassNotFoundException

loadClass

public java.lang.Class<?> loadClass(CodeBundle bundle,
                                    java.lang.String className)
                             throws java.lang.ClassNotFoundException
Loads class stored in CodeBundle and its dependancies.

Parameters:
bundle - CodeBundle to search for requested class. If null class is searched on the classpath.
className - Name of the requested class.
Returns:
Returns loaded class.
Throws:
java.lang.ClassNotFoundException

loadClass

public java.lang.Class<?> loadClass(byte[] b,
                                    java.lang.String name)
Loads class stored in byte array in classfile format.

Parameters:
b - Byte array containing data in standard classfile format.
name - Expected name of the class.
Returns:
Returns loaded class.