use of cn.taketoday.beans.factory.support.PropertiesBeanDefinitionReader in project today-framework by TAKETODAY.
the class StaticApplicationContextMulticasterTests method createContext.
@Override
protected ConfigurableApplicationContext createContext() throws Exception {
StaticApplicationContext parent = new StaticApplicationContext();
Map<String, String> m = new HashMap<>();
m.put("name", "Roderick");
parent.registerPrototype("rod", TestBean.class, new PropertyValues(m));
m.put("name", "Albert");
parent.registerPrototype("father", TestBean.class, new PropertyValues(m));
parent.registerSingleton(StaticApplicationContext.APPLICATION_EVENT_MULTICASTER_BEAN_NAME, TestApplicationEventMulticaster.class, null);
parent.refresh();
parent.addApplicationListener(parentListener);
parent.getStaticMessageSource().addMessage("code1", Locale.getDefault(), "message1");
this.sac = new StaticApplicationContext(parent);
sac.registerSingleton("beanThatListens", BeanThatListens.class, new PropertyValues());
sac.registerSingleton("aca", ACATester.class, new PropertyValues());
sac.registerPrototype("aca-prototype", ACATester.class, new PropertyValues());
PropertiesBeanDefinitionReader reader = new PropertiesBeanDefinitionReader(sac.getBeanFactory());
Resource resource = new ClassPathResource("testBeans.properties", getClass());
reader.loadBeanDefinitions(new EncodedResource(resource, "ISO-8859-1"));
sac.refresh();
sac.addApplicationListener(listener);
sac.getStaticMessageSource().addMessage("code2", Locale.getDefault(), "message2");
return sac;
}
use of cn.taketoday.beans.factory.support.PropertiesBeanDefinitionReader in project today-infrastructure by TAKETODAY.
the class StaticApplicationContextMulticasterTests method createContext.
@Override
protected ConfigurableApplicationContext createContext() throws Exception {
StaticApplicationContext parent = new StaticApplicationContext();
Map<String, String> m = new HashMap<>();
m.put("name", "Roderick");
parent.registerPrototype("rod", TestBean.class, new PropertyValues(m));
m.put("name", "Albert");
parent.registerPrototype("father", TestBean.class, new PropertyValues(m));
parent.registerSingleton(StaticApplicationContext.APPLICATION_EVENT_MULTICASTER_BEAN_NAME, TestApplicationEventMulticaster.class, null);
parent.refresh();
parent.addApplicationListener(parentListener);
parent.getStaticMessageSource().addMessage("code1", Locale.getDefault(), "message1");
this.sac = new StaticApplicationContext(parent);
sac.registerSingleton("beanThatListens", BeanThatListens.class, new PropertyValues());
sac.registerSingleton("aca", ACATester.class, new PropertyValues());
sac.registerPrototype("aca-prototype", ACATester.class, new PropertyValues());
PropertiesBeanDefinitionReader reader = new PropertiesBeanDefinitionReader(sac.getBeanFactory());
Resource resource = new ClassPathResource("testBeans.properties", getClass());
reader.loadBeanDefinitions(new EncodedResource(resource, "ISO-8859-1"));
sac.refresh();
sac.addApplicationListener(listener);
sac.getStaticMessageSource().addMessage("code2", Locale.getDefault(), "message2");
return sac;
}
Aggregations