private void doTestPropertyPlaceholderConfigurer(boolean parentChildSeparation) {
StaticApplicationContext ac = new StaticApplicationContext();
if (parentChildSeparation) {
MutablePropertyValues pvs1 = new MutablePropertyValues();
pvs1.addPropertyValue("age", "${age}");
MutablePropertyValues pvs2 = new MutablePropertyValues();
pvs2.addPropertyValue("name", "name${var}${var}${");
pvs2.addPropertyValue("spouse", new RuntimeBeanReference("${ref}"));
RootBeanDefinition parent = new RootBeanDefinition(TestBean.class, pvs1);
ChildBeanDefinition bd = new ChildBeanDefinition("${parent}", pvs2);
ac.getDefaultListableBeanFactory().registerBeanDefinition("parent1", parent);
ac.getDefaultListableBeanFactory().registerBeanDefinition("tb1", bd);
}
else {
MutablePropertyValues pvs = new MutablePropertyValues();
pvs.addPropertyValue("age", "${age}");
pvs.addPropertyValue("name", "name${var}${var}${");
pvs.addPropertyValue("spouse", new RuntimeBeanReference("${ref}"));
RootBeanDefinition bd = new RootBeanDefinition(TestBean.class, pvs);
ac.getDefaultListableBeanFactory().registerBeanDefinition("tb1", bd);
}
ConstructorArgumentValues cas = new ConstructorArgumentValues();
cas.addIndexedArgumentValue(1, "${age}");
cas.addGenericArgumentValue("${var}name${age}");
MutablePropertyValues pvs = new MutablePropertyValues();
List friends = new ManagedList();
friends.add("na${age}me");
friends.add(new RuntimeBeanReference("${ref}"));
pvs.addPropertyValue("friends", friends);
Set someSet = new ManagedSet();
someSet.add("na${age}me");
someSet.add(new RuntimeBeanReference("${ref}"));
someSet.add(new TypedStringValue("${age}", Integer.class));
pvs.addPropertyValue("someSet", someSet);
Map someMap = new ManagedMap();
someMap.put(new TypedStringValue("key${age}"), new TypedStringValue("${age}"));
someMap.put(new TypedStringValue("key${age}ref"), new RuntimeBeanReference("${ref}"));
someMap.put("key1", new RuntimeBeanReference("${ref}"));
someMap.put("key2", "${age}name");
MutablePropertyValues innerPvs = new MutablePropertyValues();
innerPvs.addPropertyValue("touchy", "${os.name}");
someMap.put("key3", new RootBeanDefinition(TestBean.class, innerPvs));
MutablePropertyValues innerPvs2 = new MutablePropertyValues(innerPvs);
someMap.put("${key4}", new BeanDefinitionHolder(new ChildBeanDefinition("tb1", innerPvs2), "child"));
pvs.addPropertyValue("someMap", someMap);
RootBeanDefinition bd = new RootBeanDefinition(TestBean.class, cas, pvs);
ac.getDefaultListableBeanFactory().registerBeanDefinition("tb2", bd);
pvs = new MutablePropertyValues();
pvs.addPropertyValue("properties", "age=98\nvar=${m}var\nref=tb2\nm=my\nkey4=mykey4\nparent=parent1");
ac.registerSingleton("configurer", PropertyPlaceholderConfigurer.class, pvs);
ac.refresh();
TestBean tb1 = (TestBean) ac.getBean("tb1");