public class

TomcatInstrumentableClassLoader

extends WebappClassLoader
java.lang.Object
   ↳ WebappClassLoader
     ↳ org.springframework.instrument.classloading.tomcat.TomcatInstrumentableClassLoader

Class Overview

Extension of Tomcat's default class loader which adds instrumentation to loaded classes without the need to use a VM-wide agent.

To be registered using a Loader tag in Tomcat's Context definition in the server.xml file, with the Spring-provided "spring-tomcat-weaver.jar" file deployed into Tomcat's "server/lib" (for Tomcat 5.x) or "lib" (for Tomcat 6.x) directory. The required configuration tag looks as follows:

<Loader loaderClass="org.springframework.instrument.classloading.tomcat.TomcatInstrumentableClassLoader"/>

Typically used in combination with a ReflectiveLoadTimeWeaver defined in the Spring application context. The addTransformer and getThrowawayClassLoader methods mirror the corresponding methods in the LoadTimeWeaver interface, as expected by ReflectiveLoadTimeWeaver.

See the PetClinic sample application for a full example of this ClassLoader in action.

NOTE: Requires Apache Tomcat version 5.0 or higher.

Summary

Public Constructors
TomcatInstrumentableClassLoader()
Create a new TomcatInstrumentableClassLoader using the current context class loader.
TomcatInstrumentableClassLoader(ClassLoader parent)
Create a new TomcatInstrumentableClassLoader with the supplied class loader as parent.
Public Methods
void addTransformer(ClassFileTransformer transformer)
Delegate for LoadTimeWeaver's addTransformer method.
ClassLoader getThrowawayClassLoader()
Delegate for LoadTimeWeaver's getThrowawayClassLoader method.
String toString()
Protected Methods
ResourceEntry findResourceInternal(String name, String path)
[Expand]
Inherited Methods
From class java.lang.Object

Public Constructors

public TomcatInstrumentableClassLoader ()

Create a new TomcatInstrumentableClassLoader using the current context class loader.

public TomcatInstrumentableClassLoader (ClassLoader parent)

Create a new TomcatInstrumentableClassLoader with the supplied class loader as parent.

Parameters
parent the parent ClassLoader to be used

Public Methods

public void addTransformer (ClassFileTransformer transformer)

Delegate for LoadTimeWeaver's addTransformer method. Typically called through ReflectiveLoadTimeWeaver.

public ClassLoader getThrowawayClassLoader ()

Delegate for LoadTimeWeaver's getThrowawayClassLoader method. Typically called through ReflectiveLoadTimeWeaver.

public String toString ()

Protected Methods

protected ResourceEntry findResourceInternal (String name, String path)