FileDocCategorySizeDatePackage
TransformingClassLoader.javaAPI DocHibernate 3.2.51620Fri Mar 03 17:23:52 GMT 2006org.hibernate.bytecode.javassist

TransformingClassLoader

public class TransformingClassLoader extends ClassLoader
author
Steve Ebersole

Fields Summary
private ClassLoader
parent
private ClassPool
classPool
Constructors Summary
TransformingClassLoader(ClassLoader parent, String[] classpath)

		this.parent = parent;
		classPool = new ClassPool( true );
		for ( int i = 0; i < classpath.length; i++ ) {
			try {
				classPool.appendClassPath( classpath[i] );
			}
			catch ( NotFoundException e ) {
				throw new HibernateException(
						"Unable to resolve requested classpath for transformation [" +
						classpath[i] + "] : " + e.getMessage()
				);
			}
		}
	
Methods Summary
protected java.lang.ClassfindClass(java.lang.String name)

        try {
            CtClass cc = classPool.get( name );
	        // todo : modify the class definition if not already transformed...
            byte[] b = cc.toBytecode();
            return defineClass( name, b, 0, b.length );
        }
        catch ( NotFoundException e ) {
            throw new ClassNotFoundException();
        }
        catch ( IOException e ) {
            throw new ClassNotFoundException();
        }
        catch ( CannotCompileException e ) {
            throw new ClassNotFoundException();
        }
    
public voidrelease()

		classPool = null;
		parent = null;