Java Code Examples for org.springframework.beans.factory.config.ConfigurableBeanFactory#registerAlias()
The following examples show how to use
org.springframework.beans.factory.config.ConfigurableBeanFactory#registerAlias() .
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: AbstractBeanFactoryTests.java From spring-analysis-note with MIT License | 6 votes |
@Test public void aliasing() { BeanFactory bf = getBeanFactory(); if (!(bf instanceof ConfigurableBeanFactory)) { return; } ConfigurableBeanFactory cbf = (ConfigurableBeanFactory) bf; String alias = "rods alias"; try { cbf.getBean(alias); fail("Shouldn't permit factory get on normal bean"); } catch (NoSuchBeanDefinitionException ex) { // Ok assertTrue(alias.equals(ex.getBeanName())); } // Create alias cbf.registerAlias("rod", alias); Object rod = getBeanFactory().getBean("rod"); Object aliasRod = getBeanFactory().getBean(alias); assertTrue(rod == aliasRod); }
Example 2
Source File: AbstractBeanFactoryTests.java From java-technology-stack with MIT License | 6 votes |
@Test public void aliasing() { BeanFactory bf = getBeanFactory(); if (!(bf instanceof ConfigurableBeanFactory)) { return; } ConfigurableBeanFactory cbf = (ConfigurableBeanFactory) bf; String alias = "rods alias"; try { cbf.getBean(alias); fail("Shouldn't permit factory get on normal bean"); } catch (NoSuchBeanDefinitionException ex) { // Ok assertTrue(alias.equals(ex.getBeanName())); } // Create alias cbf.registerAlias("rod", alias); Object rod = getBeanFactory().getBean("rod"); Object aliasRod = getBeanFactory().getBean(alias); assertTrue(rod == aliasRod); }
Example 3
Source File: AbstractBeanFactoryTests.java From spring4-understanding with Apache License 2.0 | 6 votes |
@Test public void aliasing() { BeanFactory bf = getBeanFactory(); if (!(bf instanceof ConfigurableBeanFactory)) { return; } ConfigurableBeanFactory cbf = (ConfigurableBeanFactory) bf; String alias = "rods alias"; try { cbf.getBean(alias); fail("Shouldn't permit factory get on normal bean"); } catch (NoSuchBeanDefinitionException ex) { // Ok assertTrue(alias.equals(ex.getBeanName())); } // Create alias cbf.registerAlias("rod", alias); Object rod = getBeanFactory().getBean("rod"); Object aliasRod = getBeanFactory().getBean(alias); assertTrue(rod == aliasRod); }