Top Description Methods
org.apache.tomcat

public Interface InstrumentableClassLoader

Known Direct Implementers
org.apache.catalina.loader.WebappClassLoaderBase
Imports
java.lang.instrument.ClassFileTransformer

Specifies a class loader capable of being decorated with ClassFileTransformers. These transformers can instrument (or weave) the byte code of classes loaded through this class loader to alter their behavior. Currently only org.apache.catalina.loader.WebappClassLoaderBase implements this interface. This allows web application frameworks or JPA providers bundled with a web application to instrument web application classes as necessary.

You should always program against the methods of this interface (whether using reflection or otherwise). The methods in WebappClassLoaderBase are protected by the default security manager if one is in use.

Since
8.0, 7.0.64

Method Summary

Modifier and TypeMethod and Description
public void
addTransformer(ClassFileTransformer
The transformer to add to the class loader
transformer
)

Adds the specified class file transformer to this class loader.

public ClassLoader

Returns:

the transformer-free copy of this class loader.
copyWithoutTransformers
()

Returns a copy of this class loader without any class file transformers.

public void
removeTransformer(ClassFileTransformer
The transformer to remove
transformer
)

Removes the specified class file transformer from this class loader.

Method Detail

addTransformerback to summary
public void addTransformer(ClassFileTransformer transformer)

Adds the specified class file transformer to this class loader. The transformer will then be able to instrument the bytecode of any classes loaded by this class loader after the invocation of this method.

Parameters
transformer:ClassFileTransformer

The transformer to add to the class loader

Exceptions
IllegalArgumentException:
if the transformer is null.
copyWithoutTransformersback to summary
public ClassLoader copyWithoutTransformers()

Returns a copy of this class loader without any class file transformers. This is a tool often used by Java Persistence API providers to inspect entity classes in the absence of any instrumentation, something that can't be guaranteed within the context of a ClassFileTransformer's transform method.

The returned class loader's resource cache will have been cleared so that classes already instrumented will not be retained or returned.

Returns:ClassLoader

the transformer-free copy of this class loader.

removeTransformerback to summary
public void removeTransformer(ClassFileTransformer transformer)

Removes the specified class file transformer from this class loader. It will no longer be able to instrument the byte code of any classes loaded by the class loader after the invocation of this method. However, any classes already instrumented by this transformer before this method call will remain in their instrumented state.

Parameters
transformer:ClassFileTransformer

The transformer to remove