Eclipse RCP 玩转 Spring

时间:2014-05-27 03:15:56   收藏:0   阅读:324

近来上一个项目想在Eclipse RCP中使用Spring,在网上Google了一下发现这方面的材料比较少,晓得Spring自个有个Spring-OSGI的项目,能够在Spring中装备OSGI效劳。但是,我仅仅想在RCP中引进Spring来管理Java Bean,不想去研讨那个东西。所以,看看有没有啥简略的方法来处理这个疑问。在陈刚的BlOG中找到了疑问的有些答案。

所以,我在RCP项目的activator class中加入了

private ApplicationContext ctx;
2
3     private void initializeApplicationContext() {
4         ClassLoader oldLoader = Thread.currentThread().getContextClassLoader();
5         try{
6             Thread.currentThread().setContextClassLoader(getDefault().getClass().getClassLoader());
7             this.ctx = new FileSystemXmlApplicationContext(ProjectUtil.toFullPath("properties/applicationContext.xml"));
8         } finally {
9             Thread.currentThread().setContextClassLoader(oldLoader);
10         }
11     }


Eclipse RCP 玩转 Spring,布布扣,bubuko.com

评论(0
© 2014 mamicode.com 版权所有 京ICP备13008772号-2  联系我们:gaon5@hotmail.com
迷上了代码!