com.acciente.commons.loader
Class ByteCodeClassLoader

java.lang.Object
  extended by java.lang.ClassLoader
      extended by java.security.SecureClassLoader
          extended by com.acciente.commons.loader.ByteCodeClassLoader

public class ByteCodeClassLoader
extends SecureClassLoader

A classloader to load a class using the byte code data

Author:
Adinath Raveendra Raj

Constructor Summary
ByteCodeClassLoader()
          Creates a class loader with no parent class loader, this is expected to cause the system class loader to be used as the parent class loader
ByteCodeClassLoader(ClassLoader oParentClassLoader)
          Creates a class loader that delegates to the specified parent class loader
 
Method Summary
 void addClassDef(String sClassName, byte[] ayClassByteCode)
          Add a class defined by its byte code to this loader.
protected  Class findClass(String sClassName)
          Override the default implementation of the standard findClass() method to load in our classes defined via addClassDef()
 
Methods inherited from class java.security.SecureClassLoader
defineClass, defineClass, getPermissions
 
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

ByteCodeClassLoader

public ByteCodeClassLoader()
Creates a class loader with no parent class loader, this is expected to cause the system class loader to be used as the parent class loader


ByteCodeClassLoader

public ByteCodeClassLoader(ClassLoader oParentClassLoader)
Creates a class loader that delegates to the specified parent class loader

Parameters:
oParentClassLoader - the parent class loader
Method Detail

addClassDef

public void addClassDef(String sClassName,
                        byte[] ayClassByteCode)
Add a class defined by its byte code to this loader.

Parameters:
sClassName - the class name
ayClassByteCode - the byte code buffer

findClass

protected Class findClass(String sClassName)
                   throws ClassNotFoundException
Override the default implementation of the standard findClass() method to load in our classes defined via addClassDef()

Overrides:
findClass in class ClassLoader
Parameters:
sClassName - the name of the class to load
Returns:
a newly loaded Class object representing sClassName
Throws:
ClassNotFoundException - thrown if this method was unable to load a clas corresponding to sClassName


Copyright © 2008-2013 Acciente, LLC. All Rights Reserved.