国产一级a片免费看高清,亚洲熟女中文字幕在线视频,黄三级高清在线播放,免费黄色视频在线看

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

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

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

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

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

/** 私有構(gòu)造器 */
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)對(duì)應(yīng)實(shí)例Object,使用時(shí)需要強(qiáng)制類(lèi)型轉(zhuǎn)換
*/
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
   // 測(cè)試代碼
}
}

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

聯(lián)系客服