org.springsource.loaded.agent
Class SpringPlugin

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

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

First stab at the Spring plugin for Spring-Loaded. Notes...

Since:
0.5.0

Field Summary
static java.util.List<java.lang.Object> instancesOf_AnnotationMethodHandlerAdapter
           
static java.util.List<java.lang.Object> instancesOf_DefaultAnnotationHandlerMapping
           
static java.util.List<java.lang.Object> instancesOf_RequestMappingHandlerMapping
           
static boolean support305
           
 
Constructor Summary
SpringPlugin()
           
 
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 recordAnnotationMethodHandlerAdapterInstance(java.lang.Object obj)
           
static void recordDefaultAnnotationHandlerMappingInstance(java.lang.Object obj)
           
static void recordRequestMappingHandlerMappingInstance(java.lang.Object obj)
           
 void reloadEvent(java.lang.String typename, java.lang.Class<?> clazz, 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
 

Field Detail

instancesOf_AnnotationMethodHandlerAdapter

public static java.util.List<java.lang.Object> instancesOf_AnnotationMethodHandlerAdapter

instancesOf_DefaultAnnotationHandlerMapping

public static java.util.List<java.lang.Object> instancesOf_DefaultAnnotationHandlerMapping

instancesOf_RequestMappingHandlerMapping

public static java.util.List<java.lang.Object> instancesOf_RequestMappingHandlerMapping

support305

public static boolean support305
Constructor Detail

SpringPlugin

public SpringPlugin()
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 if this plugin wants to change the bytes for the named type

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

recordAnnotationMethodHandlerAdapterInstance

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

recordRequestMappingHandlerMappingInstance

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

recordDefaultAnnotationHandlerMappingInstance

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

reloadEvent

public void reloadEvent(java.lang.String typename,
                        java.lang.Class<?> clazz,
                        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
clazz - 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