Package org.springframework.beans.factory.support

Examples of org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.registerSingleton()


  public void testSingletons() {
    DefaultSingletonBeanRegistry beanRegistry = new DefaultSingletonBeanRegistry();

    TestBean tb = new TestBean();
    beanRegistry.registerSingleton("tb", tb);
    assertSame(tb, beanRegistry.getSingleton("tb"));

    TestBean tb2 = (TestBean) beanRegistry.getSingleton("tb2", new ObjectFactory() {
      public Object getObject() throws BeansException {
        return new TestBean();
View Full Code Here


  public void testDisposableBean() {
    DefaultSingletonBeanRegistry beanRegistry = new DefaultSingletonBeanRegistry();

    DerivedTestBean tb = new DerivedTestBean();
    beanRegistry.registerSingleton("tb", tb);
    beanRegistry.registerDisposableBean("tb", tb);
    assertSame(tb, beanRegistry.getSingleton("tb"));

    assertSame(tb, beanRegistry.getSingleton("tb"));
    assertEquals(1, beanRegistry.getSingletonCount());
View Full Code Here

                         DefaultSingletonBeanRegistry.class.getName()));
            }
           
            DefaultSingletonBeanRegistry registry = (DefaultSingletonBeanRegistry) factory;           
            // Register singleton
            registry.registerSingleton(beanName, bean);           
            // Register as disposable bean
            if (bean instanceof DisposableBean) {
                registry.registerDisposableBean(beanName, (DisposableBean) bean);
            }       
    }
View Full Code Here

  @Test
  public void testSingletons() {
    DefaultSingletonBeanRegistry beanRegistry = new DefaultSingletonBeanRegistry();

    TestBean tb = new TestBean();
    beanRegistry.registerSingleton("tb", tb);
    assertSame(tb, beanRegistry.getSingleton("tb"));

    TestBean tb2 = (TestBean) beanRegistry.getSingleton("tb2", new ObjectFactory<Object>() {
      @Override
      public Object getObject() throws BeansException {
View Full Code Here

  @Test
  public void testDisposableBean() {
    DefaultSingletonBeanRegistry beanRegistry = new DefaultSingletonBeanRegistry();

    DerivedTestBean tb = new DerivedTestBean();
    beanRegistry.registerSingleton("tb", tb);
    beanRegistry.registerDisposableBean("tb", tb);
    assertSame(tb, beanRegistry.getSingleton("tb"));

    assertSame(tb, beanRegistry.getSingleton("tb"));
    assertEquals(1, beanRegistry.getSingletonCount());
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.