Search in sources :

Example 1 with JaxWSHookIT

use of com.creditease.uav.hook.jaxws.interceptors.JaxWSHookIT in project uavstack by uavorg.

the class JaxWSHookProxy method doInstallDProxy.

public void doInstallDProxy(ClassLoader webapploader, final String appid) {
    /**
     * set the webapploader is the target classloader
     */
    dpInstall.setTargetClassLoader(webapploader);
    /**
     * install proxy to javax.xml.ws.Service
     */
    dpInstall.installProxy("javax.xml.ws.Service", new String[] { "com.creditease.uav.hook.jaxws.interceptors" }, new DynamicProxyProcessor() {

        @Override
        public void process(DPMethod m) throws Exception {
            if ("getPort".equals(m.getName())) {
                dpInstall.defineLocalVal(m, "mObj", JaxWSHookIT.class);
                m.insertBefore("{mObj=new JaxWSHookIT(\"" + appid + "\");}");
                m.insertAfter("{$_=mObj.getPort($_,this,$args);}");
            }
            if ("createDispatch".equals(m.getName())) {
                dpInstall.defineLocalVal(m, "mObj", JaxWSHookIT.class);
                m.insertBefore("{mObj=new JaxWSHookIT(\"" + appid + "\");}");
                m.insertAfter("{$_=mObj.createDispatch($_,this,$args);}");
            }
        }
    }, false);
    /**
     * adapts: 实现对JDKProxyInvokeHandler封装的Proxy对象的替换,替换为原来的对象,因为在有些场景下对方原来的对象有一些非接口的方法需要调用
     * 比如CXF中ClientProxy.getClient(Object o), 需要原来的对象才能使用
     */
    dpInstall.doAdapts(this.getAdapts());
    // release loader
    dpInstall.releaseTargetClassLoader();
}
Also used : DPMethod(com.creditease.uav.monitorframework.dproxy.bytecode.DPMethod) JaxWSHookIT(com.creditease.uav.hook.jaxws.interceptors.JaxWSHookIT) DynamicProxyProcessor(com.creditease.uav.monitorframework.dproxy.DynamicProxyProcessor)

Aggregations

JaxWSHookIT (com.creditease.uav.hook.jaxws.interceptors.JaxWSHookIT)1 DynamicProxyProcessor (com.creditease.uav.monitorframework.dproxy.DynamicProxyProcessor)1 DPMethod (com.creditease.uav.monitorframework.dproxy.bytecode.DPMethod)1