alt.jiapi.util
Class InstrumentingClassLoader

java.lang.Object
  extended by java.lang.ClassLoader
      extended by java.security.SecureClassLoader
          extended by java.net.URLClassLoader
              extended by alt.jiapi.util.InstrumentingClassLoader

public class InstrumentingClassLoader
extends java.net.URLClassLoader

A sample ClassLoader which can be used when instrumenting Java applications. It knows how to load classes from CLASSPATH.

NOTE: Should the jar files found from jre/lib/ext (System.getProperty("java.ext.dirs")) also be added to search path?

Version:
$Revision: 1.7 $ $Date: 2006/01/31 12:53:04 $
Author:
Mika Riekkinen, Joni Suominen

Field Summary
protected  java.util.Map classes
           
protected  InstrumentationContext ctx
           
 
Constructor Summary
protected InstrumentingClassLoader(InstrumentationContext ctx, java.net.URL[] urls, java.lang.ClassLoader parent)
           
 
Method Summary
 java.lang.Class bootstrap(java.lang.String className)
           
static java.lang.ClassLoader createClassLoader()
          Creates a new InstrumentingClassloader.
static java.lang.ClassLoader createClassLoader(InstrumentationContext ctx)
          Creates a new InstrumentingClassloader.
static java.lang.ClassLoader createClassLoader(InstrumentationContext ctx, java.lang.ClassLoader parent)
          Creates a new InstrumentingClassloader.
static java.lang.ClassLoader createClassLoader(InstrumentationContextProvider icp)
          Creates a new InstrumentingClassloader.
static java.lang.ClassLoader createClassLoader(InstrumentationContextProvider icp, java.lang.ClassLoader parent)
          Creates a new InstrumentingClassloader.
protected  java.security.CodeSource createCodeSource(java.net.URL location)
          Form a CodeSource for loaded class.
 java.lang.Class findClass(java.lang.String name)
           
protected  java.lang.Class loadClass(java.lang.String className, boolean resolve)
           
 void setContext(InstrumentationContext ctx)
          Set the context for the ClassLoader.
 
Methods inherited from class java.net.URLClassLoader
addURL, definePackage, findResource, findResources, getPermissions, getURLs, newInstance, newInstance
 
Methods inherited from class java.security.SecureClassLoader
defineClass, defineClass
 
Methods inherited from class java.lang.ClassLoader
clearAssertionStatus, defineClass, defineClass, defineClass, defineClass, definePackage, findLibrary, findLoadedClass, 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
 

Field Detail

classes

protected java.util.Map classes

ctx

protected InstrumentationContext ctx
Constructor Detail

InstrumentingClassLoader

protected InstrumentingClassLoader(InstrumentationContext ctx,
                                   java.net.URL[] urls,
                                   java.lang.ClassLoader parent)
Method Detail

bootstrap

public java.lang.Class bootstrap(java.lang.String className)
                          throws java.lang.ClassNotFoundException
Throws:
java.lang.ClassNotFoundException

createClassLoader

public static java.lang.ClassLoader createClassLoader()
Creates a new InstrumentingClassloader.


createClassLoader

public static java.lang.ClassLoader createClassLoader(InstrumentationContext ctx)
Creates a new InstrumentingClassloader.


createClassLoader

public static java.lang.ClassLoader createClassLoader(InstrumentationContext ctx,
                                                      java.lang.ClassLoader parent)
Creates a new InstrumentingClassloader.


createClassLoader

public static java.lang.ClassLoader createClassLoader(InstrumentationContextProvider icp)
                                               throws JiapiException
Creates a new InstrumentingClassloader.

Throws:
JiapiException

createClassLoader

public static java.lang.ClassLoader createClassLoader(InstrumentationContextProvider icp,
                                                      java.lang.ClassLoader parent)
                                               throws JiapiException
Creates a new InstrumentingClassloader.

Throws:
JiapiException

createCodeSource

protected java.security.CodeSource createCodeSource(java.net.URL location)
Form a CodeSource for loaded class.

Parameters:
location - a location where the class was loaded from

findClass

public java.lang.Class findClass(java.lang.String name)
                          throws java.lang.ClassNotFoundException
Overrides:
findClass in class java.net.URLClassLoader
Throws:
java.lang.ClassNotFoundException

loadClass

protected java.lang.Class loadClass(java.lang.String className,
                                    boolean resolve)
                             throws java.lang.ClassNotFoundException
Overrides:
loadClass in class java.lang.ClassLoader
Throws:
java.lang.ClassNotFoundException

setContext

public void setContext(InstrumentationContext ctx)
Set the context for the ClassLoader.

Parameters:
ctx - an InstrumentationContext to be used


Copyright © 2001. Documenation generated August 26 2011.