me.icymint.libra.sage.spring.SqlFactoryBean Maven / Gradle / Ivy
package me.icymint.libra.sage.spring;
import me.icymint.libra.sage.model.SqlFactory;
import me.icymint.libra.sage.model.SqlInfo;
import org.springframework.beans.factory.FactoryBean;
import org.springframework.core.io.Resource;
/**
* Spring配置Sage SQL工厂的属性。请注意该类用于支持Spring模块。
*
*
* <bean id="xx" class="me.icymint.sage.spring.SqlFactoryBean">
* <property name="sqlInfo">
* <bean class="me.icymint.sage.model.SqlInfo">
* <constructor-arg value="true" />
* <constructor-arg>
* <bean class="me.icymint.sage.core.JdbcUtils">
* <constructor-arg ref="dataSource" />
* <constructor-arg value="atest" />
* </bean>
* </constructor-arg>
* </bean>
* </property>
* <property name="xml">
* <bean class="org.springframework.core.io.ClassPathResource">
* <constructor-arg value="me/icymint/sage/1.xml" />
* </bean>
* </property>
* </bean>
*
*
* @author Daniel
* @datetime 2013-1-23下午3:54:37
*
*
*/
public class SqlFactoryBean implements FactoryBean {
private SqlInfo si;
private Resource xml;
@Override
public SqlFactory getObject() throws Exception {
return SqlFactory.newInstance(si, xml.getInputStream());
}
@Override
public Class> getObjectType() {
return SqlFactory.class;
}
public SqlInfo getSqlInfo() {
return si;
}
@Override
public boolean isSingleton() {
return true;
}
public void setSqlInfo(SqlInfo si) {
this.si = si;
}
public void setXml(Resource xml) {
this.xml = xml;
}
}