org.jboss.aop.standalone
Class SystemClassLoader

java.lang.Object
  extended by java.lang.ClassLoader
      extended by org.jboss.aop.standalone.SystemClassLoader

public class SystemClassLoader
extends ClassLoader

A classloader that can be installed as the system classloader to enable aop translation based on files in META-INF/jboss-aop.xml in the classpath.

You will need the following jars in your classpath (log4j.jar is optional):

Start the virtual machine with something like the following command:
 java -Djava.system.class.loader=org.jboss.aop.standalone.SystemClassLoader my.Main
 
Implementation Detail: All access to non-jre classes must be done through reflection the classes must be loaded using the loadLocally method.

Version:
$Revision: 71279 $
Author:
Adrian Brock, Juha Lindfors

Constructor Summary
SystemClassLoader(ClassLoader parent)
          Construct a new system classloader.
 
Method Summary
protected  Class<?> defineClassFromBytes(String name, org.jboss.aop.standalone.SystemClassLoader.ClassBytes bytes, boolean resolve)
          Define a class from the bytes
protected  void definePackage(String className)
          Define the package for the class if not already done
protected  void initialize()
          Initialize the aspect manager and load the static aspects
protected  void install()
          Install the classloader, get reflection objects and load classes using ourself.
 Class<?> loadClass(String name, boolean resolve)
          Load a class, overridden to transform aop enhanced classes and load non jre classes through this classloader.
protected  Class<?> loadClassByDelegation(String name)
          Load jre classes from the parent classloader
protected  org.jboss.aop.standalone.SystemClassLoader.ClassBytes loadClassBytes(String name)
          Load the bytecode for a class
protected  Class<?> loadClassLocally(String name)
          Load a class using this classloader only
 
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
 

Constructor Detail

SystemClassLoader

public SystemClassLoader(ClassLoader parent)
Construct a new system classloader.

We cannot do much here, we need to avoid recursion

Parameters:
parent - the default system classloader
Method Detail

loadClass

public Class<?> loadClass(String name,
                          boolean resolve)
                   throws ClassNotFoundException
Load a class, overridden to transform aop enhanced classes and load non jre classes through this classloader.

Overrides:
loadClass in class ClassLoader
Parameters:
name - the class name
resolve - whether to resolve the class
Returns:
the class
Throws:
ClassNotFoundException - when there is no class

loadClassBytes

protected org.jboss.aop.standalone.SystemClassLoader.ClassBytes loadClassBytes(String name)
                                                                        throws ClassNotFoundException,
                                                                               IOException
Load the bytecode for a class

Throws:
ClassNotFoundException
IOException

defineClassFromBytes

protected Class<?> defineClassFromBytes(String name,
                                        org.jboss.aop.standalone.SystemClassLoader.ClassBytes bytes,
                                        boolean resolve)
Define a class from the bytes

Parameters:
b - the bytecode
resolve - whether to resolve the class

definePackage

protected void definePackage(String className)
Define the package for the class if not already done

Parameters:
name - the class name

loadClassLocally

protected Class<?> loadClassLocally(String name)
                             throws ClassNotFoundException
Load a class using this classloader only

Parameters:
name - the class name
Returns:
the class
Throws:
ClassNotFoundException - when there is no class

loadClassByDelegation

protected Class<?> loadClassByDelegation(String name)
                                  throws ClassNotFoundException
Load jre classes from the parent classloader

Parameters:
name - the class name
Returns:
the class
Throws:
ClassNotFoundException - when there is no class

install

protected void install()
Install the classloader, get reflection objects and load classes using ourself.


initialize

protected void initialize()
Initialize the aspect manager and load the static aspects



Copyright © 2008 JBoss, a division of Red Hat, Inc.. All Rights Reserved.