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


Java RootBeanDefinition.addQualifier方法代碼示例

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


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

示例1: testObjectFactoryQualifierInjection

import org.springframework.beans.factory.support.RootBeanDefinition; //導入方法依賴的package包/類
@Test
public void testObjectFactoryQualifierInjection() {
	DefaultListableBeanFactory bf = new DefaultListableBeanFactory();
	bf.setAutowireCandidateResolver(new QualifierAnnotationAutowireCandidateResolver());
	AutowiredAnnotationBeanPostProcessor bpp = new AutowiredAnnotationBeanPostProcessor();
	bpp.setBeanFactory(bf);
	bf.addBeanPostProcessor(bpp);
	bf.registerBeanDefinition("annotatedBean", new RootBeanDefinition(ObjectFactoryQualifierInjectionBean.class));
	RootBeanDefinition bd = new RootBeanDefinition(TestBean.class);
	bd.addQualifier(new AutowireCandidateQualifier(Qualifier.class, "testBean"));
	bf.registerBeanDefinition("testBean", bd);
	bf.registerBeanDefinition("testBean2", new RootBeanDefinition(TestBean.class));

	ObjectFactoryQualifierInjectionBean bean = (ObjectFactoryQualifierInjectionBean) bf.getBean("annotatedBean");
	assertSame(bf.getBean("testBean"), bean.getTestBean());
	bf.destroySingletons();
}
 
開發者ID:langtianya,項目名稱:spring4-understanding,代碼行數:18,代碼來源:AutowiredAnnotationBeanPostProcessorTests.java

示例2: testObjectFactoryInjection

import org.springframework.beans.factory.support.RootBeanDefinition; //導入方法依賴的package包/類
@Test
public void testObjectFactoryInjection() {
	DefaultListableBeanFactory bf = new DefaultListableBeanFactory();
	bf.setAutowireCandidateResolver(new QualifierAnnotationAutowireCandidateResolver());
	AutowiredAnnotationBeanPostProcessor bpp = new AutowiredAnnotationBeanPostProcessor();
	bpp.setBeanFactory(bf);
	bf.addBeanPostProcessor(bpp);
	bf.registerBeanDefinition("annotatedBean", new RootBeanDefinition(ObjectFactoryQualifierFieldInjectionBean.class));
	RootBeanDefinition bd = new RootBeanDefinition(TestBean.class);
	bd.addQualifier(new AutowireCandidateQualifier(Qualifier.class, "testBean"));
	bf.registerBeanDefinition("testBean", bd);
	bf.registerBeanDefinition("testBean2", new RootBeanDefinition(TestBean.class));

	ObjectFactoryQualifierFieldInjectionBean bean = (ObjectFactoryQualifierFieldInjectionBean) bf.getBean("annotatedBean");
	assertSame(bf.getBean("testBean"), bean.getTestBean());
	bf.destroySingletons();
}
 
開發者ID:langtianya,項目名稱:spring4-understanding,代碼行數:18,代碼來源:InjectAnnotationBeanPostProcessorTests.java

示例3: testObjectFactoryFieldInjectionIntoPrototypeBean

import org.springframework.beans.factory.support.RootBeanDefinition; //導入方法依賴的package包/類
@Test
public void testObjectFactoryFieldInjectionIntoPrototypeBean() {
	DefaultListableBeanFactory bf = new DefaultListableBeanFactory();
	bf.setAutowireCandidateResolver(new QualifierAnnotationAutowireCandidateResolver());
	AutowiredAnnotationBeanPostProcessor bpp = new AutowiredAnnotationBeanPostProcessor();
	bpp.setBeanFactory(bf);
	bf.addBeanPostProcessor(bpp);
	RootBeanDefinition annotatedBeanDefinition = new RootBeanDefinition(ObjectFactoryQualifierFieldInjectionBean.class);
	annotatedBeanDefinition.setScope(BeanDefinition.SCOPE_PROTOTYPE);
	bf.registerBeanDefinition("annotatedBean", annotatedBeanDefinition);
	RootBeanDefinition bd = new RootBeanDefinition(TestBean.class);
	bd.addQualifier(new AutowireCandidateQualifier(Qualifier.class, "testBean"));
	bf.registerBeanDefinition("testBean", bd);
	bf.registerBeanDefinition("testBean2", new RootBeanDefinition(TestBean.class));

	ObjectFactoryQualifierFieldInjectionBean bean = (ObjectFactoryQualifierFieldInjectionBean) bf.getBean("annotatedBean");
	assertSame(bf.getBean("testBean"), bean.getTestBean());
	ObjectFactoryQualifierFieldInjectionBean anotherBean = (ObjectFactoryQualifierFieldInjectionBean) bf.getBean("annotatedBean");
	assertNotSame(anotherBean, bean);
	assertSame(bf.getBean("testBean"), bean.getTestBean());
}
 
開發者ID:langtianya,項目名稱:spring4-understanding,代碼行數:22,代碼來源:InjectAnnotationBeanPostProcessorTests.java

示例4: testObjectFactoryMethodInjectionIntoPrototypeBean

import org.springframework.beans.factory.support.RootBeanDefinition; //導入方法依賴的package包/類
@Test
public void testObjectFactoryMethodInjectionIntoPrototypeBean() {
	DefaultListableBeanFactory bf = new DefaultListableBeanFactory();
	bf.setAutowireCandidateResolver(new QualifierAnnotationAutowireCandidateResolver());
	AutowiredAnnotationBeanPostProcessor bpp = new AutowiredAnnotationBeanPostProcessor();
	bpp.setBeanFactory(bf);
	bf.addBeanPostProcessor(bpp);
	RootBeanDefinition annotatedBeanDefinition = new RootBeanDefinition(ObjectFactoryQualifierMethodInjectionBean.class);
	annotatedBeanDefinition.setScope(BeanDefinition.SCOPE_PROTOTYPE);
	bf.registerBeanDefinition("annotatedBean", annotatedBeanDefinition);
	RootBeanDefinition bd = new RootBeanDefinition(TestBean.class);
	bd.addQualifier(new AutowireCandidateQualifier(Qualifier.class, "testBean"));
	bf.registerBeanDefinition("testBean", bd);
	bf.registerBeanDefinition("testBean2", new RootBeanDefinition(TestBean.class));

	ObjectFactoryQualifierMethodInjectionBean bean = (ObjectFactoryQualifierMethodInjectionBean) bf.getBean("annotatedBean");
	assertSame(bf.getBean("testBean"), bean.getTestBean());
	ObjectFactoryQualifierMethodInjectionBean anotherBean = (ObjectFactoryQualifierMethodInjectionBean) bf.getBean("annotatedBean");
	assertNotSame(anotherBean, bean);
	assertSame(bf.getBean("testBean"), bean.getTestBean());
}
 
開發者ID:langtianya,項目名稱:spring4-understanding,代碼行數:22,代碼來源:InjectAnnotationBeanPostProcessorTests.java

示例5: testObjectFactoryQualifierInjection

import org.springframework.beans.factory.support.RootBeanDefinition; //導入方法依賴的package包/類
@Test
public void testObjectFactoryQualifierInjection() {
	DefaultListableBeanFactory bf = new DefaultListableBeanFactory();
	AutowiredAnnotationBeanPostProcessor bpp = new AutowiredAnnotationBeanPostProcessor();
	bpp.setBeanFactory(bf);
	bf.addBeanPostProcessor(bpp);
	bf.registerBeanDefinition("annotatedBean", new RootBeanDefinition(ObjectFactoryQualifierFieldInjectionBean.class));
	RootBeanDefinition bd = new RootBeanDefinition(TestBean.class);
	bd.addQualifier(new AutowireCandidateQualifier(Qualifier.class, "testBean"));
	bf.registerBeanDefinition("testBean", bd);

	ObjectFactoryQualifierFieldInjectionBean bean = (ObjectFactoryQualifierFieldInjectionBean) bf.getBean("annotatedBean");
	assertSame(bf.getBean("testBean"), bean.getTestBean());
	bf.destroySingletons();
}
 
開發者ID:langtianya,項目名稱:spring4-understanding,代碼行數:16,代碼來源:InjectAnnotationBeanPostProcessorTests.java


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