ApplicationContext ctx = new FileSystemXmlApplicationContext("c:/beans.xml");ExampleBean eb = (ExampleBean)ctx.getBean("exampleBean"); String[] ctxs = new String[]{"ctx1.xml", "ctx2.xml"};ApplicationContext ctx = new FileSystemXmlApplicationContext(ctxs);
ApplicationContext parent = new ClassPathXmlApplicationContext("ctx1.xml");ApplicationContext ctx = new FileSystemXmlApplicationContext("ctx2.xml", parent); Resource getResource(String location)
interface Resource {boolean exists();
boolean isOpen();
String getDescription();
File getFile() throws IOException;
InputStream getInputStream() throws IOException;
}
<property name="resourceProperty">
<value>example/image.gif</value>
</property>
String getMessage(String code, Object[] args, String default, Locale loc)
<bean id="messageSource" class="...ResourceBundleMessageSource">
<property name="basenames">
<value>messages,errors</value>
</property>
</bean>
public class MyListenerBean implements ApplicationListener {public void onApplicationEvent(ApplicationEvent e) {// process event
}
}
public class ExampleBean implements ApplicationContextAware {ApplicationContext ctx;
public void setApplicationContext(ApplicationContext ctx)
throws BeansException {this.ctx = ctx;
}
public void sendEvent() {ctx.publishEvent(new MyApplicationEvent(this));
}
}
public class MyPostProcessor implements BeanFactoryPostProcessor {void postProcessBeanFactory(ConfigurableListableBeanFactory bf) {DateFormat fmt = new SimpleDateFormat("d/M/yyyy");