`
独狼
  • 浏览: 21222 次
  • 性别: Icon_minigender_2
社区版块
存档分类
最新评论

OSGi多版本组件共存的研究-Equinox的bug吗?

阅读更多
环境描述:
  组件三个,Summer3.0.0,Summer4.0.0,Autum3.0.0
依赖关系: Autum3.0.0依赖Summer3.0.0

MANIFEST文件分别如下:
Summer4.0.0:
Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: Summer Plug-in
Bundle-SymbolicName: Summer
Bundle-Version: 4.0.0
Bundle-Activator: summer.Activator
Bundle-Localization: plugin
Import-Package: org.osgi.framework;version="1.3.0"
Export-Package: summer.core;version="4.0.0"

Summer3.0.0:
Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: Summer Plug-in
Bundle-SymbolicName: Summer
Bundle-Version: 3.0.0
Bundle-Activator: summer.Activator
Bundle-Localization: plugin
Import-Package: org.osgi.framework;version="1.3.0"
Export-Package: summer.core;version="3.0.0"

Autum3.0.0

Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: Autum Plug-in
Bundle-SymbolicName: Autum
Bundle-Version: 3.0.0
Bundle-Activator: autum.Activator
Bundle-Localization: plugin
Import-Package: org.osgi.framework;version="1.3.0",
summer.core;version="3.0.0"
Require-Bundle: Summer;bundle-version="3.0.0"

介绍完了环境,下面开始正常的依赖性测试:
1.初始化Equinox Framework
C:\temp>java -jar org.eclipse.osgi_3.2.0.v20060601.jar -console

osgi> ss

Framework is launched.

id      State       Bundle
0       ACTIVE      system.bundle_3.2.0.v20060601

osgi>

2.只安装Autum3.0.0,运行,出错是正常的:
osgi> install reference:file:c:\temp\plugins\Autum_3.0.0.jar
Bundle id is 24

osgi> ss

Framework is launched.

id      State       Bundle
0       ACTIVE      system.bundle_3.2.0.v20060601
24      INSTALLED   Autum_3.0.0

osgi> start 24
org.osgi.framework.BundleException: The bundle could not be resolved. Reason: Mi
ssing Constraint: Require-Bundle: Summer; bundle-version="3.0.0"
        at org.eclipse.osgi.framework.internal.core.BundleHost.startWorker(Bundl
eHost.java:294)

3.在之前基础上再安装Summer3.0.0,运行,是可以成功的:
osgi> install reference:file:c:\temp\plugins\Summer_3.0.0.jar
Bundle id is 25

osgi> ss

Framework is launched.

id      State       Bundle
0       ACTIVE      system.bundle_3.2.0.v20060601
24      INSTALLED   Autum_3.0.0
25      INSTALLED   Summer_3.0.0

osgi> start 24
version 3,addPortfolio
version 3,addPartner
version 3,removePortfolio

osgi>

4.安装Summer4.0.0,停止Autum3.0.0,重启Equinox Framework,启动Autum3.0.0:
C:\temp>java -jar org.eclipse.osgi_3.2.0.v20060601.jar -console

osgi> ss

Framework is launched.

id      State       Bundle
0       ACTIVE      system.bundle_3.2.0.v20060601
24      RESOLVED    Autum_3.0.0
25      RESOLVED    Summer_3.0.0
26      INSTALLED   Summer_4.0.0

osgi> start 24
version 3,addPortfolio
version 3,addPartner
version 3,removePortfolio

osgi>

5.重新初始化Equinox Framework,卸载所有应用,重启,按刚才次序把三个应用全部装上:

C:\temp>java -jar org.eclipse.osgi_3.2.0.v20060601.jar -console

osgi> ss

Framework is launched.

id      State       Bundle
0       ACTIVE      system.bundle_3.2.0.v20060601

osgi> install reference:file:c:\temp\plugins\Autum_3.0.0.jar
Bundle id is 27

osgi> install reference:file:c:/temp/plugins/Summer_3.0.0.jar
Bundle id is 28

osgi> install reference:file:c:/temp/plugins/Summer_4.0.0.jar
Bundle id is 29

osgi> ss

Framework is launched.

id      State       Bundle
0       ACTIVE      system.bundle_3.2.0.v20060601
27      INSTALLED   Autum_3.0.0
28      INSTALLED   Summer_3.0.0
29      INSTALLED   Summer_4.0.0

osgi> start 27
version 4,addPortfolio
version 4,addPartner
version 4,removePortfolio

osgi>

结果是Autum3.0.0跑去抢Summer4.0.0的东西去了,这是为什么呢,难道是Equinox实现的bug?
分享到:
评论
3 楼 独狼 2006-09-29  
刚才试验Knopflerfish还试出了一个问题:就是当系统中没有匹配版本时,似乎会尽力使其互相凑合,具体表现是autum3.0设置成仅依赖summer.core3.0.0,而summer4.0提供的包是summer.core4.0.0,居然也能执行,不知道是不是OSGi Rc4的规定,还有待仔细研究。
2 楼 独狼 2006-09-29  
好伤心,没人理会我,难道大家没有多版本库的共存需求吗?
---------------------
另外,刚才下载了Knopflerfish2.0 ,试验的结果是正常的,几乎可以确定这是Equinox的Bug了。另外要多提一点的是Knopflerfish的GUI管理界面比Equinox的命令行好用,install ,uninstall,start,stop都图形化了,适合我这样的懒人实用,呵呵.
Knopflerfish有一点点小缺陷,就是安装了包后,点击包是看不到bundle的信息的,需要重启framework才行,还有就是一安装就立即启动bundle,这点也有点奇怪。
1 楼 独狼 2006-09-24  
研究OSGi的人果真很少,BlueDavy还要加油哦

相关推荐

Global site tag (gtag.js) - Google Analytics