本文整理汇总了Java中org.springframework.beans.factory.support.DefaultListableBeanFactory.destroyBean方法的典型用法代码示例。如果您正苦于以下问题:Java DefaultListableBeanFactory.destroyBean方法的具体用法?Java DefaultListableBeanFactory.destroyBean怎么用?Java DefaultListableBeanFactory.destroyBean使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.springframework.beans.factory.support.DefaultListableBeanFactory
的用法示例。
在下文中一共展示了DefaultListableBeanFactory.destroyBean方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testResourceInjectionWithPrototypes
import org.springframework.beans.factory.support.DefaultListableBeanFactory; //导入方法依赖的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
示例2: testCreateBean
import org.springframework.beans.factory.support.DefaultListableBeanFactory; //导入方法依赖的package包/类
@Test
public void testCreateBean() {
DefaultListableBeanFactory lbf = new DefaultListableBeanFactory();
TestBean tb = lbf.createBean(TestBean.class);
assertSame(lbf, tb.getBeanFactory());
lbf.destroyBean(tb);
}
示例3: testCreateBeanWithDisposableBean
import org.springframework.beans.factory.support.DefaultListableBeanFactory; //导入方法依赖的package包/类
@Test
public void testCreateBeanWithDisposableBean() {
DefaultListableBeanFactory lbf = new DefaultListableBeanFactory();
DerivedTestBean tb = lbf.createBean(DerivedTestBean.class);
assertSame(lbf, tb.getBeanFactory());
lbf.destroyBean(tb);
assertTrue(tb.wasDestroyed());
}