Java Code Examples for org.springframework.beans.factory.support.DefaultListableBeanFactory#getBeansOfType()
The following examples show how to use
org.springframework.beans.factory.support.DefaultListableBeanFactory#getBeansOfType() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: XmlBeanFactoryTests.java From java-technology-stack with MIT License | 6 votes |
@Test public void testAbstractParentBeans() { DefaultListableBeanFactory parent = new DefaultListableBeanFactory(); new XmlBeanDefinitionReader(parent).loadBeanDefinitions(PARENT_CONTEXT); parent.preInstantiateSingletons(); assertTrue(parent.isSingleton("inheritedTestBeanWithoutClass")); // abstract beans should not match Map<?, ?> tbs = parent.getBeansOfType(TestBean.class); assertEquals(2, tbs.size()); assertTrue(tbs.containsKey("inheritedTestBeanPrototype")); assertTrue(tbs.containsKey("inheritedTestBeanSingleton")); // abstract bean should throw exception on creation attempt try { parent.getBean("inheritedTestBeanWithoutClass"); fail("Should have thrown BeanIsAbstractException"); } catch (BeanIsAbstractException ex) { // expected } // non-abstract bean should work, even if it serves as parent assertTrue(parent.getBean("inheritedTestBeanPrototype") instanceof TestBean); }
Example 2
Source File: XmlBeanFactoryTests.java From spring-analysis-note with MIT License | 6 votes |
@Test public void testAbstractParentBeans() { DefaultListableBeanFactory parent = new DefaultListableBeanFactory(); new XmlBeanDefinitionReader(parent).loadBeanDefinitions(PARENT_CONTEXT); parent.preInstantiateSingletons(); assertTrue(parent.isSingleton("inheritedTestBeanWithoutClass")); // abstract beans should not match Map<?, ?> tbs = parent.getBeansOfType(TestBean.class); assertEquals(2, tbs.size()); assertTrue(tbs.containsKey("inheritedTestBeanPrototype")); assertTrue(tbs.containsKey("inheritedTestBeanSingleton")); // abstract bean should throw exception on creation attempt try { parent.getBean("inheritedTestBeanWithoutClass"); fail("Should have thrown BeanIsAbstractException"); } catch (BeanIsAbstractException ex) { // expected } // non-abstract bean should work, even if it serves as parent assertTrue(parent.getBean("inheritedTestBeanPrototype") instanceof TestBean); }
Example 3
Source File: DefaultListableBeanFactoryTests.java From java-technology-stack with MIT License | 5 votes |
@Test public void testRegisterExistingSingletonWithNameOverriding() { DefaultListableBeanFactory lbf = new DefaultListableBeanFactory(); Properties p = new Properties(); p.setProperty("test.(class)", TestBean.class.getName()); p.setProperty("test.name", "Tony"); p.setProperty("test.age", "48"); p.setProperty("test.spouse(ref)", "singletonObject"); (new PropertiesBeanDefinitionReader(lbf)).registerBeanDefinitions(p); lbf.registerBeanDefinition("singletonObject", new RootBeanDefinition(PropertiesFactoryBean.class)); Object singletonObject = new TestBean(); lbf.registerSingleton("singletonObject", singletonObject); lbf.preInstantiateSingletons(); assertTrue(lbf.isSingleton("singletonObject")); assertEquals(TestBean.class, lbf.getType("singletonObject")); TestBean test = (TestBean) lbf.getBean("test"); assertEquals(singletonObject, lbf.getBean("singletonObject")); assertEquals(singletonObject, test.getSpouse()); Map<?, ?> beansOfType = lbf.getBeansOfType(TestBean.class, false, true); assertEquals(2, beansOfType.size()); assertTrue(beansOfType.containsValue(test)); assertTrue(beansOfType.containsValue(singletonObject)); beansOfType = lbf.getBeansOfType(null, false, true); Iterator<String> beanNames = lbf.getBeanNamesIterator(); assertEquals("test", beanNames.next()); assertEquals("singletonObject", beanNames.next()); assertFalse(beanNames.hasNext()); assertEquals(2, beansOfType.size()); assertTrue(lbf.containsSingleton("test")); assertTrue(lbf.containsSingleton("singletonObject")); assertTrue(lbf.containsBeanDefinition("test")); assertTrue(lbf.containsBeanDefinition("singletonObject")); }
Example 4
Source File: DefaultListableBeanFactoryTests.java From spring4-understanding with Apache License 2.0 | 5 votes |
@Test public void testCircularReferenceThroughFactoryBeanTypeCheck() { DefaultListableBeanFactory lbf = new DefaultListableBeanFactory(); RootBeanDefinition bd = new RootBeanDefinition(ConstructorDependencyFactoryBean.class); bd.setAutowireMode(RootBeanDefinition.AUTOWIRE_CONSTRUCTOR); lbf.registerBeanDefinition("test", bd); try { lbf.getBeansOfType(String.class); fail("Should have thrown UnsatisfiedDependencyException"); } catch (UnsatisfiedDependencyException expected) { } }
Example 5
Source File: DefaultListableBeanFactoryTests.java From spring4-understanding with Apache License 2.0 | 5 votes |
@Test public void testRegisterExistingSingletonWithNameOverriding() { DefaultListableBeanFactory lbf = new DefaultListableBeanFactory(); Properties p = new Properties(); p.setProperty("test.(class)", TestBean.class.getName()); p.setProperty("test.name", "Tony"); p.setProperty("test.age", "48"); p.setProperty("test.spouse(ref)", "singletonObject"); (new PropertiesBeanDefinitionReader(lbf)).registerBeanDefinitions(p); lbf.registerBeanDefinition("singletonObject", new RootBeanDefinition(PropertiesFactoryBean.class)); Object singletonObject = new TestBean(); lbf.registerSingleton("singletonObject", singletonObject); lbf.preInstantiateSingletons(); assertTrue(lbf.isSingleton("singletonObject")); assertEquals(TestBean.class, lbf.getType("singletonObject")); TestBean test = (TestBean) lbf.getBean("test"); assertEquals(singletonObject, lbf.getBean("singletonObject")); assertEquals(singletonObject, test.getSpouse()); Map<?, ?> beansOfType = lbf.getBeansOfType(TestBean.class, false, true); assertEquals(2, beansOfType.size()); assertTrue(beansOfType.containsValue(test)); assertTrue(beansOfType.containsValue(singletonObject)); beansOfType = lbf.getBeansOfType(null, false, true); Iterator<String> beanNames = lbf.getBeanNamesIterator(); assertEquals("test", beanNames.next()); assertEquals("singletonObject", beanNames.next()); assertFalse(beanNames.hasNext()); assertEquals(2, beansOfType.size()); assertTrue(lbf.containsSingleton("test")); assertTrue(lbf.containsSingleton("singletonObject")); assertTrue(lbf.containsBeanDefinition("test")); assertTrue(lbf.containsBeanDefinition("singletonObject")); }
Example 6
Source File: DefaultListableBeanFactoryTests.java From spring4-understanding with Apache License 2.0 | 5 votes |
@Test public void testRegisterExistingSingletonWithReference() { DefaultListableBeanFactory lbf = new DefaultListableBeanFactory(); Properties p = new Properties(); p.setProperty("test.(class)", TestBean.class.getName()); p.setProperty("test.name", "Tony"); p.setProperty("test.age", "48"); p.setProperty("test.spouse(ref)", "singletonObject"); (new PropertiesBeanDefinitionReader(lbf)).registerBeanDefinitions(p); Object singletonObject = new TestBean(); lbf.registerSingleton("singletonObject", singletonObject); assertTrue(lbf.isSingleton("singletonObject")); assertEquals(TestBean.class, lbf.getType("singletonObject")); TestBean test = (TestBean) lbf.getBean("test"); assertEquals(singletonObject, lbf.getBean("singletonObject")); assertEquals(singletonObject, test.getSpouse()); Map<?, ?> beansOfType = lbf.getBeansOfType(TestBean.class, false, true); assertEquals(2, beansOfType.size()); assertTrue(beansOfType.containsValue(test)); assertTrue(beansOfType.containsValue(singletonObject)); beansOfType = lbf.getBeansOfType(null, false, true); assertEquals(2, beansOfType.size()); Iterator<String> beanNames = lbf.getBeanNamesIterator(); assertEquals("test", beanNames.next()); assertEquals("singletonObject", beanNames.next()); assertFalse(beanNames.hasNext()); assertTrue(lbf.containsSingleton("test")); assertTrue(lbf.containsSingleton("singletonObject")); assertTrue(lbf.containsBeanDefinition("test")); assertFalse(lbf.containsBeanDefinition("singletonObject")); }
Example 7
Source File: SQLErrorCodesFactory.java From spring4-understanding with Apache License 2.0 | 5 votes |
/** * Create a new instance of the {@link SQLErrorCodesFactory} class. * <p>Not public to enforce Singleton design pattern. Would be private * except to allow testing via overriding the * {@link #loadResource(String)} method. * <p><b>Do not subclass in application code.</b> * @see #loadResource(String) */ protected SQLErrorCodesFactory() { Map<String, SQLErrorCodes> errorCodes; try { DefaultListableBeanFactory lbf = new DefaultListableBeanFactory(); lbf.setBeanClassLoader(getClass().getClassLoader()); XmlBeanDefinitionReader bdr = new XmlBeanDefinitionReader(lbf); // Load default SQL error codes. Resource resource = loadResource(SQL_ERROR_CODE_DEFAULT_PATH); if (resource != null && resource.exists()) { bdr.loadBeanDefinitions(resource); } else { logger.warn("Default sql-error-codes.xml not found (should be included in spring.jar)"); } // Load custom SQL error codes, overriding defaults. resource = loadResource(SQL_ERROR_CODE_OVERRIDE_PATH); if (resource != null && resource.exists()) { bdr.loadBeanDefinitions(resource); logger.info("Found custom sql-error-codes.xml file at the root of the classpath"); } // Check all beans of type SQLErrorCodes. errorCodes = lbf.getBeansOfType(SQLErrorCodes.class, true, false); if (logger.isInfoEnabled()) { logger.info("SQLErrorCodes loaded: " + errorCodes.keySet()); } } catch (BeansException ex) { logger.warn("Error loading SQL error codes from config file", ex); errorCodes = Collections.emptyMap(); } this.errorCodesMap = errorCodes; }
Example 8
Source File: SQLErrorCodesFactory.java From effectivejava with Apache License 2.0 | 5 votes |
/** * Create a new instance of the {@link SQLErrorCodesFactory} class. * <p>Not public to enforce Singleton design pattern. Would be private * except to allow testing via overriding the * {@link #loadResource(String)} method. * <p><b>Do not subclass in application code.</b> * @see #loadResource(String) */ protected SQLErrorCodesFactory() { Map<String, SQLErrorCodes> errorCodes; try { DefaultListableBeanFactory lbf = new DefaultListableBeanFactory(); lbf.setBeanClassLoader(getClass().getClassLoader()); XmlBeanDefinitionReader bdr = new XmlBeanDefinitionReader(lbf); // Load default SQL error codes. Resource resource = loadResource(SQL_ERROR_CODE_DEFAULT_PATH); if (resource != null && resource.exists()) { bdr.loadBeanDefinitions(resource); } else { logger.warn("Default sql-error-codes.xml not found (should be included in spring.jar)"); } // Load custom SQL error codes, overriding defaults. resource = loadResource(SQL_ERROR_CODE_OVERRIDE_PATH); if (resource != null && resource.exists()) { bdr.loadBeanDefinitions(resource); logger.info("Found custom sql-error-codes.xml file at the root of the classpath"); } // Check all beans of type SQLErrorCodes. errorCodes = lbf.getBeansOfType(SQLErrorCodes.class, true, false); if (logger.isInfoEnabled()) { logger.info("SQLErrorCodes loaded: " + errorCodes.keySet()); } } catch (BeansException ex) { logger.warn("Error loading SQL error codes from config file", ex); errorCodes = Collections.emptyMap(); } this.errorCodesMap = errorCodes; }
Example 9
Source File: SQLErrorCodesFactory.java From lams with GNU General Public License v2.0 | 5 votes |
/** * Create a new instance of the {@link SQLErrorCodesFactory} class. * <p>Not public to enforce Singleton design pattern. Would be private * except to allow testing via overriding the * {@link #loadResource(String)} method. * <p><b>Do not subclass in application code.</b> * @see #loadResource(String) */ protected SQLErrorCodesFactory() { Map<String, SQLErrorCodes> errorCodes; try { DefaultListableBeanFactory lbf = new DefaultListableBeanFactory(); lbf.setBeanClassLoader(getClass().getClassLoader()); XmlBeanDefinitionReader bdr = new XmlBeanDefinitionReader(lbf); // Load default SQL error codes. Resource resource = loadResource(SQL_ERROR_CODE_DEFAULT_PATH); if (resource != null && resource.exists()) { bdr.loadBeanDefinitions(resource); } else { logger.warn("Default sql-error-codes.xml not found (should be included in spring.jar)"); } // Load custom SQL error codes, overriding defaults. resource = loadResource(SQL_ERROR_CODE_OVERRIDE_PATH); if (resource != null && resource.exists()) { bdr.loadBeanDefinitions(resource); logger.info("Found custom sql-error-codes.xml file at the root of the classpath"); } // Check all beans of type SQLErrorCodes. errorCodes = lbf.getBeansOfType(SQLErrorCodes.class, true, false); if (logger.isInfoEnabled()) { logger.info("SQLErrorCodes loaded: " + errorCodes.keySet()); } } catch (BeansException ex) { logger.warn("Error loading SQL error codes from config file", ex); errorCodes = Collections.emptyMap(); } this.errorCodesMap = errorCodes; }
Example 10
Source File: MangoConfigFactory.java From mango-spring-boot-starter with Apache License 2.0 | 5 votes |
private static PropertySourcesPlaceholderConfigurer getSinglePropertySourcesPlaceholderConfigurer(DefaultListableBeanFactory beanFactory) { // Take care not to cause early instantiation of all FactoryBeans Map<String, PropertySourcesPlaceholderConfigurer> beans = beanFactory.getBeansOfType(PropertySourcesPlaceholderConfigurer.class, false, false); if (beans.size() == 1) { return beans.values().iterator().next(); } return null; }
Example 11
Source File: DefaultListableBeanFactoryTests.java From java-technology-stack with MIT License | 5 votes |
@Test public void testCircularReferenceThroughFactoryBeanTypeCheck() { DefaultListableBeanFactory lbf = new DefaultListableBeanFactory(); RootBeanDefinition bd = new RootBeanDefinition(ConstructorDependencyFactoryBean.class); bd.setAutowireMode(RootBeanDefinition.AUTOWIRE_CONSTRUCTOR); lbf.registerBeanDefinition("test", bd); try { lbf.getBeansOfType(String.class); fail("Should have thrown UnsatisfiedDependencyException"); } catch (UnsatisfiedDependencyException expected) { } }
Example 12
Source File: DefaultListableBeanFactoryTests.java From java-technology-stack with MIT License | 5 votes |
@Test public void testRegisterExistingSingletonWithReference() { DefaultListableBeanFactory lbf = new DefaultListableBeanFactory(); Properties p = new Properties(); p.setProperty("test.(class)", TestBean.class.getName()); p.setProperty("test.name", "Tony"); p.setProperty("test.age", "48"); p.setProperty("test.spouse(ref)", "singletonObject"); (new PropertiesBeanDefinitionReader(lbf)).registerBeanDefinitions(p); Object singletonObject = new TestBean(); lbf.registerSingleton("singletonObject", singletonObject); assertTrue(lbf.isSingleton("singletonObject")); assertEquals(TestBean.class, lbf.getType("singletonObject")); TestBean test = (TestBean) lbf.getBean("test"); assertEquals(singletonObject, lbf.getBean("singletonObject")); assertEquals(singletonObject, test.getSpouse()); Map<?, ?> beansOfType = lbf.getBeansOfType(TestBean.class, false, true); assertEquals(2, beansOfType.size()); assertTrue(beansOfType.containsValue(test)); assertTrue(beansOfType.containsValue(singletonObject)); beansOfType = lbf.getBeansOfType(null, false, true); assertEquals(2, beansOfType.size()); Iterator<String> beanNames = lbf.getBeanNamesIterator(); assertEquals("test", beanNames.next()); assertEquals("singletonObject", beanNames.next()); assertFalse(beanNames.hasNext()); assertTrue(lbf.containsSingleton("test")); assertTrue(lbf.containsSingleton("singletonObject")); assertTrue(lbf.containsBeanDefinition("test")); assertFalse(lbf.containsBeanDefinition("singletonObject")); }
Example 13
Source File: SQLErrorCodesFactory.java From java-technology-stack with MIT License | 5 votes |
/** * Create a new instance of the {@link SQLErrorCodesFactory} class. * <p>Not public to enforce Singleton design pattern. Would be private * except to allow testing via overriding the * {@link #loadResource(String)} method. * <p><b>Do not subclass in application code.</b> * @see #loadResource(String) */ protected SQLErrorCodesFactory() { Map<String, SQLErrorCodes> errorCodes; try { DefaultListableBeanFactory lbf = new DefaultListableBeanFactory(); lbf.setBeanClassLoader(getClass().getClassLoader()); XmlBeanDefinitionReader bdr = new XmlBeanDefinitionReader(lbf); // Load default SQL error codes. Resource resource = loadResource(SQL_ERROR_CODE_DEFAULT_PATH); if (resource != null && resource.exists()) { bdr.loadBeanDefinitions(resource); } else { logger.info("Default sql-error-codes.xml not found (should be included in spring-jdbc jar)"); } // Load custom SQL error codes, overriding defaults. resource = loadResource(SQL_ERROR_CODE_OVERRIDE_PATH); if (resource != null && resource.exists()) { bdr.loadBeanDefinitions(resource); logger.debug("Found custom sql-error-codes.xml file at the root of the classpath"); } // Check all beans of type SQLErrorCodes. errorCodes = lbf.getBeansOfType(SQLErrorCodes.class, true, false); if (logger.isTraceEnabled()) { logger.trace("SQLErrorCodes loaded: " + errorCodes.keySet()); } } catch (BeansException ex) { logger.warn("Error loading SQL error codes from config file", ex); errorCodes = Collections.emptyMap(); } this.errorCodesMap = errorCodes; }
Example 14
Source File: DefaultListableBeanFactoryTests.java From spring-analysis-note with MIT License | 5 votes |
@Test public void testCircularReferenceThroughFactoryBeanTypeCheck() { DefaultListableBeanFactory lbf = new DefaultListableBeanFactory(); RootBeanDefinition bd = new RootBeanDefinition(ConstructorDependencyFactoryBean.class); bd.setAutowireMode(RootBeanDefinition.AUTOWIRE_CONSTRUCTOR); lbf.registerBeanDefinition("test", bd); try { lbf.getBeansOfType(String.class); fail("Should have thrown UnsatisfiedDependencyException"); } catch (UnsatisfiedDependencyException expected) { } }
Example 15
Source File: DefaultListableBeanFactoryTests.java From spring-analysis-note with MIT License | 5 votes |
@Test public void testRegisterExistingSingletonWithNameOverriding() { DefaultListableBeanFactory lbf = new DefaultListableBeanFactory(); Properties p = new Properties(); p.setProperty("test.(class)", TestBean.class.getName()); p.setProperty("test.name", "Tony"); p.setProperty("test.age", "48"); p.setProperty("test.spouse(ref)", "singletonObject"); (new PropertiesBeanDefinitionReader(lbf)).registerBeanDefinitions(p); lbf.registerBeanDefinition("singletonObject", new RootBeanDefinition(PropertiesFactoryBean.class)); Object singletonObject = new TestBean(); lbf.registerSingleton("singletonObject", singletonObject); lbf.preInstantiateSingletons(); assertTrue(lbf.isSingleton("singletonObject")); assertEquals(TestBean.class, lbf.getType("singletonObject")); TestBean test = (TestBean) lbf.getBean("test"); assertEquals(singletonObject, lbf.getBean("singletonObject")); assertEquals(singletonObject, test.getSpouse()); Map<?, ?> beansOfType = lbf.getBeansOfType(TestBean.class, false, true); assertEquals(2, beansOfType.size()); assertTrue(beansOfType.containsValue(test)); assertTrue(beansOfType.containsValue(singletonObject)); beansOfType = lbf.getBeansOfType(null, false, true); Iterator<String> beanNames = lbf.getBeanNamesIterator(); assertEquals("test", beanNames.next()); assertEquals("singletonObject", beanNames.next()); assertFalse(beanNames.hasNext()); assertEquals(2, beansOfType.size()); assertTrue(lbf.containsSingleton("test")); assertTrue(lbf.containsSingleton("singletonObject")); assertTrue(lbf.containsBeanDefinition("test")); assertTrue(lbf.containsBeanDefinition("singletonObject")); }
Example 16
Source File: DefaultListableBeanFactoryTests.java From spring-analysis-note with MIT License | 5 votes |
@Test public void testRegisterExistingSingletonWithReference() { DefaultListableBeanFactory lbf = new DefaultListableBeanFactory(); Properties p = new Properties(); p.setProperty("test.(class)", TestBean.class.getName()); p.setProperty("test.name", "Tony"); p.setProperty("test.age", "48"); p.setProperty("test.spouse(ref)", "singletonObject"); (new PropertiesBeanDefinitionReader(lbf)).registerBeanDefinitions(p); Object singletonObject = new TestBean(); lbf.registerSingleton("singletonObject", singletonObject); assertTrue(lbf.isSingleton("singletonObject")); assertEquals(TestBean.class, lbf.getType("singletonObject")); TestBean test = (TestBean) lbf.getBean("test"); assertEquals(singletonObject, lbf.getBean("singletonObject")); assertEquals(singletonObject, test.getSpouse()); Map<?, ?> beansOfType = lbf.getBeansOfType(TestBean.class, false, true); assertEquals(2, beansOfType.size()); assertTrue(beansOfType.containsValue(test)); assertTrue(beansOfType.containsValue(singletonObject)); beansOfType = lbf.getBeansOfType(null, false, true); assertEquals(2, beansOfType.size()); Iterator<String> beanNames = lbf.getBeanNamesIterator(); assertEquals("test", beanNames.next()); assertEquals("singletonObject", beanNames.next()); assertFalse(beanNames.hasNext()); assertTrue(lbf.containsSingleton("test")); assertTrue(lbf.containsSingleton("singletonObject")); assertTrue(lbf.containsBeanDefinition("test")); assertFalse(lbf.containsBeanDefinition("singletonObject")); }
Example 17
Source File: SQLErrorCodesFactory.java From spring-analysis-note with MIT License | 5 votes |
/** * Create a new instance of the {@link SQLErrorCodesFactory} class. * <p>Not public to enforce Singleton design pattern. Would be private * except to allow testing via overriding the * {@link #loadResource(String)} method. * <p><b>Do not subclass in application code.</b> * @see #loadResource(String) */ protected SQLErrorCodesFactory() { Map<String, SQLErrorCodes> errorCodes; try { DefaultListableBeanFactory lbf = new DefaultListableBeanFactory(); lbf.setBeanClassLoader(getClass().getClassLoader()); XmlBeanDefinitionReader bdr = new XmlBeanDefinitionReader(lbf); // Load default SQL error codes. Resource resource = loadResource(SQL_ERROR_CODE_DEFAULT_PATH); if (resource != null && resource.exists()) { bdr.loadBeanDefinitions(resource); } else { logger.info("Default sql-error-codes.xml not found (should be included in spring-jdbc jar)"); } // Load custom SQL error codes, overriding defaults. resource = loadResource(SQL_ERROR_CODE_OVERRIDE_PATH); if (resource != null && resource.exists()) { bdr.loadBeanDefinitions(resource); logger.debug("Found custom sql-error-codes.xml file at the root of the classpath"); } // Check all beans of type SQLErrorCodes. errorCodes = lbf.getBeansOfType(SQLErrorCodes.class, true, false); if (logger.isTraceEnabled()) { logger.trace("SQLErrorCodes loaded: " + errorCodes.keySet()); } } catch (BeansException ex) { logger.warn("Error loading SQL error codes from config file", ex); errorCodes = Collections.emptyMap(); } this.errorCodesMap = errorCodes; }
Example 18
Source File: FactoryBeanTests.java From java-technology-stack with MIT License | 4 votes |
@Test public void testAbstractFactoryBeanViaType() throws Exception { DefaultListableBeanFactory factory = new DefaultListableBeanFactory(); new XmlBeanDefinitionReader(factory).loadBeanDefinitions(ABSTRACT_CONTEXT); factory.getBeansOfType(AbstractFactoryBean.class); }
Example 19
Source File: FactoryBeanTests.java From spring4-understanding with Apache License 2.0 | 4 votes |
@Test public void testAbstractFactoryBeanViaType() throws Exception { DefaultListableBeanFactory factory = new DefaultListableBeanFactory(); new XmlBeanDefinitionReader(factory).loadBeanDefinitions(ABSTRACT_CONTEXT); factory.getBeansOfType(AbstractFactoryBean.class); }
Example 20
Source File: FactoryBeanTests.java From spring-analysis-note with MIT License | 4 votes |
@Test public void testAbstractFactoryBeanViaType() throws Exception { DefaultListableBeanFactory factory = new DefaultListableBeanFactory(); new XmlBeanDefinitionReader(factory).loadBeanDefinitions(ABSTRACT_CONTEXT); factory.getBeansOfType(AbstractFactoryBean.class); }