com.dream.boot.bean.MapperFactoryBean Maven / Gradle / Ivy
The newest version!
package com.dream.boot.bean;
import com.dream.template.session.SessionTemplate;
import org.springframework.beans.factory.FactoryBean;
import org.springframework.beans.factory.annotation.Autowired;
public class MapperFactoryBean implements FactoryBean {
private Class mapperInterface;
private SessionTemplate sessionTemplate;
public MapperFactoryBean(Class mapperInterface) {
this.mapperInterface = mapperInterface;
}
@Override
public T getObject() {
return sessionTemplate.getMapper(this.mapperInterface);
}
@Override
public Class> getObjectType() {
return this.mapperInterface;
}
@Override
public boolean isSingleton() {
return true;
}
@Autowired
public void setSessionTemplate(SessionTemplate sessionTemplate) {
this.sessionTemplate = sessionTemplate;
}
}