欧美性猛交XXXX免费看蜜桃,成人网18免费韩国,亚洲国产成人精品区综合,欧美日韩一区二区三区高清不卡,亚洲综合一区二区精品久久

打開(kāi)APP
userphoto
未登錄

開(kāi)通VIP,暢享免費電子書(shū)等14項超值服

開(kāi)通VIP
Spring工具類(lèi),提供取得Bean的方法,方便單元測試

import org.springframework.beans.factory.BeanFactory;
import org.springframework.context.support.ClassPathXmlApplicationContext;

/**
* Spring工具類(lèi),提供取得Spring配置文件中定義的Bean的方法<br>用于單元測試
* @author http://hi.baidu.com/rascal_hu
*
*/
public class SpringUtil {
/** 唯一實(shí)例 */
private static SpringUtil INSTALL = null;
/**Spring工廠(chǎng)接口*/
private BeanFactory beanFactory = null;
/** Spring配置文件 */
private static final String SPRING_CFG = "file:WebRoot/WEB-INF/spring-*.xml";

/** 私有構造器 */
private SpringUtil() {
}

/**
* 取得類(lèi)的唯一實(shí)例
* @return
*/
public synchronized static SpringUtil getInstance() {
   if (INSTALL == null) {
    INSTALL = new SpringUtil();
   }
   return INSTALL;
}

/**
* 取得BeanFactory
*/
private synchronized BeanFactory getBeanFactory() {
   if (this.beanFactory == null) {
    this.beanFactory = new ClassPathXmlApplicationContext(SPRING_CFG);
   }
   return this.beanFactory;
}

/**
* 通過(guò)在Spring配置文件中定義的bean名稱(chēng),從IOC容器中取得實(shí)例
*
* @param beanName
*            bean名稱(chēng)
* @return bean名稱(chēng)對應實(shí)例Object,使用時(shí)需要強制類(lèi)型轉換
*/
public Object getBean(String beanName) throws NullPointerException {
   if (beanName == null) {
    throw new java.lang.NullPointerException("beanName不能為空!");
   }
   return this.getBeanFactory().getBean(beanName);
}

public static void main(String[] args) {
   // TODO
   // 測試代碼
}
}

本站僅提供存儲服務(wù),所有內容均由用戶(hù)發(fā)布,如發(fā)現有害或侵權內容,請點(diǎn)擊舉報。
打開(kāi)APP,閱讀全文并永久保存 查看更多類(lèi)似文章
猜你喜歡
類(lèi)似文章
Action中獲取Spring配置的bean
Spring容器獲取Bean的9種方式,你能get幾種?
Spring內核研究-管理bean的聲明周期一(InitializingBean和init-method)
Spring:源碼解讀Spring IOC原理
spring的InitializingBean的afterPropertiesSet方法和init-method配置的區別聯(lián)系
使用beanfactory管理bean
更多類(lèi)似文章 >>
生活服務(wù)
分享 收藏 導長(cháng)圖 關(guān)注 下載文章
綁定賬號成功
后續可登錄賬號暢享VIP特權!
如果VIP功能使用有故障,
可點(diǎn)擊這里聯(lián)系客服!

聯(lián)系客服

欧美性猛交XXXX免费看蜜桃,成人网18免费韩国,亚洲国产成人精品区综合,欧美日韩一区二区三区高清不卡,亚洲综合一区二区精品久久