com.github.nezha.httpfetch.spring.HttpApiFactoryBean Maven / Gradle / Ivy
package com.github.nezha.httpfetch.spring;
import com.github.nezha.httpfetch.HttpApiService;
import org.springframework.beans.factory.FactoryBean;
import org.springframework.beans.factory.annotation.Autowired;
/**
* Created by daiqiang on 17/7/26.
*/
public class HttpApiFactoryBean implements FactoryBean {
@Autowired
private HttpApiService httpApiService;
private Class> targetClass;
@Override
public Object getObject() throws Exception {
return httpApiService.getOrCreateService(targetClass);
}
@Override
public Class> getObjectType() {
return targetClass;
}
@Override
public boolean isSingleton() {
return true;
}
public Class> getTargetClass() {
return targetClass;
}
public void setTargetClass(Class> targetClass) {
this.targetClass = targetClass;
}
}