當前位置: 首頁>>代碼示例>>Java>>正文


Java RootBeanDefinition.setDependencyCheck方法代碼示例

本文整理匯總了Java中org.springframework.beans.factory.support.RootBeanDefinition.setDependencyCheck方法的典型用法代碼示例。如果您正苦於以下問題:Java RootBeanDefinition.setDependencyCheck方法的具體用法?Java RootBeanDefinition.setDependencyCheck怎麽用?Java RootBeanDefinition.setDependencyCheck使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.springframework.beans.factory.support.RootBeanDefinition的用法示例。


在下文中一共展示了RootBeanDefinition.setDependencyCheck方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: testRegisterExistingSingletonWithAutowire

import org.springframework.beans.factory.support.RootBeanDefinition; //導入方法依賴的package包/類
@Test
public void testRegisterExistingSingletonWithAutowire() {
	DefaultListableBeanFactory lbf = new DefaultListableBeanFactory();
	MutablePropertyValues pvs = new MutablePropertyValues();
	pvs.add("name", "Tony");
	pvs.add("age", "48");
	RootBeanDefinition bd = new RootBeanDefinition(DependenciesBean.class);
	bd.setPropertyValues(pvs);
	bd.setDependencyCheck(RootBeanDefinition.DEPENDENCY_CHECK_OBJECTS);
	bd.setAutowireMode(RootBeanDefinition.AUTOWIRE_BY_TYPE);
	lbf.registerBeanDefinition("test", bd);
	Object singletonObject = new TestBean();
	lbf.registerSingleton("singletonObject", singletonObject);

	assertTrue(lbf.containsBean("singletonObject"));
	assertTrue(lbf.isSingleton("singletonObject"));
	assertEquals(TestBean.class, lbf.getType("singletonObject"));
	assertEquals(0, lbf.getAliases("singletonObject").length);
	DependenciesBean test = (DependenciesBean) lbf.getBean("test");
	assertEquals(singletonObject, lbf.getBean("singletonObject"));
	assertEquals(singletonObject, test.getSpouse());
}
 
開發者ID:langtianya,項目名稱:spring4-understanding,代碼行數:23,代碼來源:DefaultListableBeanFactoryTests.java

示例2: testPrototypeCreationWithDependencyCheckIsFastEnough

import org.springframework.beans.factory.support.RootBeanDefinition; //導入方法依賴的package包/類
@Test
public void testPrototypeCreationWithDependencyCheckIsFastEnough() {
	Assume.group(TestGroup.PERFORMANCE);
	Assume.notLogging(factoryLog);
	DefaultListableBeanFactory lbf = new DefaultListableBeanFactory();
	RootBeanDefinition rbd = new RootBeanDefinition(LifecycleBean.class);
	rbd.setScope(RootBeanDefinition.SCOPE_PROTOTYPE);
	rbd.setDependencyCheck(RootBeanDefinition.DEPENDENCY_CHECK_OBJECTS);
	lbf.registerBeanDefinition("test", rbd);
	lbf.addBeanPostProcessor(new LifecycleBean.PostProcessor());
	StopWatch sw = new StopWatch();
	sw.start("prototype");
	for (int i = 0; i < 100000; i++) {
		lbf.getBean("test");
	}
	sw.stop();
	// System.out.println(sw.getTotalTimeMillis());
	assertTrue("Prototype creation took too long: " + sw.getTotalTimeMillis(), sw.getTotalTimeMillis() < 3000);
}
 
開發者ID:langtianya,項目名稱:spring4-understanding,代碼行數:20,代碼來源:DefaultListableBeanFactoryTests.java


注:本文中的org.springframework.beans.factory.support.RootBeanDefinition.setDependencyCheck方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。