您的位置:首页 > 大数据 > 人工智能

dubbo学习笔记 六 dubbo-container

2016-12-18 12:52 429 查看
这个模块比较简单,东西也不多,好写



看下SpringContainer吧,里面就是把META-INF/spring 下面的文件加载起来

public class SpringContainer implements Container {

private static final Logger logger = LoggerFactory.getLogger(SpringContainer.class);

public static final String SPRING_CONFIG = "dubbo.spring.config";

public static final String DEFAULT_SPRING_CONFIG = "classpath*:META-INF/spring/*.xml";

static ClassPathXmlApplicationContext context;

public static ClassPathXmlApplicationContext getContext() {
return context;
}

public void start() {
String configPath = ConfigUtils.getProperty(SPRING_CONFIG);
if (configPath == null || configPath.length() == 0) {
configPath = DEFAULT_SPRING_CONFIG;
}
context = new ClassPathXmlApplicationContext(configPath.split("[,\\s]+"));
context.start();
}

public void stop() {
try {
if (context != null) {
context.stop();
context.close();
context = null;
}
} catch (Throwable e) {
logger.error(e.getMessage(), e);
}
}

}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: