Package org.springframework.beans.factory.xml

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


  }

  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

*/
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

    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

    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

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.