use of com.creditease.uav.monitorframework.dproxy.DynamicProxyProcessor in project uavstack by uavorg.
the class LogBackHookProxy method InsertIntercept.
private void InsertIntercept(HookContext context, ClassLoader webapploader) {
if (isHookEventDone("insertLogbackIntercepter")) {
return;
}
ServerVendor vendor = (ServerVendor) UAVServer.instance().getServerInfo(CaptureConstants.INFO_APPSERVER_VENDOR);
if (vendor == ServerVendor.SPRINGBOOT) {
return;
}
/**
* set the webapploader is the target classloader
*/
dpInstall.setTargetClassLoader(webapploader);
// 定义一个类里面的hook变量并初始化,防止每次拦截write时都初始化对象
dpInstall.defineField("uavLogHook", LogIT.class, "ch.qos.logback.core.encoder.LayoutWrappingEncoder", "new LogIT()");
dpInstall.installProxy("ch.qos.logback.core.encoder.LayoutWrappingEncoder", new String[] { "com.creditease.uav.log.hook.interceptors" }, new DynamicProxyProcessor() {
@Override
public void process(DPMethod m) throws Exception {
if ("convertToBytes".equals(m.getName())) {
m.insertBefore("{$1=uavLogHook.formatLog($1);}");
}
}
}, false);
// release loader
dpInstall.releaseTargetClassLoader();
}
use of com.creditease.uav.monitorframework.dproxy.DynamicProxyProcessor in project uavstack by uavorg.
the class WebServiceListener method doInstallDProxy.
public void doInstallDProxy(ClassLoader webapploader, final String appid, String contextPath) {
// like SMS, which uses the sun jax-ws RI/Metro-jax-ws RI bind webservices when the servlet starts should
// profile in ComponentProfileHandler
FastClasspathScanner fcs = new FastClasspathScanner(new ClassLoader[] { webapploader });
fcs.scan();
List<String> endPoints = fcs.getNamesOfDirectSubclassesOf("javax.xml.ws.Endpoint");
if (!endPoints.isEmpty()) {
dpInstall.setTargetClassLoader(webapploader);
for (int i = 0; i < endPoints.size(); i++) {
dpInstall.installProxy(endPoints.get(i), new String[] { "com.creditease.uav.monitorframework.webservice.interceptors" }, new DynamicProxyProcessor() {
@Override
public void process(DPMethod m) throws Exception {
if ("publish".equals(m.getName()) && m.getParameterTypes().length > 0 && m.getParameterTypes()[0].getSimpleName().equals("String")) {
dpInstall.defineLocalVal(m, "mObj", WebServiceListenerIT.class);
m.insertBefore("{mObj=new WebServiceListenerIT(\"" + appid + "\");mObj.obtainWsInfo($1,getImplementor());}");
}
}
}, false);
}
// release loader
dpInstall.releaseTargetClassLoader();
}
}
use of com.creditease.uav.monitorframework.dproxy.DynamicProxyProcessor in project uavstack by uavorg.
the class HttpAsyncClientHookProxy method doInstallDProxy.
public void doInstallDProxy(ClassLoader webapploader, final String appid) {
/**
* set the webapploader is the target classloader
*/
dpInstall.setTargetClassLoader(webapploader);
/**
* install proxy to InternalHttpAsyncClient
*/
dpInstall.installProxy("org.apache.http.impl.nio.client.InternalHttpAsyncClient", new String[] { "com.creditease.uav.hook.httpclients.async.interceptors" }, new DynamicProxyProcessor() {
@Override
public void process(DPMethod m) throws Exception {
if ("execute".equals(m.getName())) {
if (m.getParameterTypes().length == 4) {
dpInstall.defineLocalVal(m, "mObj", ApacheAsyncHttpClientIT.class);
m.insertBefore("{mObj=new ApacheAsyncHttpClientIT(\"" + appid + "\"); " + "$2=mObj.makeConsumer($2);$4=mObj.doAsyncStart(new Object[]{$1,$2,$3,$4});}");
m.insertAfter("{$_=mObj.doAsyncEnd(new Object[]{$_});}");
}
}
}
}, false);
/**
* install proxy to MinimalHttpAsyncClient
*/
dpInstall.installProxy("org.apache.http.impl.nio.client.MinimalHttpAsyncClient", new String[] { "com.creditease.uav.hook.httpclients.async.interceptors" }, new DynamicProxyProcessor() {
@Override
public void process(DPMethod m) throws Exception {
if ("execute".equals(m.getName())) {
dpInstall.defineLocalVal(m, "mObj", ApacheAsyncHttpClientIT.class);
if (m.getParameterTypes().length == 4) {
m.insertBefore("{mObj=new ApacheAsyncHttpClientIT(\"" + appid + "\"); $2=mObj.makeConsumer($2);$4=mObj.doAsyncStart(new Object[]{$1,$2,$3,$4});}");
m.insertAfter("{$_=mObj.doAsyncEnd(new Object[]{$_});}");
} else if (m.getParameterTypes().length == 5) {
m.insertBefore("{mObj=new ApacheAsyncHttpClientIT(\"" + appid + "\"); $3=mObj.makeConsumers($3);$5=mObj.doAsyncStart(new Object[]{$1,$2,$3,$4,$5});}");
m.insertAfter("{$_=mObj.doAsyncEnd(new Object[]{$_});}");
}
}
}
}, false);
// release loader
dpInstall.releaseTargetClassLoader();
}
use of com.creditease.uav.monitorframework.dproxy.DynamicProxyProcessor in project uavstack by uavorg.
the class HttpClientHookProxy method doInstallDProxy.
public void doInstallDProxy(ClassLoader webapploader, final String appid) {
/**
* set the webapploader is the target classloader
*/
dpInstall.setTargetClassLoader(webapploader);
/**
* install proxy to AbstractHttpClient before 4.3
*/
dpInstall.installProxy("org.apache.http.impl.client.AbstractHttpClient", new String[] { "com.creditease.uav.hook.httpclients.sync.interceptors" }, new DynamicProxyProcessor() {
@Override
public void process(DPMethod m) throws Exception {
if ("execute".equals(m.getName())) {
if (m.getParameterTypes().length == 3 && m.getReturnType().getSimpleName().equals("HttpResponse")) {
m.insertBefore("{ApacheHttpClientIT.start(\"" + appid + "\",new Object[]{$1,$2,$3});}");
m.insertAfter("{ApacheHttpClientIT.end(new Object[]{$_});}");
dpInstall.addCatch(m, "ApacheHttpClientIT.end(new Object[]{$e});");
}
}
}
}, false);
/**
* install proxy to InternalHttpClient after 4.3
*/
dpInstall.installProxy("org.apache.http.impl.client.InternalHttpClient", new String[] { "com.creditease.uav.hook.httpclients.sync.interceptors" }, new DynamicProxyProcessor() {
@Override
public void process(DPMethod m) throws Exception {
if ("doExecute".equals(m.getName())) {
m.insertBefore("{ApacheHttpClientIT.start(\"" + appid + "\",new Object[]{$1,$2,$3});}");
m.insertAfter("{ApacheHttpClientIT.end(new Object[]{$_});}");
dpInstall.addCatch(m, "ApacheHttpClientIT.end(new Object[]{$e});");
}
}
}, false);
/**
* install proxy to MinimalHttpClient after 4.3
*/
dpInstall.installProxy("org.apache.http.impl.client.MinimalHttpClient", new String[] { "com.creditease.uav.hook.httpclients.sync.interceptors" }, new DynamicProxyProcessor() {
@Override
public void process(DPMethod m) throws Exception {
if ("doExecute".equals(m.getName())) {
m.insertBefore("{ApacheHttpClientIT.start(\"" + appid + "\",new Object[]{$1,$2,$3});}");
m.insertAfter("{ApacheHttpClientIT.end(new Object[]{$_});}");
dpInstall.addCatch(m, "ApacheHttpClientIT.end(new Object[]{$e});");
}
}
}, false);
// release loader
dpInstall.releaseTargetClassLoader();
}
use of com.creditease.uav.monitorframework.dproxy.DynamicProxyProcessor in project uavstack by uavorg.
the class HttpClient3HookProxy method doInstallDProxy.
public void doInstallDProxy(ClassLoader webapploader, final String appid) {
/**
* set the webapploader is the target classloader
*/
dpInstall.setTargetClassLoader(webapploader);
/**
* install proxy to httpclient 3.x
*/
dpInstall.installProxy("org.apache.commons.httpclient.HttpClient", new String[] { "com.creditease.uav.hook.httpclients3.sync.interceptors" }, new DynamicProxyProcessor() {
@Override
public void process(DPMethod m) throws Exception {
if ("executeMethod".equals(m.getName()) && m.getParameterTypes().length == 3) {
m.insertBefore("{ApacheHttpClient3IT.start(\"" + appid + "\",new Object[]{$1,$2,$3});}");
m.insertAfter("{ApacheHttpClient3IT.end(new Object[]{$2});}");
dpInstall.addCatch(m, "ApacheHttpClient3IT.end(new Object[]{$e});");
}
}
}, false);
}
Aggregations