com.github.easilyuse.core.proxy.HttpClientCglibProxy Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of easily-http Show documentation
Show all versions of easily-http Show documentation
Easy implementation of http client remote calls through annotations
The newest version!
package com.github.easilyuse.core.proxy;
import java.lang.reflect.Method;
import com.github.easilyuse.core.enu.HttpMethod;
import net.sf.cglib.proxy.Enhancer;
import net.sf.cglib.proxy.MethodInterceptor;
import net.sf.cglib.proxy.MethodProxy;
/**
*
*
* Title:HttpClientCglibProxy
*
*
* Description: cglib http请求代理
*
*
* @author linyb
*/
public class HttpClientCglibProxy extends BaseHttpClientProxy implements MethodInterceptor {
public HttpClientCglibProxy(HttpMethod httpMethod, String url) {
this.httpMethod = httpMethod;
this.url = url;
}
public HttpClientCglibProxy() {
}
public static Object newInstance(Class targetClz, HttpMethod httpMethod, String url) {
Enhancer enhancer = new Enhancer();
enhancer.setSuperclass(targetClz);
enhancer.setCallback(new HttpClientCglibProxy(httpMethod, url));
return enhancer.create();
}
public static Object newInstance(Class targetClz) {
Enhancer enhancer = new Enhancer();
enhancer.setSuperclass(targetClz);
enhancer.setCallback(new HttpClientCglibProxy());
return enhancer.create();
}
@Override
public Object intercept(Object proxy, Method method, Object[] args, MethodProxy methodProxy) throws Throwable {
return doService(proxy, method, args);
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy