Examples of preInstantiateSingletons()


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

  @Test
  public void testPrototypeFactoryBeanNotEagerlyCalled() {
    DefaultListableBeanFactory lbf = new DefaultListableBeanFactory();
    lbf.registerBeanDefinition("test", new RootBeanDefinition(FactoryBeanThatShouldntBeCalled.class));
    lbf.preInstantiateSingletons();
  }

  @Test
  public void testLazyInitFactory() {
    DefaultListableBeanFactory lbf = new DefaultListableBeanFactory();
View Full Code Here

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

  @Test
  public void testLazyInitFactory() {
    DefaultListableBeanFactory lbf = new DefaultListableBeanFactory();
    lbf.registerBeanDefinition("test", new RootBeanDefinition(LazyInitFactory.class));
    lbf.preInstantiateSingletons();
    LazyInitFactory factory = (LazyInitFactory) lbf.getBean("&test");
    assertFalse(factory.initialized);
  }

  @Test
View Full Code Here

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

  @Test
  public void testSmartInitFactory() {
    DefaultListableBeanFactory lbf = new DefaultListableBeanFactory();
    lbf.registerBeanDefinition("test", new RootBeanDefinition(EagerInitFactory.class));
    lbf.preInstantiateSingletons();
    EagerInitFactory factory = (EagerInitFactory) lbf.getBean("&test");
    assertTrue(factory.initialized);
  }

  @Test
View Full Code Here

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

  @Test
  public void testPrototypeFactoryBeanNotEagerlyCalledInCaseOfBeanClassName() {
    DefaultListableBeanFactory lbf = new DefaultListableBeanFactory();
    lbf.registerBeanDefinition("test",
        new RootBeanDefinition(FactoryBeanThatShouldntBeCalled.class.getName(), null, null));
    lbf.preInstantiateSingletons();
  }

  @Test
  public void testPrototypeStringCreatedRepeatedly() {
    DefaultListableBeanFactory lbf = new DefaultListableBeanFactory();
View Full Code Here

Examples of org.springframework.beans.factory.xml.XmlBeanFactory.preInstantiateSingletons()

        ConfigurableListableBeanFactory factory = new XmlBeanFactory(
                new FileSystemResource(
                        "./ch5/src/conf/interaction/shutdownHook.xml"));

        // make sure the shutdown hook is created
        factory.preInstantiateSingletons();

        DestructiveBeanWithInterface bean = (DestructiveBeanWithInterface) factory.getBean("destructiveBean");
    }
}
View Full Code Here

Examples of org.springframework.beans.factory.xml.XmlBeanFactory.preInstantiateSingletons()

  }

  public void testProxyFactoryBeanWithAutodetect() throws Exception {
    try {
      XmlBeanFactory bf = new XmlBeanFactory(new ClassPathResource("proxyFactoryBean.xml", getClass()));
      bf.preInstantiateSingletons();
    }
    catch (BeanCreationException ex) {
      if (ex.getCause().getClass() == MBeanInfoRetrievalException.class) {
        fail("MBeanProxyFactoryBean should be ignored by MBeanExporter when running autodetect process");
      }
View Full Code Here

Examples of org.springframework.beans.factory.xml.XmlBeanFactory.preInstantiateSingletons()

*/
public class LazyInitTargetSourceTests extends TestCase {

  public void testLazyInitSingletonTargetSource() {
    XmlBeanFactory bf = new XmlBeanFactory(new ClassPathResource("lazyInitSingletonTests.xml", getClass()));
    bf.preInstantiateSingletons();

    ITestBean tb = (ITestBean) bf.getBean("proxy");
    assertFalse(bf.containsSingleton("target"));
    assertEquals(10, tb.getAge());
    assertTrue(bf.containsSingleton("target"));
View Full Code Here

Examples of org.springframework.beans.factory.xml.XmlBeanFactory.preInstantiateSingletons()

    assertTrue(bf.containsSingleton("target"));
  }

  public void testCustomLazyInitSingletonTargetSource() {
    XmlBeanFactory bf = new XmlBeanFactory(new ClassPathResource("customLazyInitTarget.xml", getClass()));
    bf.preInstantiateSingletons();

    ITestBean tb = (ITestBean) bf.getBean("proxy");
    assertFalse(bf.containsSingleton("target"));
    assertEquals("Rob Harrop", tb.getName());
    assertTrue(bf.containsSingleton("target"));
View Full Code Here

Examples of org.springframework.beans.factory.xml.XmlBeanFactory.preInstantiateSingletons()

    assertTrue(bf.containsSingleton("target"));
  }

  public void testLazyInitFactoryBeanTargetSource() {
    XmlBeanFactory bf = new XmlBeanFactory(new ClassPathResource("lazyInitFactoryBean.xml", getClass()));
    bf.preInstantiateSingletons();

    Set set1 = (Set) bf.getBean("proxy1");
    assertFalse(bf.containsSingleton("target1"));
    assertTrue(set1.contains("10"));
    assertTrue(bf.containsSingleton("target1"));
View Full Code Here

Examples of us.codecraft.tinyioc.beans.factory.AbstractBeanFactory.preInstantiateSingletons()

    for (Map.Entry<String, BeanDefinition> beanDefinitionEntry : xmlBeanDefinitionReader.getRegistry().entrySet()) {
      beanFactory.registerBeanDefinition(beanDefinitionEntry.getKey(), beanDefinitionEntry.getValue());
    }

        // 3.初始化bean
        beanFactory.preInstantiateSingletons();

    // 4.获取bean
    HelloWorldService helloWorldService = (HelloWorldService) beanFactory.getBean("helloWorldService");
    helloWorldService.helloWorld();
  }
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.