11/*
2- * Copyright 2002-2012 the original author or authors.
2+ * Copyright 2002-2013 the original author or authors.
33 *
44 * Licensed under the Apache License, Version 2.0 (the "License");
55 * you may not use this file except in compliance with the License.
@@ -39,6 +39,13 @@ public static void premain(String agentArgs, Instrumentation inst) {
3939 instrumentation = inst ;
4040 }
4141
42+ /**
43+ * Save the {@link Instrumentation} interface exposed by the JVM.
44+ * This method is required to dynamically load this Agent with the Attach API.
45+ */
46+ public static void agentmain (String agentArgs , Instrumentation inst ) {
47+ instrumentation = inst ;
48+ }
4249
4350 /**
4451 * Return the {@link Instrumentation} interface exposed by the JVM.
@@ -48,8 +55,9 @@ public static void premain(String agentArgs, Instrumentation inst) {
4855 * {@link org.springframework.instrument.classloading.InstrumentationLoadTimeWeaver#getInstrumentation()}
4956 * instead - which will work without the agent class in the classpath as well.
5057 * @return the {@code Instrumentation} instance previously saved when
51- * the {@link #premain} method was called by the JVM; will be {@code null}
52- * if this class was not used as Java agent when this JVM was started.
58+ * the {@link #premain} or {@link #agentmain} methods was called by the JVM;
59+ * will be {@code null} if this class was not used as Java agent when this
60+ * JVM was started or it wasn't installed as agent using the Attach API.
5361 * @see org.springframework.instrument.classloading.InstrumentationLoadTimeWeaver#getInstrumentation()
5462 */
5563 public static Instrumentation getInstrumentation () {
0 commit comments