me.danwi.sqlex.spring.SqlExFactoryBean Maven / Gradle / Ivy
package me.danwi.sqlex.spring;
import me.danwi.sqlex.core.DaoFactory;
import org.springframework.beans.factory.FactoryBean;
public class SqlExFactoryBean implements FactoryBean {
final private Class daoInterface;
private DaoFactory factory;
public SqlExFactoryBean(Class clazz) {
this.daoInterface = clazz;
}
public void setFactory(DaoFactory factory) {
this.factory = factory;
}
@Override
public T getObject() throws Exception {
if (this.factory == null)
throw new Exception("请确保容器中注册有DaoFactory");
//noinspection unchecked
return this.factory.getInstance(this.daoInterface);
}
@Override
public Class getObjectType() {
return daoInterface;
}
@Override
public boolean isSingleton() {
return true;
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy