Examples of preInstantiateSingletons()


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

  }

  public void testByTypeAutowireWithInclusion() throws Exception {
    CountingFactory.reset();
    DefaultListableBeanFactory beanFactory = getBeanFactory("autowire-with-inclusion.xml");
    beanFactory.preInstantiateSingletons();
    TestBean rob = (TestBean) beanFactory.getBean("rob");
    assertEquals("props1", rob.getSomeProperties().getProperty("name"));
    assertEquals(1, CountingFactory.getFactoryBeanInstanceCount());
  }
View Full Code Here

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

  }

  public void testByTypeAutowireWithSelectiveInclusion() throws Exception {
    CountingFactory.reset();
    DefaultListableBeanFactory beanFactory = getBeanFactory("autowire-with-selective-inclusion.xml");
    beanFactory.preInstantiateSingletons();
    TestBean rob = (TestBean) beanFactory.getBean("rob");
    assertEquals("props1", rob.getSomeProperties().getProperty("name"));
    assertEquals(1, CountingFactory.getFactoryBeanInstanceCount());
  }
View Full Code Here

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

      public Object postProcessAfterInitialization(Object bean, String beanName) {
        return bean;
      }
    });
    BeanWithDisposableBean.closed = false;
    lbf.preInstantiateSingletons();
    lbf.destroySingletons();
    assertTrue("Destroy method invoked", BeanWithDisposableBean.closed);
  }

  @Test
View Full Code Here

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

      public Object postProcessAfterInitialization(Object bean, String beanName) {
        return bean;
      }
    });
    BeanWithDisposableBean.closed = false;
    lbf.preInstantiateSingletons();
    lbf.destroySingletons();
    assertTrue("Destroy method invoked", BeanWithCloseable.closed);
  }

  @Test
View Full Code Here

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

      public Object postProcessAfterInitialization(Object bean, String beanName) {
        return bean;
      }
    });
    BeanWithDestroyMethod.closed = false;
    lbf.preInstantiateSingletons();
    lbf.destroySingletons();
    assertTrue("Destroy method invoked", BeanWithDestroyMethod.closed);
  }

  @Test
View Full Code Here

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

          // Keep compiler happy about return
          throw new IllegalStateException();
        }
      }
    });
    lbf.preInstantiateSingletons();
    TestBean tb = (TestBean) lbf.getBean("test");
    assertEquals("Name was set on field by IAPP", nameSetOnField, tb.getName());
    if (!skipPropertyPopulation) {
      assertEquals("Property value still set", ageSetByPropertyValue, tb.getAge());
    }
View Full Code Here

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

      pvs.addPropertyValue(new PropertyValue("spouse", new RuntimeBeanReference("bean" + (i < 99 ? i + 1 : 0))));
      RootBeanDefinition bd = new RootBeanDefinition(TestBean.class);
      bd.setPropertyValues(pvs);
      lbf.registerBeanDefinition("bean" + i, bd);
    }
    lbf.preInstantiateSingletons();
    for (int i = 0; i < 1000; i++) {
      TestBean bean = (TestBean) lbf.getBean("bean" + i);
      TestBean otherBean = (TestBean) lbf.getBean("bean" + (i < 99 ? i + 1 : 0));
      assertTrue(bean.getSpouse() == otherBean);
    }
View Full Code Here

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

    DefaultListableBeanFactory lbf = new DefaultListableBeanFactory();
    RootBeanDefinition bd = new RootBeanDefinition(ConstructorDependencyBean.class);
    bd.setAutowireMode(RootBeanDefinition.AUTOWIRE_CONSTRUCTOR);
    lbf.registerBeanDefinition("test", bd);
    try {
      lbf.preInstantiateSingletons();
      fail("Should have thrown UnsatisfiedDependencyException");
    }
    catch (UnsatisfiedDependencyException expected) {
    }
  }
View Full Code Here

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

    DefaultListableBeanFactory lbf = new DefaultListableBeanFactory();
    RootBeanDefinition bd = new RootBeanDefinition(ConstructorDependencyFactoryBean.class);
    bd.setAutowireMode(RootBeanDefinition.AUTOWIRE_CONSTRUCTOR);
    lbf.registerBeanDefinition("test", bd);
    try {
      lbf.preInstantiateSingletons();
      fail("Should have thrown UnsatisfiedDependencyException");
    }
    catch (UnsatisfiedDependencyException expected) {
    }
  }
View Full Code Here

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

    bd.setAutowireMode(RootBeanDefinition.AUTOWIRE_CONSTRUCTOR);
    lbf.registerBeanDefinition("test", bd);
    RootBeanDefinition bd2 = new RootBeanDefinition(String.class);
    bd2.setAutowireMode(RootBeanDefinition.AUTOWIRE_CONSTRUCTOR);
    lbf.registerBeanDefinition("string", bd2);
    lbf.preInstantiateSingletons();
  }

  @Test
  public void testBeanDefinitionWithInterface() {
    DefaultListableBeanFactory lbf = new DefaultListableBeanFactory();
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.