当前位置: 首页>>代码示例>>Java>>正文


Java RootBeanDefinition.setScope方法代码示例

本文整理汇总了Java中org.springframework.beans.factory.support.RootBeanDefinition.setScope方法的典型用法代码示例。如果您正苦于以下问题:Java RootBeanDefinition.setScope方法的具体用法?Java RootBeanDefinition.setScope怎么用?Java RootBeanDefinition.setScope使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.springframework.beans.factory.support.RootBeanDefinition的用法示例。


在下文中一共展示了RootBeanDefinition.setScope方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: 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

示例2: testPrototypeCreationWithResourcePropertiesIsFastEnough

import org.springframework.beans.factory.support.RootBeanDefinition; //导入方法依赖的package包/类
@Test
public void testPrototypeCreationWithResourcePropertiesIsFastEnough() {
	GenericApplicationContext ctx = new GenericApplicationContext();
	AnnotationConfigUtils.registerAnnotationConfigProcessors(ctx);
	ctx.refresh();

	RootBeanDefinition rbd = new RootBeanDefinition(ResourceAnnotatedTestBean.class);
	rbd.setScope(RootBeanDefinition.SCOPE_PROTOTYPE);
	ctx.registerBeanDefinition("test", rbd);
	ctx.registerBeanDefinition("spouse", new RootBeanDefinition(TestBean.class));
	TestBean spouse = (TestBean) ctx.getBean("spouse");
	StopWatch sw = new StopWatch();
	sw.start("prototype");
	for (int i = 0; i < 100000; i++) {
		TestBean tb = (TestBean) ctx.getBean("test");
		assertSame(spouse, tb.getSpouse());
	}
	sw.stop();
	assertTrue("Prototype creation took too long: " + sw.getTotalTimeMillis(), sw.getTotalTimeMillis() < 4000);
}
 
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:21,代码来源:AnnotationProcessorPerformanceTests.java

示例3: testPrototypeCreationWithOverriddenAutowiredPropertiesIsFastEnough

import org.springframework.beans.factory.support.RootBeanDefinition; //导入方法依赖的package包/类
@Test
public void testPrototypeCreationWithOverriddenAutowiredPropertiesIsFastEnough() {
	GenericApplicationContext ctx = new GenericApplicationContext();
	AnnotationConfigUtils.registerAnnotationConfigProcessors(ctx);
	ctx.refresh();

	RootBeanDefinition rbd = new RootBeanDefinition(AutowiredAnnotatedTestBean.class);
	rbd.setScope(RootBeanDefinition.SCOPE_PROTOTYPE);
	rbd.getPropertyValues().add("spouse", new RuntimeBeanReference("spouse"));
	ctx.registerBeanDefinition("test", rbd);
	ctx.registerBeanDefinition("spouse", new RootBeanDefinition(TestBean.class));
	TestBean spouse = (TestBean) ctx.getBean("spouse");
	StopWatch sw = new StopWatch();
	sw.start("prototype");
	for (int i = 0; i < 100000; i++) {
		TestBean tb = (TestBean) ctx.getBean("test");
		assertSame(spouse, tb.getSpouse());
	}
	sw.stop();
	assertTrue("Prototype creation took too long: " + sw.getTotalTimeMillis(), sw.getTotalTimeMillis() < 6000);
}
 
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:22,代码来源:AnnotationProcessorPerformanceTests.java

示例4: genericsBasedInjectionWithScoped

import org.springframework.beans.factory.support.RootBeanDefinition; //导入方法依赖的package包/类
@Test
public void genericsBasedInjectionWithScoped() {
	AutowiredAnnotationBeanPostProcessor bpp = new AutowiredAnnotationBeanPostProcessor();
	bpp.setBeanFactory(beanFactory);
	beanFactory.addBeanPostProcessor(bpp);
	RootBeanDefinition bd = new RootBeanDefinition(RepositoryInjectionBean.class);
	bd.setScope(RootBeanDefinition.SCOPE_PROTOTYPE);
	beanFactory.registerBeanDefinition("annotatedBean", bd);
	beanFactory.registerBeanDefinition("configClass", new RootBeanDefinition(ScopedRepositoryConfiguration.class));
	ConfigurationClassPostProcessor pp = new ConfigurationClassPostProcessor();
	pp.postProcessBeanFactory(beanFactory);

	RepositoryInjectionBean bean = (RepositoryInjectionBean) beanFactory.getBean("annotatedBean");
	assertEquals("Repository<String>", bean.stringRepository.toString());
	assertEquals("Repository<Integer>", bean.integerRepository.toString());
}
 
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:17,代码来源:ConfigurationClassPostProcessorTests.java

示例5: genericsBasedInjectionWithScopedProxyUsingAsm

import org.springframework.beans.factory.support.RootBeanDefinition; //导入方法依赖的package包/类
@Test
public void genericsBasedInjectionWithScopedProxyUsingAsm() {
	AutowiredAnnotationBeanPostProcessor bpp = new AutowiredAnnotationBeanPostProcessor();
	bpp.setBeanFactory(beanFactory);
	beanFactory.addBeanPostProcessor(bpp);
	RootBeanDefinition bd = new RootBeanDefinition(RepositoryInjectionBean.class.getName());
	bd.setScope(RootBeanDefinition.SCOPE_PROTOTYPE);
	beanFactory.registerBeanDefinition("annotatedBean", bd);
	beanFactory.registerBeanDefinition("configClass", new RootBeanDefinition(ScopedProxyRepositoryConfiguration.class.getName()));
	ConfigurationClassPostProcessor pp = new ConfigurationClassPostProcessor();
	pp.postProcessBeanFactory(beanFactory);
	beanFactory.freezeConfiguration();

	RepositoryInjectionBean bean = (RepositoryInjectionBean) beanFactory.getBean("annotatedBean");
	assertEquals("Repository<String>", bean.stringRepository.toString());
	assertEquals("Repository<Integer>", bean.integerRepository.toString());
	assertTrue(AopUtils.isCglibProxy(bean.stringRepository));
	assertTrue(AopUtils.isCglibProxy(bean.integerRepository));
}
 
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:20,代码来源:ConfigurationClassPostProcessorTests.java

示例6: 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

示例7: testPrototypeWithArrayConversionForConstructor

import org.springframework.beans.factory.support.RootBeanDefinition; //导入方法依赖的package包/类
@Test
public void testPrototypeWithArrayConversionForConstructor() {
	DefaultListableBeanFactory lbf = new DefaultListableBeanFactory();
	List<String> list = new ManagedList<String>();
	list.add("myName");
	list.add("myBeanName");
	RootBeanDefinition bd = new RootBeanDefinition(DerivedTestBean.class);
	bd.setScope(RootBeanDefinition.SCOPE_PROTOTYPE);
	bd.getConstructorArgumentValues().addGenericArgumentValue(list);
	lbf.registerBeanDefinition("test", bd);
	DerivedTestBean tb = (DerivedTestBean) lbf.getBean("test");
	assertEquals("myName", tb.getName());
	assertEquals("myBeanName", tb.getBeanName());
	DerivedTestBean tb2 = (DerivedTestBean) lbf.getBean("test");
	assertTrue(tb != tb2);
	assertEquals("myName", tb2.getName());
	assertEquals("myBeanName", tb2.getBeanName());
}
 
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:19,代码来源:DefaultListableBeanFactoryTests.java

示例8: registerBean

import org.springframework.beans.factory.support.RootBeanDefinition; //导入方法依赖的package包/类
/**
	 * 注册bean定义
	 * @param idOrName
	 * @param beanClass
	 * @param isSingleton
	 */
	public static void registerBean(String idOrName,Class beanClass,boolean isSingleton) {
		DefaultListableBeanFactory beanFactory = getDefaultBeanFactory();
		if(!beanFactory.containsBean( idOrName )){
			
			RootBeanDefinition beanDefinition = new RootBeanDefinition();
			beanDefinition.setBeanClassName(beanClass.getName());
            beanDefinition.setScope(AbstractBeanDefinition.SCOPE_SINGLETON);
//			beanDefinition.setSingleton(isSingleton); //默认为true, 需要增加可配置性
			beanFactory.registerBeanDefinition( idOrName , beanDefinition);
			
			if(log.isDebugEnabled()) log.debug("注册bean: {} singleton?:{}",  idOrName, isSingleton);
		}
		
	}
 
开发者ID:jambo-framework,项目名称:jambo2,代码行数:21,代码来源:SpringContextManager.java

示例9: createPointcutDefinition

import org.springframework.beans.factory.support.RootBeanDefinition; //导入方法依赖的package包/类
/**
 * Creates a {@link BeanDefinition} for the {@link AspectJExpressionPointcut} class using
 * the supplied pointcut expression.
 */
protected AbstractBeanDefinition createPointcutDefinition(String expression) {
	RootBeanDefinition beanDefinition = new RootBeanDefinition(AspectJExpressionPointcut.class);
	beanDefinition.setScope(BeanDefinition.SCOPE_PROTOTYPE);
	beanDefinition.setSynthetic(true);
	beanDefinition.getPropertyValues().add(EXPRESSION, expression);
	return beanDefinition;
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:12,代码来源:ConfigBeanDefinitionParser.java

示例10: testGenericsBasedFieldInjectionWithSimpleMatchAndMockito

import org.springframework.beans.factory.support.RootBeanDefinition; //导入方法依赖的package包/类
@Test
public void testGenericsBasedFieldInjectionWithSimpleMatchAndMockito() {
	DefaultListableBeanFactory bf = new DefaultListableBeanFactory();
	bf.setAutowireCandidateResolver(new QualifierAnnotationAutowireCandidateResolver());
	AutowiredAnnotationBeanPostProcessor bpp = new AutowiredAnnotationBeanPostProcessor();
	bpp.setBeanFactory(bf);
	bf.addBeanPostProcessor(bpp);
	RootBeanDefinition bd = new RootBeanDefinition(RepositoryFieldInjectionBeanWithSimpleMatch.class);
	bd.setScope(RootBeanDefinition.SCOPE_PROTOTYPE);
	bf.registerBeanDefinition("annotatedBean", bd);

	RootBeanDefinition rbd = new RootBeanDefinition();
	rbd.setBeanClassName(Mockito.class.getName());
	rbd.setFactoryMethodName("mock");
	// TypedStringValue used to be equivalent to an XML-defined argument String
	rbd.getConstructorArgumentValues().addGenericArgumentValue(new TypedStringValue(Repository.class.getName()));
	bf.registerBeanDefinition("repo", rbd);

	RepositoryFieldInjectionBeanWithSimpleMatch bean = (RepositoryFieldInjectionBeanWithSimpleMatch) bf.getBean("annotatedBean");
	Repository repo = bf.getBean("repo", Repository.class);
	assertSame(repo, bean.repository);
	assertSame(repo, bean.stringRepository);
	assertSame(1, bean.repositoryArray.length);
	assertSame(1, bean.stringRepositoryArray.length);
	assertSame(repo, bean.repositoryArray[0]);
	assertSame(repo, bean.stringRepositoryArray[0]);
	assertSame(1, bean.repositoryList.size());
	assertSame(1, bean.stringRepositoryList.size());
	assertSame(repo, bean.repositoryList.get(0));
	assertSame(repo, bean.stringRepositoryList.get(0));
	assertSame(1, bean.repositoryMap.size());
	assertSame(1, bean.stringRepositoryMap.size());
	assertSame(repo, bean.repositoryMap.get("repo"));
	assertSame(repo, bean.stringRepositoryMap.get("repo"));
}
 
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:36,代码来源:AutowiredAnnotationBeanPostProcessorTests.java

示例11: testFieldInjectionWithMap

import org.springframework.beans.factory.support.RootBeanDefinition; //导入方法依赖的package包/类
@Test
public void testFieldInjectionWithMap() {
	DefaultListableBeanFactory bf = new DefaultListableBeanFactory();
	AutowiredAnnotationBeanPostProcessor bpp = new AutowiredAnnotationBeanPostProcessor();
	bpp.setBeanFactory(bf);
	bf.addBeanPostProcessor(bpp);
	RootBeanDefinition bd = new RootBeanDefinition(MapFieldInjectionBean.class);
	bd.setScope(RootBeanDefinition.SCOPE_PROTOTYPE);
	bf.registerBeanDefinition("annotatedBean", bd);
	TestBean tb1 = new TestBean();
	TestBean tb2 = new TestBean();
	bf.registerSingleton("testBean1", tb1);
	bf.registerSingleton("testBean2", tb1);

	MapFieldInjectionBean bean = (MapFieldInjectionBean) bf.getBean("annotatedBean");
	assertEquals(2, bean.getTestBeanMap().size());
	assertTrue(bean.getTestBeanMap().keySet().contains("testBean1"));
	assertTrue(bean.getTestBeanMap().keySet().contains("testBean2"));
	assertTrue(bean.getTestBeanMap().values().contains(tb1));
	assertTrue(bean.getTestBeanMap().values().contains(tb2));

	bean = (MapFieldInjectionBean) bf.getBean("annotatedBean");
	assertEquals(2, bean.getTestBeanMap().size());
	assertTrue(bean.getTestBeanMap().keySet().contains("testBean1"));
	assertTrue(bean.getTestBeanMap().keySet().contains("testBean2"));
	assertTrue(bean.getTestBeanMap().values().contains(tb1));
	assertTrue(bean.getTestBeanMap().values().contains(tb2));
}
 
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:29,代码来源:InjectAnnotationBeanPostProcessorTests.java

示例12: prototypeCreationIsFastEnough

import org.springframework.beans.factory.support.RootBeanDefinition; //导入方法依赖的package包/类
@Test
public void prototypeCreationIsFastEnough() {
	Assume.group(TestGroup.PERFORMANCE);
	Assume.notLogging(factoryLog);
	GenericApplicationContext ac = new GenericApplicationContext();
	RootBeanDefinition rbd = new RootBeanDefinition(TestBean.class);
	rbd.setScope(RootBeanDefinition.SCOPE_PROTOTYPE);
	rbd.getConstructorArgumentValues().addGenericArgumentValue("#{systemProperties.name}");
	rbd.getPropertyValues().add("country", "#{systemProperties.country}");
	ac.registerBeanDefinition("test", rbd);
	ac.refresh();
	StopWatch sw = new StopWatch();
	sw.start("prototype");
	System.getProperties().put("name", "juergen");
	System.getProperties().put("country", "UK");
	try {
		for (int i = 0; i < 100000; i++) {
			TestBean tb = (TestBean) ac.getBean("test");
			assertEquals("juergen", tb.getName());
			assertEquals("UK", tb.getCountry());
		}
		sw.stop();
	}
	finally {
		System.getProperties().remove("country");
		System.getProperties().remove("name");
	}
	assertTrue("Prototype creation took too long: " + sw.getTotalTimeMillis(), sw.getTotalTimeMillis() < 6000);
}
 
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:30,代码来源:ApplicationContextExpressionTests.java

示例13: testResourceInjectionWithPrototypes

import org.springframework.beans.factory.support.RootBeanDefinition; //导入方法依赖的package包/类
@Test
public void testResourceInjectionWithPrototypes() {
	DefaultListableBeanFactory bf = new DefaultListableBeanFactory();
	CommonAnnotationBeanPostProcessor bpp = new CommonAnnotationBeanPostProcessor();
	bpp.setResourceFactory(bf);
	bf.addBeanPostProcessor(bpp);
	RootBeanDefinition abd = new RootBeanDefinition(ResourceInjectionBean.class);
	abd.setScope(BeanDefinition.SCOPE_PROTOTYPE);
	bf.registerBeanDefinition("annotatedBean", abd);
	RootBeanDefinition tbd1 = new RootBeanDefinition(TestBean.class);
	tbd1.setScope(BeanDefinition.SCOPE_PROTOTYPE);
	bf.registerBeanDefinition("testBean", tbd1);
	RootBeanDefinition tbd2 = new RootBeanDefinition(TestBean.class);
	tbd2.setScope(BeanDefinition.SCOPE_PROTOTYPE);
	bf.registerBeanDefinition("testBean2", tbd2);

	ResourceInjectionBean bean = (ResourceInjectionBean) bf.getBean("annotatedBean");
	assertTrue(bean.initCalled);
	assertTrue(bean.init2Called);
	assertTrue(bean.init3Called);

	TestBean tb = bean.getTestBean();
	TestBean tb2 = bean.getTestBean2();
	assertNotNull(tb);
	assertNotNull(tb2);

	ResourceInjectionBean anotherBean = (ResourceInjectionBean) bf.getBean("annotatedBean");
	assertNotSame(anotherBean, bean);
	assertNotSame(anotherBean.getTestBean(), tb);
	assertNotSame(anotherBean.getTestBean2(), tb2);

	bf.destroyBean("annotatedBean", bean);
	assertTrue(bean.destroyCalled);
	assertTrue(bean.destroy2Called);
	assertTrue(bean.destroy3Called);
}
 
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:37,代码来源:CommonAnnotationBeanPostProcessorTests.java

示例14: testGenericsBasedFieldInjectionWithQualifiers

import org.springframework.beans.factory.support.RootBeanDefinition; //导入方法依赖的package包/类
@Test
public void testGenericsBasedFieldInjectionWithQualifiers() {
	DefaultListableBeanFactory bf = new DefaultListableBeanFactory();
	bf.setAutowireCandidateResolver(new QualifierAnnotationAutowireCandidateResolver());
	AutowiredAnnotationBeanPostProcessor bpp = new AutowiredAnnotationBeanPostProcessor();
	bpp.setBeanFactory(bf);
	bf.addBeanPostProcessor(bpp);
	RootBeanDefinition bd = new RootBeanDefinition(RepositoryFieldInjectionBeanWithQualifiers.class);
	bd.setScope(RootBeanDefinition.SCOPE_PROTOTYPE);
	bf.registerBeanDefinition("annotatedBean", bd);
	StringRepository sr = new StringRepository();
	bf.registerSingleton("stringRepo", sr);
	IntegerRepository ir = new IntegerRepository();
	bf.registerSingleton("integerRepo", ir);

	RepositoryFieldInjectionBeanWithQualifiers bean = (RepositoryFieldInjectionBeanWithQualifiers) bf.getBean("annotatedBean");
	assertSame(sr, bean.stringRepository);
	assertSame(ir, bean.integerRepository);
	assertSame(1, bean.stringRepositoryArray.length);
	assertSame(1, bean.integerRepositoryArray.length);
	assertSame(sr, bean.stringRepositoryArray[0]);
	assertSame(ir, bean.integerRepositoryArray[0]);
	assertSame(1, bean.stringRepositoryList.size());
	assertSame(1, bean.integerRepositoryList.size());
	assertSame(sr, bean.stringRepositoryList.get(0));
	assertSame(ir, bean.integerRepositoryList.get(0));
	assertSame(1, bean.stringRepositoryMap.size());
	assertSame(1, bean.integerRepositoryMap.size());
	assertSame(sr, bean.stringRepositoryMap.get("stringRepo"));
	assertSame(ir, bean.integerRepositoryMap.get("integerRepo"));
}
 
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:32,代码来源:AutowiredAnnotationBeanPostProcessorTests.java

示例15: testGenericsBasedFieldInjectionWithSimpleMatch

import org.springframework.beans.factory.support.RootBeanDefinition; //导入方法依赖的package包/类
@Test
public void testGenericsBasedFieldInjectionWithSimpleMatch() {
	DefaultListableBeanFactory bf = new DefaultListableBeanFactory();
	bf.setAutowireCandidateResolver(new QualifierAnnotationAutowireCandidateResolver());
	AutowiredAnnotationBeanPostProcessor bpp = new AutowiredAnnotationBeanPostProcessor();
	bpp.setBeanFactory(bf);
	bf.addBeanPostProcessor(bpp);
	RootBeanDefinition bd = new RootBeanDefinition(RepositoryFieldInjectionBeanWithSimpleMatch.class);
	bd.setScope(RootBeanDefinition.SCOPE_PROTOTYPE);
	bf.registerBeanDefinition("annotatedBean", bd);

	bf.registerSingleton("repo", new StringRepository());

	RepositoryFieldInjectionBeanWithSimpleMatch bean = (RepositoryFieldInjectionBeanWithSimpleMatch) bf.getBean("annotatedBean");
	Repository repo = bf.getBean("repo", Repository.class);
	assertSame(repo, bean.repository);
	assertSame(repo, bean.stringRepository);
	assertSame(1, bean.repositoryArray.length);
	assertSame(1, bean.stringRepositoryArray.length);
	assertSame(repo, bean.repositoryArray[0]);
	assertSame(repo, bean.stringRepositoryArray[0]);
	assertSame(1, bean.repositoryList.size());
	assertSame(1, bean.stringRepositoryList.size());
	assertSame(repo, bean.repositoryList.get(0));
	assertSame(repo, bean.stringRepositoryList.get(0));
	assertSame(1, bean.repositoryMap.size());
	assertSame(1, bean.stringRepositoryMap.size());
	assertSame(repo, bean.repositoryMap.get("repo"));
	assertSame(repo, bean.stringRepositoryMap.get("repo"));
}
 
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:31,代码来源:AutowiredAnnotationBeanPostProcessorTests.java


注:本文中的org.springframework.beans.factory.support.RootBeanDefinition.setScope方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。