org.springsource.loaded.agent
Class GrailsPlugin

java.lang.Object
  extended by org.springsource.loaded.agent.GrailsPlugin
All Implemented Interfaces:
LoadtimeInstrumentationPlugin, Plugin, ReloadEventProcessorPlugin

public class GrailsPlugin
extends java.lang.Object
implements LoadtimeInstrumentationPlugin, ReloadEventProcessorPlugin

Since:
0.7.3

Constructor Summary
GrailsPlugin()
           
 
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.
static void recordInstance(java.lang.Object obj)
           
 void reloadEvent(java.lang.String typename, java.lang.Class<?> reloadedClazz, java.lang.String versionsuffix)
          Called when a type has been reloaded.
 boolean shouldRerunStaticInitializer(java.lang.String typename, java.lang.Class<?> clazz, java.lang.String encodedTimestamp)
          Called when a type has been reloaded, allows the plugin to decide if the static initializer should be re-run for the reloaded type.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

GrailsPlugin

public GrailsPlugin()
Method Detail

accept

public boolean accept(java.lang.String slashedTypeName,
                      java.lang.ClassLoader classLoader,
                      java.security.ProtectionDomain protectionDomain,
                      byte[] bytes)
Description copied from interface: LoadtimeInstrumentationPlugin
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.

Specified by:
accept in interface LoadtimeInstrumentationPlugin
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:
true for types this plugin would like to change on startup

modify

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

Specified by:
modify in interface LoadtimeInstrumentationPlugin
classLoader - the classloader loading the type
bytes - the classfile contents for the type
Returns:
the new (modified) bytes for the class

recordInstance

public static void recordInstance(java.lang.Object obj)

reloadEvent

public void reloadEvent(java.lang.String typename,
                        java.lang.Class<?> reloadedClazz,
                        java.lang.String versionsuffix)
Description copied from interface: ReloadEventProcessorPlugin
Called when a type has been reloaded. Note, the class is only truly defined to the VM once, and so the Class object (clazz parameter) is always the same for the same type (ignoring multiple classloader situations). It is passed here so that plugins processing events can clear any cached state related to it. The encodedTimestamp is an encoding of the ID that the agent has assigned to this reloaded version of this type.

Specified by:
reloadEvent in interface ReloadEventProcessorPlugin
Parameters:
typename - the (dotted) type name, for example java.lang.String
reloadedClazz - the Class object that has been reloaded
versionsuffix - an encoded time stamp for this version, containing chars (A-Za-z0-9)

shouldRerunStaticInitializer

public boolean shouldRerunStaticInitializer(java.lang.String typename,
                                            java.lang.Class<?> clazz,
                                            java.lang.String encodedTimestamp)
Description copied from interface: ReloadEventProcessorPlugin
Called when a type has been reloaded, allows the plugin to decide if the static initializer should be re-run for the reloaded type. If the reloaded type has a different static initializer, the new one is the one that will run.

Specified by:
shouldRerunStaticInitializer in interface ReloadEventProcessorPlugin
Parameters:
typename - the (dotted) type name, for example java.lang.String
clazz - the Class object that has been reloaded
encodedTimestamp - an encoded time stamp for this version, containing chars (A-Za-z0-9)
Returns:
true if the static initializer should be re-run