📄 servicefactory.java
字号:
/*
* Created on 2004-8-13
*
* TODO To change the template for this generated file go to Window -
* Preferences - Java - Code Style - Code Templates
*/
package org.ggyy.util;
import org.ggyy.dao.ICatDao;
import org.ggyy.dao.IOwnerDao;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.FileSystemXmlApplicationContext;
/**
* bean实例的类工厂,从spring容器管理的bean中得到bean的实例,这是给Junit测试用的.
* 服务器运行时,bean的实例由spring容器产生
* @author jiangyubao
*
*/
public final class ServiceFactory {
private static ICatDao catDao = null;
private static IOwnerDao ownerDao = null;
private static ApplicationContext ctx = null;
static {
ctx = new FileSystemXmlApplicationContext(
"WebRoot/WEB-INF/applicationContext.xml");
}
private ServiceFactory() {
}
public static ApplicationContext getApplicationContext() {
return ctx;
}
public static ICatDao getICatDao() {
if (catDao == null) {
catDao = (ICatDao) ctx.getBean("catDao");
}
return catDao;
}
public static IOwnerDao getIOwnerDao() {
if (ownerDao == null) {
ownerDao = (IOwnerDao) ctx.getBean("ownerDao");
}
return ownerDao;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -