Example usage for org.springframework.beans.factory.support DefaultListableBeanFactory setAllowCircularReferences

List of usage examples for org.springframework.beans.factory.support DefaultListableBeanFactory setAllowCircularReferences

Introduction

In this page you can find the example usage for org.springframework.beans.factory.support DefaultListableBeanFactory setAllowCircularReferences.

Prototype

public void setAllowCircularReferences(boolean allowCircularReferences) 

Source Link

Document

Set whether to allow circular references between beans - and automatically try to resolve them.

Usage

From source file:org.springframework.beans.factory.xml.XmlBeanFactoryTests.java

@Test
public void testCircularReferencesWithNotAllowed() {
    DefaultListableBeanFactory xbf = new DefaultListableBeanFactory();
    xbf.setAllowCircularReferences(false);
    XmlBeanDefinitionReader reader = new XmlBeanDefinitionReader(xbf);
    reader.setValidationMode(XmlBeanDefinitionReader.VALIDATION_NONE);
    reader.loadBeanDefinitions(REFTYPES_CONTEXT);
    try {/*from  ww  w  .  j av  a2  s . c o  m*/
        xbf.getBean("jenny");
        fail("Should have thrown BeanCreationException");
    } catch (BeanCreationException ex) {
        assertTrue(ex.contains(BeanCurrentlyInCreationException.class));
    }
}