Created
April 9, 2016 13:18
-
-
Save heipacker/4439f791e202288c97f70e9c7b271bb3 to your computer and use it in GitHub Desktop.
testAgent
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.dlmu.agent.server; | |
import com.dlmu.agent.CosmosAgent; | |
import java.lang.instrument.Instrumentation; | |
/** | |
* Created by fupan on 16-4-2. | |
*/ | |
public class TestAgent { | |
/** | |
* 第一个种, 程序启动是attach | |
* VM options: -javaagent:/home/fupan/IdeaProjects/agentTest/agent-tools/target/agent-tools-1.0-SNAPSHOT.jar | |
* 第二种, 程序启动后attach | |
* attachAgent(); | |
* | |
* @param args | |
*/ | |
public static void main(String[] args) { | |
//程序启动时attach得把这个注释掉 | |
CosmosAgent.install(); | |
System.out.println("run test agent"); | |
Instrumentation instrumentation = CosmosAgent.getInstrumentation(); | |
ClassTransformerSupport.addCode(instrumentation); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment