mirror of
https://github.com/wahyd4/pinpoint.git
synced 2026-08-20 10:16:13 +10:00
- version을 0.0.2에서 0.0.3-SNAPSHOT으로 변경. git-svn-id: http://svn.bds.nhncorp.com/pe/hippo-tomcat-profiler/trunk@1730 84d0f5b1-2673-498c-a247-62c4ff18d310
59 lines
2.2 KiB
Java
59 lines
2.2 KiB
Java
package com.profiler.modifier.servlet;
|
|
|
|
import java.security.ProtectionDomain;
|
|
import com.profiler.logging.Logger;
|
|
import com.profiler.logging.LoggerFactory;
|
|
|
|
import com.profiler.Agent;
|
|
import com.nhn.pinpoint.common.ServiceType;
|
|
import com.profiler.interceptor.Interceptor;
|
|
import com.profiler.interceptor.bci.ByteCodeInstrumentor;
|
|
import com.profiler.interceptor.bci.InstrumentClass;
|
|
import com.profiler.interceptor.bci.InstrumentException;
|
|
import com.profiler.modifier.AbstractModifier;
|
|
|
|
/**
|
|
*
|
|
* @author netspider
|
|
*
|
|
*/
|
|
public class SpringFrameworkServletModifier extends AbstractModifier {
|
|
|
|
private final Logger logger = LoggerFactory.getLogger(SpringFrameworkServletModifier.class);
|
|
|
|
public SpringFrameworkServletModifier(ByteCodeInstrumentor byteCodeInstrumentor, Agent agent) {
|
|
super(byteCodeInstrumentor, agent);
|
|
}
|
|
|
|
public String getTargetClass() {
|
|
return "org/springframework/web/servlet/FrameworkServlet";
|
|
}
|
|
|
|
public byte[] modify(ClassLoader classLoader, String javassistClassName, ProtectionDomain protectedDomain, byte[] classFileBuffer) {
|
|
if (logger.isInfoEnabled()) {
|
|
logger.info("Modifing. {}", javassistClassName);
|
|
}
|
|
|
|
byteCodeInstrumentor.checkLibrary(classLoader, javassistClassName);
|
|
|
|
try {
|
|
Interceptor doGetInterceptor = byteCodeInstrumentor.newInterceptor(classLoader, protectedDomain, "com.profiler.modifier.method.interceptors.MethodInterceptor");
|
|
setServiceType(doGetInterceptor, ServiceType.SPRING_MVC);
|
|
|
|
Interceptor doPostInterceptor = byteCodeInstrumentor.newInterceptor(classLoader, protectedDomain, "com.profiler.modifier.method.interceptors.MethodInterceptor");
|
|
setServiceType(doPostInterceptor, ServiceType.SPRING_MVC);
|
|
|
|
|
|
|
|
InstrumentClass servlet = byteCodeInstrumentor.getClass(javassistClassName);
|
|
servlet.addInterceptor("doGet", new String[] { "javax.servlet.http.HttpServletRequest", "javax.servlet.http.HttpServletResponse" }, doGetInterceptor);
|
|
|
|
servlet.addInterceptor("doPost", new String[] { "javax.servlet.http.HttpServletRequest", "javax.servlet.http.HttpServletResponse" }, doPostInterceptor);
|
|
|
|
return servlet.toBytecode();
|
|
} catch (InstrumentException e) {
|
|
logger.warn("modify fail. Cause:" + e.getMessage(), e);
|
|
return null;
|
|
}
|
|
}
|
|
} |