List of usage examples for org.springframework.beans.factory.support DefaultListableBeanFactory applyBeanPropertyValues
@Override public void applyBeanPropertyValues(Object existingBean, String beanName) throws BeansException
From source file:org.springframework.beans.factory.DefaultListableBeanFactoryTests.java
@Test public void testApplyBeanPropertyValues() { DefaultListableBeanFactory lbf = new DefaultListableBeanFactory(); MutablePropertyValues pvs = new MutablePropertyValues(); pvs.add("age", "99"); RootBeanDefinition bd = new RootBeanDefinition(TestBean.class); bd.setPropertyValues(pvs);//from w w w . j ava2 s.co m lbf.registerBeanDefinition("test", bd); TestBean tb = new TestBean(); assertEquals(0, tb.getAge()); lbf.applyBeanPropertyValues(tb, "test"); assertEquals(99, tb.getAge()); }
From source file:org.springframework.beans.factory.DefaultListableBeanFactoryTests.java
@Test public void testApplyBeanPropertyValuesWithIncompleteDefinition() { DefaultListableBeanFactory lbf = new DefaultListableBeanFactory(); MutablePropertyValues pvs = new MutablePropertyValues(); pvs.add("age", "99"); RootBeanDefinition bd = new RootBeanDefinition(); bd.setPropertyValues(pvs);// www. j a va 2 s.co m lbf.registerBeanDefinition("test", bd); TestBean tb = new TestBean(); assertEquals(0, tb.getAge()); lbf.applyBeanPropertyValues(tb, "test"); assertEquals(99, tb.getAge()); assertNull(tb.getBeanFactory()); assertNull(tb.getSpouse()); }