All Downloads are FREE. Search and download functionalities are using the official Maven repository.

top.jfunc.common.http.boot.HttpServiceFactoryBean Maven / Gradle / Ivy

Go to download

httpclient-xxx在spring-boot环境下的自动配置,要配合httpclient-xxx之一使用

There is a newer version: 1.1.4
Show newest version
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;
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy