org.springframework.instrument.classloading
Class SimpleLoadTimeWeaver

java.lang.Object
  extended by org.springframework.instrument.classloading.SimpleLoadTimeWeaver
All Implemented Interfaces:
LoadTimeWeaver

public class SimpleLoadTimeWeaver
extends java.lang.Object
implements LoadTimeWeaver

LoadTimeWeaver that builds and exposes a SimpleInstrumentableClassLoader.

Mainly intended for testing environments, where it is sufficient to perform all class transformation on a newly created ClassLoader instance.

Since:
2.0
Author:
Rod Johnson, Juergen Hoeller
See Also:
getInstrumentableClassLoader(), SimpleInstrumentableClassLoader, ReflectiveLoadTimeWeaver

Field Summary
private  SimpleInstrumentableClassLoader classLoader
           
 
Constructor Summary
SimpleLoadTimeWeaver()
          Create a new SimpleLoadTimeWeaver for the current context ClassLoader.
SimpleLoadTimeWeaver(SimpleInstrumentableClassLoader classLoader)
          Create a new SimpleLoadTimeWeaver for the given ClassLoader.
 
Method Summary
 void addTransformer(java.lang.instrument.ClassFileTransformer transformer)
          Add a ClassFileTransformer to be applied by this LoadTimeWeaver.
 java.lang.ClassLoader getInstrumentableClassLoader()
          Return a ClassLoader that supports instrumentation through AspectJ-style load-time weaving based on user-defined ClassFileTransformers.
 java.lang.ClassLoader getThrowawayClassLoader()
          This implementation builds a SimpleThrowawayClassLoader.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

classLoader

private final SimpleInstrumentableClassLoader classLoader
Constructor Detail

SimpleLoadTimeWeaver

public SimpleLoadTimeWeaver()
Create a new SimpleLoadTimeWeaver for the current context ClassLoader.

See Also:
SimpleInstrumentableClassLoader

SimpleLoadTimeWeaver

public SimpleLoadTimeWeaver(SimpleInstrumentableClassLoader classLoader)
Create a new SimpleLoadTimeWeaver for the given ClassLoader.

Parameters:
classLoader - the ClassLoader to build a simple instrumentable ClassLoader on top of
Method Detail

addTransformer

public void addTransformer(java.lang.instrument.ClassFileTransformer transformer)
Description copied from interface: LoadTimeWeaver
Add a ClassFileTransformer to be applied by this LoadTimeWeaver.

Specified by:
addTransformer in interface LoadTimeWeaver
Parameters:
transformer - the ClassFileTransformer to add

getInstrumentableClassLoader

public java.lang.ClassLoader getInstrumentableClassLoader()
Description copied from interface: LoadTimeWeaver
Return a ClassLoader that supports instrumentation through AspectJ-style load-time weaving based on user-defined ClassFileTransformers.

May be the current ClassLoader, or a ClassLoader created by this LoadTimeWeaver instance.

Specified by:
getInstrumentableClassLoader in interface LoadTimeWeaver
Returns:
the ClassLoader which will expose instrumented classes according to the registered transformers

getThrowawayClassLoader

public java.lang.ClassLoader getThrowawayClassLoader()
This implementation builds a SimpleThrowawayClassLoader.

Specified by:
getThrowawayClassLoader in interface LoadTimeWeaver
Returns:
a temporary throwaway ClassLoader; should return a new instance for each call, with no existing state