Examples of destroySingletons()


Examples of org.springframework.beans.factory.support.DefaultListableBeanFactory.destroySingletons()

    final DefaultListableBeanFactory beanFactory = createBeanFactoryAndRegisterBean(beanClass, "customInit",
        "customDestroy");
    final CustomAnnotatedInitDestroyWithShadowedMethodsBean bean = (CustomAnnotatedInitDestroyWithShadowedMethodsBean) 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);
  }

  public void testAllLifecycleMechanismsAtOnce() {
View Full Code Here

Examples of org.springframework.beans.factory.support.DefaultListableBeanFactory.destroySingletons()

    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);
  }


  public static class InitDestroyBean {
View Full Code Here

Examples of org.springframework.beans.factory.support.DefaultListableBeanFactory.destroySingletons()

    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);
  }

  public void testPostConstructAndPreDestroyWithManualConfiguration() {
    DefaultListableBeanFactory bf = new DefaultListableBeanFactory();
View Full Code Here

Examples of org.springframework.beans.factory.support.DefaultListableBeanFactory.destroySingletons()

    bf.addBeanPostProcessor(bpp);
    bf.registerBeanDefinition("annotatedBean", new RootBeanDefinition(AnnotatedInitDestroyBean.class));

    AnnotatedInitDestroyBean bean = (AnnotatedInitDestroyBean) bf.getBean("annotatedBean");
    assertTrue(bean.initCalled);
    bf.destroySingletons();
    assertTrue(bean.destroyCalled);
  }

  public void testSerialization() throws Exception {
    CommonAnnotationBeanPostProcessor bpp = new CommonAnnotationBeanPostProcessor();
View Full Code Here

Examples of org.springframework.beans.factory.support.DefaultListableBeanFactory.destroySingletons()

    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);
  }

  public void testResourceInjectionWithTwoProcessors() {
View Full Code Here

Examples of org.springframework.beans.factory.support.DefaultListableBeanFactory.destroySingletons()

    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);
  }

  public void testResourceInjectionFromJndi() {
View Full Code Here

Examples of org.springframework.beans.factory.support.DefaultListableBeanFactory.destroySingletons()

    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);
  }

  public void testExtendedResourceInjection() {
View Full Code Here

Examples of org.springframework.beans.factory.support.DefaultListableBeanFactory.destroySingletons()

    assertSame(tb2, bean.getTestBean2());
    assertSame(tb, bean.getTestBean3());
    assertSame(tb, bean.getTestBean4());
    assertSame(ntb, bean.getNestedTestBean());
    assertSame(bf, bean.getBeanFactory());
    bf.destroySingletons();
  }

  public void testExtendedResourceInjectionWithAtRequired() {
    DefaultListableBeanFactory bf = new DefaultListableBeanFactory();
    bf.registerResolvableDependency(BeanFactory.class, bf);
View Full Code Here

Examples of org.springframework.beans.factory.support.DefaultListableBeanFactory.destroySingletons()

      fail("should have failed, more than one bean of type");
    }
    catch (BeanCreationException e) {
      // expected
    }
    bf.destroySingletons();
  }

  public void testMethodInjectionWithMapAndMultipleMatchesButOnlyOneAutowireCandidate() {
    DefaultListableBeanFactory bf = new DefaultListableBeanFactory();
    AutowiredAnnotationBeanPostProcessor bpp = new AutowiredAnnotationBeanPostProcessor();
View Full Code Here

Examples of org.springframework.beans.factory.support.DefaultListableBeanFactory.destroySingletons()

    TestBean tb = (TestBean) bf.getBean("testBean1");
    assertEquals(1, bean.getTestBeanMap().size());
    assertTrue(bean.getTestBeanMap().keySet().contains("testBean1"));
    assertTrue(bean.getTestBeanMap().values().contains(tb));
    assertSame(tb, bean.getTestBean());
    bf.destroySingletons();
  }

  public void testMethodInjectionWithMapAndNoMatches() {
    DefaultListableBeanFactory bf = new DefaultListableBeanFactory();
    AutowiredAnnotationBeanPostProcessor bpp = new AutowiredAnnotationBeanPostProcessor();
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.