自定义Spring ApplicationContext 支持动态订阅spring配置
Posted 栀子花开~
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了自定义Spring ApplicationContext 支持动态订阅spring配置相关的知识,希望对你有一定的参考价值。
public class StringXmlApplicationContext extends AbstractXmlApplicationContext {
private Resource[] configResources;
public StringXmlApplicationContext(String stringXml) {
this(new String[] { stringXml }, null);
}
public StringXmlApplicationContext(String[] stringXmls) {
this(stringXmls, null);
}
public StringXmlApplicationContext(String[] stringXmls, ApplicationContext parent) {
super(parent);
this.configResources = new Resource[stringXmls.length];
for (int i = 0; i < stringXmls.length; i++) {
this.configResources[i] = new ByteArrayResource(stringXmls[i].getBytes());
}
refresh();
}
protected Resource[] getConfigResources() {
return this.configResources;
}
public ClassLoader getClassLoader() {
return this.getClass().getClassLoader();
}
}
以上是关于自定义Spring ApplicationContext 支持动态订阅spring配置的主要内容,如果未能解决你的问题,请参考以下文章
Spring - ApplicationContextInitializer 扩展接口