Java Code Examples for org.springframework.beans.factory.support.DefaultListableBeanFactory#destroySingletons()

The following examples show how to use org.springframework.beans.factory.support.DefaultListableBeanFactory#destroySingletons() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: AutowiredAnnotationBeanPostProcessorTests.java    From spring4-understanding with Apache License 2.0 6 votes vote down vote up
@Test
public void testOptionalResourceInjectionWithNoDependencies() {
	DefaultListableBeanFactory bf = new DefaultListableBeanFactory();
	AutowiredAnnotationBeanPostProcessor bpp = new AutowiredAnnotationBeanPostProcessor();
	bpp.setBeanFactory(bf);
	bf.addBeanPostProcessor(bpp);
	bf.registerBeanDefinition("annotatedBean", new RootBeanDefinition(OptionalResourceInjectionBean.class));

	OptionalResourceInjectionBean bean = (OptionalResourceInjectionBean) bf.getBean("annotatedBean");
	assertNull(bean.getTestBean());
	assertNull(bean.getTestBean2());
	assertNull(bean.getTestBean3());
	assertNull(bean.getTestBean4());
	assertNull(bean.getNestedTestBeans());
	bf.destroySingletons();
}
 
Example 2
Source File: InjectAnnotationBeanPostProcessorTests.java    From spring4-understanding with Apache License 2.0 6 votes vote down vote up
@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();
}
 
Example 3
Source File: CommonAnnotationBeanPostProcessorTests.java    From spring4-understanding with Apache License 2.0 6 votes vote down vote up
@Test
public void testResourceInjectionFromJndi() {
	DefaultListableBeanFactory bf = new DefaultListableBeanFactory();
	CommonAnnotationBeanPostProcessor bpp = new CommonAnnotationBeanPostProcessor();
	SimpleJndiBeanFactory resourceFactory = new SimpleJndiBeanFactory();
	ExpectedLookupTemplate jndiTemplate = new ExpectedLookupTemplate();
	TestBean tb = new TestBean();
	jndiTemplate.addObject("java:comp/env/testBean", tb);
	TestBean tb2 = new TestBean();
	jndiTemplate.addObject("java:comp/env/testBean2", tb2);
	resourceFactory.setJndiTemplate(jndiTemplate);
	bpp.setResourceFactory(resourceFactory);
	bf.addBeanPostProcessor(bpp);
	bf.registerBeanDefinition("annotatedBean", new RootBeanDefinition(ResourceInjectionBean.class));

	ResourceInjectionBean bean = (ResourceInjectionBean) bf.getBean("annotatedBean");
	assertTrue(bean.initCalled);
	assertTrue(bean.init2Called);
	assertSame(tb, bean.getTestBean());
	assertSame(tb2, bean.getTestBean2());
	bf.destroySingletons();
	assertTrue(bean.destroyCalled);
	assertTrue(bean.destroy2Called);
}
 
Example 4
Source File: AutowiredAnnotationBeanPostProcessorTests.java    From spring4-understanding with Apache License 2.0 6 votes vote down vote up
@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();
}
 
Example 5
Source File: InjectAnnotationBeanPostProcessorTests.java    From spring4-understanding with Apache License 2.0 6 votes vote down vote up
@Test
public void testObjectFactoryWithTypedMapMethod() throws Exception {
	DefaultListableBeanFactory bf = new DefaultListableBeanFactory();
	AutowiredAnnotationBeanPostProcessor bpp = new AutowiredAnnotationBeanPostProcessor();
	bpp.setBeanFactory(bf);
	bf.addBeanPostProcessor(bpp);
	bf.registerBeanDefinition("annotatedBean", new RootBeanDefinition(ObjectFactoryMapMethodInjectionBean.class));
	bf.registerBeanDefinition("testBean", new RootBeanDefinition(TestBean.class));
	bf.setSerializationId("test");

	ObjectFactoryMapMethodInjectionBean bean = (ObjectFactoryMapMethodInjectionBean) bf.getBean("annotatedBean");
	assertSame(bf.getBean("testBean"), bean.getTestBean());
	bean = (ObjectFactoryMapMethodInjectionBean) SerializationTestUtils.serializeAndDeserialize(bean);
	assertSame(bf.getBean("testBean"), bean.getTestBean());
	bf.destroySingletons();
}
 
Example 6
Source File: AutowiredAnnotationBeanPostProcessorTests.java    From spring4-understanding with Apache License 2.0 6 votes vote down vote up
@Test
public void testExtendedResourceInjectionWithDefaultMethod() {
	DefaultListableBeanFactory bf = new DefaultListableBeanFactory();
	bf.registerResolvableDependency(BeanFactory.class, bf);
	AutowiredAnnotationBeanPostProcessor bpp = new AutowiredAnnotationBeanPostProcessor();
	bpp.setBeanFactory(bf);
	bf.addBeanPostProcessor(bpp);
	RootBeanDefinition annotatedBd = new RootBeanDefinition(DefaultMethodResourceInjectionBean.class);
	bf.registerBeanDefinition("annotatedBean", annotatedBd);
	TestBean tb = new TestBean();
	bf.registerSingleton("testBean", tb);
	NestedTestBean ntb = new NestedTestBean();
	bf.registerSingleton("nestedTestBean", ntb);

	DefaultMethodResourceInjectionBean bean = (DefaultMethodResourceInjectionBean) bf.getBean("annotatedBean");
	assertSame(tb, bean.getTestBean());
	assertNull(bean.getTestBean2());
	assertSame(tb, bean.getTestBean3());
	assertSame(tb, bean.getTestBean4());
	assertSame(ntb, bean.getNestedTestBean());
	assertNull(bean.getBeanFactory());
	assertTrue(bean.baseInjected);
	assertTrue(bean.subInjected);
	bf.destroySingletons();
}
 
Example 7
Source File: AutowiredAnnotationBeanPostProcessorTests.java    From spring4-understanding with Apache License 2.0 6 votes vote down vote up
@Test
public void testCustomAnnotationRequiredMethodResourceInjection() {
	DefaultListableBeanFactory bf = new DefaultListableBeanFactory();
	AutowiredAnnotationBeanPostProcessor bpp = new AutowiredAnnotationBeanPostProcessor();
	bpp.setAutowiredAnnotationType(MyAutowired.class);
	bpp.setRequiredParameterName("optional");
	bpp.setRequiredParameterValue(false);
	bpp.setBeanFactory(bf);
	bf.addBeanPostProcessor(bpp);
	bf.registerBeanDefinition("customBean", new RootBeanDefinition(
			CustomAnnotationRequiredMethodResourceInjectionBean.class));
	TestBean tb = new TestBean();
	bf.registerSingleton("testBean", tb);

	CustomAnnotationRequiredMethodResourceInjectionBean bean = (CustomAnnotationRequiredMethodResourceInjectionBean) bf.getBean("customBean");
	assertSame(tb, bean.getTestBean());
	bf.destroySingletons();
}
 
Example 8
Source File: XmlBeanFactoryTests.java    From spring-analysis-note with MIT License 6 votes vote down vote up
/**
 * Check that InitializingBean method is not called twice.
 */
@Test
public void testInitializingBeanAndSameInitMethod() {
	InitAndIB.constructed = false;
	DefaultListableBeanFactory xbf = new DefaultListableBeanFactory();
	new XmlBeanDefinitionReader(xbf).loadBeanDefinitions(INITIALIZERS_CONTEXT);
	assertFalse(InitAndIB.constructed);
	xbf.preInstantiateSingletons();
	assertFalse(InitAndIB.constructed);
	InitAndIB iib = (InitAndIB) xbf.getBean("ib-same-init");
	assertTrue(InitAndIB.constructed);
	assertTrue(iib.afterPropertiesSetInvoked && !iib.initMethodInvoked);
	assertTrue(!iib.destroyed && !iib.customDestroyed);
	xbf.destroySingletons();
	assertTrue(iib.destroyed && !iib.customDestroyed);
	xbf.destroySingletons();
	assertTrue(iib.destroyed && !iib.customDestroyed);
}
 
Example 9
Source File: Spr3775InitDestroyLifecycleTests.java    From spring4-understanding with Apache License 2.0 5 votes vote down vote up
@Test
public void testInitializingDisposableInterfacesWithShadowedMethods() {
	final Class<?> beanClass = InitializingDisposableWithShadowedMethodsBean.class;
	final DefaultListableBeanFactory beanFactory = createBeanFactoryAndRegisterBean(beanClass,
			"afterPropertiesSet", "destroy");
	final InitializingDisposableWithShadowedMethodsBean bean = (InitializingDisposableWithShadowedMethodsBean) beanFactory.getBean(LIFECYCLE_TEST_BEAN);
	assertMethodOrdering(beanClass, "init-methods", Arrays.asList("InitializingBean.afterPropertiesSet"),
			bean.initMethods);
	beanFactory.destroySingletons();
	assertMethodOrdering(beanClass, "destroy-methods", Arrays.asList("DisposableBean.destroy"), bean.destroyMethods);
}
 
Example 10
Source File: Spr3775InitDestroyLifecycleTests.java    From spring-analysis-note with MIT License 5 votes vote down vote up
@Test
public void testJsr250Annotations() {
	final Class<?> beanClass = CustomAnnotatedInitDestroyBean.class;
	final DefaultListableBeanFactory beanFactory = createBeanFactoryAndRegisterBean(beanClass, "customInit",
			"customDestroy");
	final CustomAnnotatedInitDestroyBean bean = (CustomAnnotatedInitDestroyBean) beanFactory.getBean(LIFECYCLE_TEST_BEAN);
	assertMethodOrdering(beanClass, "init-methods", Arrays.asList("postConstruct", "afterPropertiesSet",
			"customInit"), bean.initMethods);
	beanFactory.destroySingletons();
	assertMethodOrdering(beanClass, "destroy-methods", Arrays.asList("preDestroy", "destroy", "customDestroy"),
			bean.destroyMethods);
}
 
Example 11
Source File: Spr3775InitDestroyLifecycleTests.java    From java-technology-stack with MIT License 5 votes vote down vote up
@Test
public void testAllLifecycleMechanismsAtOnce() {
	final Class<?> beanClass = AllInOneBean.class;
	final DefaultListableBeanFactory beanFactory = createBeanFactoryAndRegisterBean(beanClass,
			"afterPropertiesSet", "destroy");
	final AllInOneBean bean = (AllInOneBean) beanFactory.getBean(LIFECYCLE_TEST_BEAN);
	assertMethodOrdering(beanClass, "init-methods", Arrays.asList("afterPropertiesSet"), bean.initMethods);
	beanFactory.destroySingletons();
	assertMethodOrdering(beanClass, "destroy-methods", Arrays.asList("destroy"), bean.destroyMethods);
}
 
Example 12
Source File: AutowiredAnnotationBeanPostProcessorTests.java    From spring4-understanding with Apache License 2.0 5 votes vote down vote up
@Test
public void testConstructorResourceInjectionWithMultipleCandidatesAndFallback() {
	DefaultListableBeanFactory bf = new DefaultListableBeanFactory();
	AutowiredAnnotationBeanPostProcessor bpp = new AutowiredAnnotationBeanPostProcessor();
	bpp.setBeanFactory(bf);
	bf.addBeanPostProcessor(bpp);
	bf.registerBeanDefinition("annotatedBean", new RootBeanDefinition(ConstructorsResourceInjectionBean.class));
	TestBean tb = new TestBean();
	bf.registerSingleton("testBean", tb);

	ConstructorsResourceInjectionBean bean = (ConstructorsResourceInjectionBean) bf.getBean("annotatedBean");
	assertSame(tb, bean.getTestBean3());
	assertNull(bean.getTestBean4());
	bf.destroySingletons();
}
 
Example 13
Source File: DefaultListableBeanFactoryTests.java    From spring4-understanding with Apache License 2.0 5 votes vote down vote up
@Test
public void testDestroyMethodOnInnerBeanAsPrototype() {
	DefaultListableBeanFactory lbf = new DefaultListableBeanFactory();
	RootBeanDefinition innerBd = new RootBeanDefinition(BeanWithDestroyMethod.class);
	innerBd.setScope(RootBeanDefinition.SCOPE_PROTOTYPE);
	innerBd.setDestroyMethodName("close");
	RootBeanDefinition bd = new RootBeanDefinition(BeanWithDestroyMethod.class);
	bd.setDestroyMethodName("close");
	bd.getPropertyValues().add("inner", innerBd);
	lbf.registerBeanDefinition("test", bd);
	BeanWithDestroyMethod.closeCount = 0;
	lbf.preInstantiateSingletons();
	lbf.destroySingletons();
	assertEquals("Destroy methods invoked", 1, BeanWithDestroyMethod.closeCount);
}
 
Example 14
Source File: InjectAnnotationBeanPostProcessorTests.java    From spring4-understanding with Apache License 2.0 5 votes vote down vote up
@Test
public void testOptionalMethodInjectionWithBeanAvailable() {
	DefaultListableBeanFactory bf = new DefaultListableBeanFactory();
	AutowiredAnnotationBeanPostProcessor bpp = new AutowiredAnnotationBeanPostProcessor();
	bpp.setBeanFactory(bf);
	bf.addBeanPostProcessor(bpp);
	bf.registerBeanDefinition("annotatedBean", new RootBeanDefinition(OptionalMethodInjectionBean.class));
	bf.registerBeanDefinition("testBean", new RootBeanDefinition(TestBean.class));

	OptionalMethodInjectionBean bean = (OptionalMethodInjectionBean) bf.getBean("annotatedBean");
	assertTrue(bean.getTestBean().isPresent());
	assertSame(bf.getBean("testBean"), bean.getTestBean().get());
	bf.destroySingletons();
}
 
Example 15
Source File: DefaultListableBeanFactoryTests.java    From spring-analysis-note with MIT License 5 votes vote down vote up
@Test
public void testDestroyMethodOnInnerBeanAsPrototype() {
	DefaultListableBeanFactory lbf = new DefaultListableBeanFactory();
	RootBeanDefinition innerBd = new RootBeanDefinition(BeanWithDestroyMethod.class);
	innerBd.setScope(RootBeanDefinition.SCOPE_PROTOTYPE);
	innerBd.setDestroyMethodName("close");
	RootBeanDefinition bd = new RootBeanDefinition(BeanWithDestroyMethod.class);
	bd.setDestroyMethodName("close");
	bd.getPropertyValues().add("inner", innerBd);
	lbf.registerBeanDefinition("test", bd);
	BeanWithDestroyMethod.closeCount = 0;
	lbf.preInstantiateSingletons();
	lbf.destroySingletons();
	assertEquals("Destroy methods invoked", 1, BeanWithDestroyMethod.closeCount);
}
 
Example 16
Source File: CommonAnnotationBeanPostProcessorTests.java    From spring4-understanding with Apache License 2.0 5 votes vote down vote up
@Test
public void testPostConstructAndPreDestroyWithPostProcessor() {
	DefaultListableBeanFactory bf = new DefaultListableBeanFactory();
	bf.addBeanPostProcessor(new InitDestroyBeanPostProcessor());
	bf.addBeanPostProcessor(new CommonAnnotationBeanPostProcessor());
	bf.registerBeanDefinition("annotatedBean", new RootBeanDefinition(AnnotatedInitDestroyBean.class));

	AnnotatedInitDestroyBean bean = (AnnotatedInitDestroyBean) bf.getBean("annotatedBean");
	assertTrue(bean.initCalled);
	bf.destroySingletons();
	assertTrue(bean.destroyCalled);
}
 
Example 17
Source File: DefaultLifecycleMethodsTests.java    From java-technology-stack with MIT License 5 votes vote down vote up
@Test
public void ignoreDefaultLifecycleMethods() throws Exception {
	DefaultListableBeanFactory bf = new DefaultListableBeanFactory();
	new XmlBeanDefinitionReader(bf).loadBeanDefinitions(new ClassPathResource(
			"ignoreDefaultLifecycleMethods.xml", getClass()));
	bf.preInstantiateSingletons();
	bf.destroySingletons();
}
 
Example 18
Source File: BeanLifecycleDemo.java    From geekbang-lessons with Apache License 2.0 4 votes vote down vote up
public static void main(String[] args) throws InterruptedException {
    DefaultListableBeanFactory beanFactory = new DefaultListableBeanFactory();
    // 添加 BeanPostProcessor 实现 MyInstantiationAwareBeanPostProcessor
    beanFactory.addBeanPostProcessor(new MyInstantiationAwareBeanPostProcessor());
    // 添加 MyDestructionAwareBeanPostProcessor 执行销毁前回调
    beanFactory.addBeanPostProcessor(new MyDestructionAwareBeanPostProcessor());
    // 添加 CommonAnnotationBeanPostProcessor 解决 @PostConstruct @PreDestroy
    beanFactory.addBeanPostProcessor(new CommonAnnotationBeanPostProcessor());

    XmlBeanDefinitionReader beanDefinitionReader = new XmlBeanDefinitionReader(beanFactory);
    String[] locations = {"META-INF/dependency-lookup-context.xml", "META-INF/bean-constructor-dependency-injection.xml"};
    int beanNumbers = beanDefinitionReader.loadBeanDefinitions(locations);
    System.out.println("已加载 BeanDefinition 数量:" + beanNumbers);
    // 显示地执行 preInstantiateSingletons()
    // SmartInitializingSingleton 通常在 Spring ApplicationContext 场景使用
    // preInstantiateSingletons 将已注册的 BeanDefinition 初始化成 Spring Bean
    beanFactory.preInstantiateSingletons();

    // 通过 Bean Id 和类型进行依赖查找
    User user = beanFactory.getBean("user", User.class);
    System.out.println(user);

    User superUser = beanFactory.getBean("superUser", User.class);
    System.out.println(superUser);

    // 构造器注入按照类型注入,resolveDependency
    UserHolder userHolder = beanFactory.getBean("userHolder", UserHolder.class);

    System.out.println(userHolder);

    // 执行 Bean 销毁(容器内)
    beanFactory.destroyBean("userHolder", userHolder);
    // Bean 销毁并不意味着 Bean 垃圾回收了
    System.out.println(userHolder);

    // 销毁 BeanFactory 中的单例 Bean
    beanFactory.destroySingletons();
    // 强制 GC
    System.gc();
    // 等待一段时间
    Thread.sleep(1000L);
    // 强制 GC
    System.gc();
}
 
Example 19
Source File: CommonAnnotationBeanPostProcessorTests.java    From spring4-understanding with Apache License 2.0 4 votes vote down vote up
@Test
public void testExtendedResourceInjectionWithOverriding() {
	DefaultListableBeanFactory bf = new DefaultListableBeanFactory();
	CommonAnnotationBeanPostProcessor bpp = new CommonAnnotationBeanPostProcessor();
	bpp.setBeanFactory(bf);
	bf.addBeanPostProcessor(bpp);
	bf.registerResolvableDependency(BeanFactory.class, bf);

	PropertyPlaceholderConfigurer ppc = new PropertyPlaceholderConfigurer();
	Properties props = new Properties();
	props.setProperty("tb", "testBean3");
	ppc.setProperties(props);
	ppc.postProcessBeanFactory(bf);

	RootBeanDefinition annotatedBd = new RootBeanDefinition(ExtendedResourceInjectionBean.class);
	TestBean tb5 = new TestBean();
	annotatedBd.getPropertyValues().add("testBean2", tb5);
	bf.registerBeanDefinition("annotatedBean", annotatedBd);
	bf.registerBeanDefinition("annotatedBean2", new RootBeanDefinition(NamedResourceInjectionBean.class));
	TestBean tb = new TestBean();
	bf.registerSingleton("testBean", tb);
	TestBean tb2 = new TestBean();
	bf.registerSingleton("testBean2", tb2);
	TestBean tb3 = new TestBean();
	bf.registerSingleton("testBean3", tb3);
	TestBean tb4 = new TestBean();
	bf.registerSingleton("testBean4", tb4);
	NestedTestBean tb6 = new NestedTestBean();
	bf.registerSingleton("xy", tb6);

	ExtendedResourceInjectionBean bean = (ExtendedResourceInjectionBean) bf.getBean("annotatedBean");
	assertTrue(bean.initCalled);
	assertTrue(bean.init2Called);
	assertSame(tb, bean.getTestBean());
	assertSame(tb5, bean.getTestBean2());
	assertSame(tb4, bean.getTestBean3());
	assertSame(tb3, bean.getTestBean4());
	assertSame(tb6, bean.testBean5);
	assertSame(tb6, bean.testBean6);
	assertSame(bf, bean.beanFactory);

	try {
		bf.getBean("annotatedBean2");
	}
	catch (BeanCreationException ex) {
		assertTrue(ex.getRootCause() instanceof NoSuchBeanDefinitionException);
		NoSuchBeanDefinitionException innerEx = (NoSuchBeanDefinitionException) ex.getRootCause();
		assertEquals("testBean9", innerEx.getBeanName());
	}

	bf.destroySingletons();
	assertTrue(bean.destroyCalled);
	assertTrue(bean.destroy2Called);
}
 
Example 20
Source File: CommonAnnotationBeanPostProcessorTests.java    From java-technology-stack with MIT License 4 votes vote down vote up
@Test
public void testExtendedResourceInjection() {
	DefaultListableBeanFactory bf = new DefaultListableBeanFactory();
	CommonAnnotationBeanPostProcessor bpp = new CommonAnnotationBeanPostProcessor();
	bpp.setBeanFactory(bf);
	bf.addBeanPostProcessor(bpp);
	bf.registerResolvableDependency(BeanFactory.class, bf);

	PropertyPlaceholderConfigurer ppc = new PropertyPlaceholderConfigurer();
	Properties props = new Properties();
	props.setProperty("tb", "testBean3");
	ppc.setProperties(props);
	ppc.postProcessBeanFactory(bf);

	bf.registerBeanDefinition("annotatedBean", new RootBeanDefinition(ExtendedResourceInjectionBean.class));
	bf.registerBeanDefinition("annotatedBean2", new RootBeanDefinition(NamedResourceInjectionBean.class));
	bf.registerBeanDefinition("annotatedBean3", new RootBeanDefinition(ConvertedResourceInjectionBean.class));
	TestBean tb = new TestBean();
	bf.registerSingleton("testBean", tb);
	TestBean tb2 = new TestBean();
	bf.registerSingleton("testBean2", tb2);
	TestBean tb3 = new TestBean();
	bf.registerSingleton("testBean3", tb3);
	TestBean tb4 = new TestBean();
	bf.registerSingleton("testBean4", tb4);
	NestedTestBean tb6 = new NestedTestBean();
	bf.registerSingleton("value", "5");
	bf.registerSingleton("xy", tb6);
	bf.registerAlias("xy", "testBean9");

	ExtendedResourceInjectionBean bean = (ExtendedResourceInjectionBean) bf.getBean("annotatedBean");
	assertTrue(bean.initCalled);
	assertTrue(bean.init2Called);
	assertSame(tb, bean.getTestBean());
	assertSame(tb2, bean.getTestBean2());
	assertSame(tb4, bean.getTestBean3());
	assertSame(tb3, bean.getTestBean4());
	assertSame(tb6, bean.testBean5);
	assertSame(tb6, bean.testBean6);
	assertSame(bf, bean.beanFactory);

	NamedResourceInjectionBean bean2 = (NamedResourceInjectionBean) bf.getBean("annotatedBean2");
	assertSame(tb6, bean2.testBean);

	ConvertedResourceInjectionBean bean3 = (ConvertedResourceInjectionBean) bf.getBean("annotatedBean3");
	assertSame(5, bean3.value);

	bf.destroySingletons();
	assertTrue(bean.destroyCalled);
	assertTrue(bean.destroy2Called);
}