org.springsource.loaded
Interface LoadtimeInstrumentationPlugin

All Superinterfaces:
Plugin
All Known Implementing Classes:
CglibPlugin, GrailsPlugin, GroovyPlugin, JVMPlugin, SpringPlugin

public interface LoadtimeInstrumentationPlugin
extends Plugin

Plugins that implement this interface are allowed to modify types as they are loaded - this can be necessary sometimes to ensure, for example, that a particular field is accessible later when a reload event occurs or that some factory method returns a wrapper rather than the original object it intended to. For information on how to register plugins with the agent, see Plugin

Since:
0.5.0

Method Summary
 boolean accept(java.lang.String slashedTypeName, java.lang.ClassLoader classLoader, java.security.ProtectionDomain protectionDomain, byte[] bytes)
          Called by the agent to determine if this plugin is interested in changing the specified type at load time.
 byte[] modify(java.lang.String slashedClassName, java.lang.ClassLoader classLoader, byte[] bytes)
          Once accept has returned true for a type, the modify method will be called to make the actual change to the classfile bytes.
 

Method Detail

accept

boolean accept(java.lang.String slashedTypeName,
               java.lang.ClassLoader classLoader,
               java.security.ProtectionDomain protectionDomain,
               byte[] bytes)
Called by the agent to determine if this plugin is interested in changing the specified type at load time. This is used when the plugin wishes to do some kind of transformation itself before the type is loaded - for example modify it to record something that will later be used on a reload event.

Parameters:
slashedTypeName - the type name, slashed form (e.g. java/lang/String)
classLoader - the classloader loading the type
protectionDomain -
bytes - the classfile contents for the type
Returns:
true if this plugin wants to change the bytes for the named type

modify

byte[] modify(java.lang.String slashedClassName,
              java.lang.ClassLoader classLoader,
              byte[] bytes)
Once accept has returned true for a type, the modify method will be called to make the actual change to the classfile bytes.

Parameters:
slashedTypeName - the type name, slashed form (e.g. java/lang/String)
classLoader - the classloader loading the type
bytes - the classfile contents for the type
Returns:
the new (modified) bytes for the class