Example usage for org.springframework.beans.factory.support DefaultListableBeanFactory createBean

List of usage examples for org.springframework.beans.factory.support DefaultListableBeanFactory createBean

Introduction

In this page you can find the example usage for org.springframework.beans.factory.support DefaultListableBeanFactory createBean.

Prototype

@Override
    @SuppressWarnings("unchecked")
    public <T> T createBean(Class<T> beanClass) throws BeansException 

Source Link

Usage

From source file:org.springframework.beans.factory.DefaultListableBeanFactoryTests.java

@Test
public void testCreateBean() {
    DefaultListableBeanFactory lbf = new DefaultListableBeanFactory();
    TestBean tb = lbf.createBean(TestBean.class);
    assertSame(lbf, tb.getBeanFactory());
    lbf.destroyBean(tb);//w  w  w. j  av  a  2 s  . c  o m
}

From source file:org.springframework.beans.factory.DefaultListableBeanFactoryTests.java

@Test
public void testCreateBeanWithDisposableBean() {
    DefaultListableBeanFactory lbf = new DefaultListableBeanFactory();
    DerivedTestBean tb = lbf.createBean(DerivedTestBean.class);
    assertSame(lbf, tb.getBeanFactory());
    lbf.destroyBean(tb);/* www  . ja  va  2 s.c  o m*/
    assertTrue(tb.wasDestroyed());
}