DAOFactory 源码:
package com.sinoest.ybl.common;
import org.springframework.beans.factory.BeanFactory;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;
import org.springframework.context.support.FileSystemXmlApplicationContext;
import com.sinoest.ybl.dao.ITestDAO;
import com.sinoest.ybl.dao.impl.TestDAO;
/**
*
* @author guochr
*
*/
public class DAOFactory {
//private ApplicationContext factory = null;
private BeanFactory factory=null;
private static DAOFactory instance;
private static final String FSMS_CLIENT_BEAN_FILE = "applicationContext.xml";
private DAOFactory() {
// this.factory = new FileSystemXmlApplicationContext(
// new String[] { FSMS_CLIENT_BEAN_FILE });
//
factory = new ClassPathXmlApplicationContext(FSMS_CLIENT_BEAN_FILE);
}
public static DAOFactory getInstance() {
if (instance == null) {
instance = new DAOFactory();
}
return instance;
}
public ITestDAO getTestDAO() {
return(ITestDAO) this.factory.getBean("TestDAO");
}*/
public ITestDAO getTestDAO() {
return (TestDAO) this.factory.getBean("TestDAO");
}
}