下面列出了怎么用org.springframework.context.ACATester的API类实例代码及写法,或者点击链接到github查看源代码。
@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 MutablePropertyValues(m));
m.put("name", "Albert");
parent.registerPrototype("father", TestBean.class, new MutablePropertyValues(m));
parent.refresh();
parent.addApplicationListener(parentListener) ;
parent.getStaticMessageSource().addMessage("code1", Locale.getDefault(), "message1");
this.sac = new StaticApplicationContext(parent);
sac.registerSingleton("beanThatListens", BeanThatListens.class, new MutablePropertyValues());
sac.registerSingleton("aca", ACATester.class, new MutablePropertyValues());
sac.registerPrototype("aca-prototype", ACATester.class, new MutablePropertyValues());
PropertiesBeanDefinitionReader reader = new PropertiesBeanDefinitionReader(sac.getDefaultListableBeanFactory());
reader.loadBeanDefinitions(new ClassPathResource("testBeans.properties", getClass()));
sac.refresh();
sac.addApplicationListener(listener);
sac.getStaticMessageSource().addMessage("code2", Locale.getDefault(), "message2");
return sac;
}
@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 MutablePropertyValues(m));
m.put("name", "Albert");
parent.registerPrototype("father", TestBean.class, new MutablePropertyValues(m));
parent.refresh();
parent.addApplicationListener(parentListener) ;
parent.getStaticMessageSource().addMessage("code1", Locale.getDefault(), "message1");
this.sac = new StaticApplicationContext(parent);
sac.registerSingleton("beanThatListens", BeanThatListens.class, new MutablePropertyValues());
sac.registerSingleton("aca", ACATester.class, new MutablePropertyValues());
sac.registerPrototype("aca-prototype", ACATester.class, new MutablePropertyValues());
PropertiesBeanDefinitionReader reader = new PropertiesBeanDefinitionReader(sac.getDefaultListableBeanFactory());
reader.loadBeanDefinitions(new ClassPathResource("testBeans.properties", getClass()));
sac.refresh();
sac.addApplicationListener(listener);
sac.getStaticMessageSource().addMessage("code2", Locale.getDefault(), "message2");
return sac;
}
@Override
protected ConfigurableApplicationContext createContext() throws Exception {
StaticApplicationContext parent = new StaticApplicationContext();
Map<String, String> m = new HashMap<String, String>();
m.put("name", "Roderick");
parent.registerPrototype("rod", TestBean.class, new MutablePropertyValues(m));
m.put("name", "Albert");
parent.registerPrototype("father", TestBean.class, new MutablePropertyValues(m));
parent.refresh();
parent.addApplicationListener(parentListener) ;
parent.getStaticMessageSource().addMessage("code1", Locale.getDefault(), "message1");
this.sac = new StaticApplicationContext(parent);
sac.registerSingleton("beanThatListens", BeanThatListens.class, new MutablePropertyValues());
sac.registerSingleton("aca", ACATester.class, new MutablePropertyValues());
sac.registerPrototype("aca-prototype", ACATester.class, new MutablePropertyValues());
PropertiesBeanDefinitionReader reader = new PropertiesBeanDefinitionReader(sac.getDefaultListableBeanFactory());
reader.loadBeanDefinitions(new ClassPathResource("testBeans.properties", getClass()));
sac.refresh();
sac.addApplicationListener(listener);
sac.getStaticMessageSource().addMessage("code2", Locale.getDefault(), "message2");
return sac;
}
@Override
protected ConfigurableApplicationContext createContext() throws Exception {
StaticApplicationContext parent = new StaticApplicationContext();
Map<String, String> m = new HashMap<>();
m.put("name", "Roderick");
parent.registerPrototype("rod", org.springframework.tests.sample.beans.TestBean.class, new MutablePropertyValues(m));
m.put("name", "Albert");
parent.registerPrototype("father", org.springframework.tests.sample.beans.TestBean.class, new MutablePropertyValues(m));
parent.refresh();
parent.addApplicationListener(parentListener);
this.sac = new StaticApplicationContext(parent);
sac.registerSingleton("beanThatListens", BeanThatListens.class, new MutablePropertyValues());
sac.registerSingleton("aca", ACATester.class, new MutablePropertyValues());
sac.registerPrototype("aca-prototype", ACATester.class, new MutablePropertyValues());
PropertiesBeanDefinitionReader reader = new PropertiesBeanDefinitionReader(sac.getDefaultListableBeanFactory());
reader.loadBeanDefinitions(new ClassPathResource("testBeans.properties", getClass()));
sac.refresh();
sac.addApplicationListener(listener);
StaticMessageSource messageSource = sac.getStaticMessageSource();
Map<String, String> usMessages = new HashMap<>(3);
usMessages.put("message.format.example1", MSG_TXT1_US);
usMessages.put("message.format.example2", MSG_TXT2_US);
usMessages.put("message.format.example3", MSG_TXT3_US);
messageSource.addMessages(usMessages, Locale.US);
messageSource.addMessage("message.format.example1", Locale.UK, MSG_TXT1_UK);
return sac;
}
@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 MutablePropertyValues(m));
m.put("name", "Albert");
parent.registerPrototype("father", TestBean.class, new MutablePropertyValues(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 MutablePropertyValues());
sac.registerSingleton("aca", ACATester.class, new MutablePropertyValues());
sac.registerPrototype("aca-prototype", ACATester.class, new MutablePropertyValues());
PropertiesBeanDefinitionReader reader = new PropertiesBeanDefinitionReader(sac.getDefaultListableBeanFactory());
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;
}
@Override
protected ConfigurableApplicationContext createContext() throws Exception {
StaticApplicationContext parent = new StaticApplicationContext();
Map<String, String> m = new HashMap<>();
m.put("name", "Roderick");
parent.registerPrototype("rod", org.springframework.tests.sample.beans.TestBean.class, new MutablePropertyValues(m));
m.put("name", "Albert");
parent.registerPrototype("father", org.springframework.tests.sample.beans.TestBean.class, new MutablePropertyValues(m));
parent.refresh();
parent.addApplicationListener(parentListener);
this.sac = new StaticApplicationContext(parent);
sac.registerSingleton("beanThatListens", BeanThatListens.class, new MutablePropertyValues());
sac.registerSingleton("aca", ACATester.class, new MutablePropertyValues());
sac.registerPrototype("aca-prototype", ACATester.class, new MutablePropertyValues());
PropertiesBeanDefinitionReader reader = new PropertiesBeanDefinitionReader(sac.getDefaultListableBeanFactory());
reader.loadBeanDefinitions(new ClassPathResource("testBeans.properties", getClass()));
sac.refresh();
sac.addApplicationListener(listener);
StaticMessageSource messageSource = sac.getStaticMessageSource();
Map<String, String> usMessages = new HashMap<>(3);
usMessages.put("message.format.example1", MSG_TXT1_US);
usMessages.put("message.format.example2", MSG_TXT2_US);
usMessages.put("message.format.example3", MSG_TXT3_US);
messageSource.addMessages(usMessages, Locale.US);
messageSource.addMessage("message.format.example1", Locale.UK, MSG_TXT1_UK);
return sac;
}
@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 MutablePropertyValues(m));
m.put("name", "Albert");
parent.registerPrototype("father", TestBean.class, new MutablePropertyValues(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 MutablePropertyValues());
sac.registerSingleton("aca", ACATester.class, new MutablePropertyValues());
sac.registerPrototype("aca-prototype", ACATester.class, new MutablePropertyValues());
PropertiesBeanDefinitionReader reader = new PropertiesBeanDefinitionReader(sac.getDefaultListableBeanFactory());
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;
}
@Override
protected ConfigurableApplicationContext createContext() throws Exception {
StaticApplicationContext parent = new StaticApplicationContext();
Map<String, String> m = new HashMap<String, String>();
m.put("name", "Roderick");
parent.registerPrototype("rod", org.springframework.tests.sample.beans.TestBean.class, new MutablePropertyValues(m));
m.put("name", "Albert");
parent.registerPrototype("father", org.springframework.tests.sample.beans.TestBean.class, new MutablePropertyValues(m));
parent.refresh();
parent.addApplicationListener(parentListener);
this.sac = new StaticApplicationContext(parent);
sac.registerSingleton("beanThatListens", BeanThatListens.class, new MutablePropertyValues());
sac.registerSingleton("aca", ACATester.class, new MutablePropertyValues());
sac.registerPrototype("aca-prototype", ACATester.class, new MutablePropertyValues());
PropertiesBeanDefinitionReader reader = new PropertiesBeanDefinitionReader(sac.getDefaultListableBeanFactory());
reader.loadBeanDefinitions(new ClassPathResource("testBeans.properties", getClass()));
sac.refresh();
sac.addApplicationListener(listener);
StaticMessageSource messageSource = sac.getStaticMessageSource();
Map<String, String> usMessages = new HashMap<String, String>(3);
usMessages.put("message.format.example1", MSG_TXT1_US);
usMessages.put("message.format.example2", MSG_TXT2_US);
usMessages.put("message.format.example3", MSG_TXT3_US);
messageSource.addMessages(usMessages, Locale.US);
messageSource.addMessage("message.format.example1", Locale.UK, MSG_TXT1_UK);
return sac;
}
@Override
protected ConfigurableApplicationContext createContext() throws Exception {
StaticApplicationContext parent = new StaticApplicationContext();
Map<String, String> m = new HashMap<String, String>();
m.put("name", "Roderick");
parent.registerPrototype("rod", TestBean.class, new MutablePropertyValues(m));
m.put("name", "Albert");
parent.registerPrototype("father", TestBean.class, new MutablePropertyValues(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 MutablePropertyValues());
sac.registerSingleton("aca", ACATester.class, new MutablePropertyValues());
sac.registerPrototype("aca-prototype", ACATester.class, new MutablePropertyValues());
PropertiesBeanDefinitionReader reader = new PropertiesBeanDefinitionReader(sac.getDefaultListableBeanFactory());
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;
}