top.jfunc.common.http.boot.HttpServiceFactoryBean Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of httpclient-spring-boot-starter Show documentation
Show all versions of httpclient-spring-boot-starter Show documentation
httpclient-xxx在spring-boot环境下的自动配置,要配合httpclient-xxx之一使用
package top.jfunc.common.http.boot;
import org.springframework.beans.factory.FactoryBean;
import top.jfunc.common.http.interfacing.HttpServiceCreator;
/**
* 用于通过HttpServiceCreator生成HttpService接口的代理类
* @see HttpServiceCreator
* @param HttpService标注的接口
* @author xiongshiyan
*/
public class HttpServiceFactoryBean implements FactoryBean{
private Class interfaceClass;
private HttpServiceCreator httpServiceCreator;
public HttpServiceFactoryBean() {
}
public HttpServiceFactoryBean(HttpServiceCreator httpServiceCreator, Class interfaceClass) {
this.httpServiceCreator = httpServiceCreator;
this.interfaceClass = interfaceClass;
}
@Override
public T getObject() throws Exception {
return httpServiceCreator.create(interfaceClass);
}
@Override
public Class> getObjectType() {
return interfaceClass;
}
@Override
public boolean isSingleton() {
return true;
}
public Class getInterfaceClass() {
return interfaceClass;
}
public void setInterfaceClass(Class interfaceClass) {
this.interfaceClass = interfaceClass;
}
public HttpServiceCreator getHttpServiceCreator() {
return httpServiceCreator;
}
public void setHttpServiceCreator(HttpServiceCreator httpServiceCreator) {
this.httpServiceCreator = httpServiceCreator;
}
}