2017-03-08 85 views
0

如何在MANIFEST-MF文件中沒有Bundle-Activator的情況下激活OSGi軟件包?例如,Google Guava可以作爲捆綁包運行並在Karaf容器中處於活動狀態,但MANIFEST-MF文件不包含Bundle-Activator屬性。OSGi軟件包如何在沒有Bundle-Activator的情況下啓動

Manifest-Version: 1.0 
Bnd-LastModified: 1408992499326 
Build-Jdk: 1.7.0-google-v6 
Built-By: cgdecker 
Bundle-Description: Guava is a suite of core and expanded libraries that 
    include utility classes, google's collections, io classes, and much 
    much more. Guava has only one code dependency - javax.annotation 
, per the JSR-305 spec. 
Bundle-DocURL: https://guava-libraries.googlecode.com/ 
Bundle-License: http://www.apache.org/licenses/LICENSE-2.0.txt 
Bundle-ManifestVersion: 2 
Bundle-Name: Guava: Google Core Libraries for Java 
Bundle-SymbolicName: com.google.guava 
Bundle-Version: 18.0.0 
Created-By: Apache Maven Bundle Plugin 
Export-Package: com.google.common.net;uses:="javax.annotation,com.google 
.common.base,com.google.common.hash,com.google.common.io,com.google.com 
mon.primitives,com.google.common.collect,com.google.common.escape";vers 
ion="18.0.0",com.google.common.html;uses:="com.google.common.escape,jav 
ax.annotation";version="18.0.0",com.google.common.collect;uses:="com.go 
ogle.common.base,javax.annotation,com.google.common.primitives,com.goog 
le.common.math";version="18.0.0",com.google.common.primitives;uses:="co 
m.google.common.base,javax.annotation,sun.misc";version="18.0.0",com.go 
ogle.common.base;uses:="javax.annotation";version="18.0.0",com.google.c 
ommon.escape;uses:="com.google.common.base,javax.annotation";version="1 
8.0.0",com.google.common.cache;uses:="com.google.common.collect,com.goo 
gle.common.util.concurrent,javax.annotation,com.google.common.base,com. 
google.common.primitives,sun.misc";version="18.0.0",com.google.common.e 
ventbus;uses:="com.google.common.collect,com.google.common.cache,javax. 
annotation,com.google.common.base,com.google.common.util.concurrent,com 
.google.common.reflect";version="18.0.0",com.google.common.util.concurr 
ent;uses:="com.google.common.base,javax.annotation,com.google.common.co 
llect,com.google.common.primitives,com.google.common.math";version="18. 
0.0",com.google.common.hash;uses:="com.google.common.primitives,com.goo 
gle.common.base,javax.annotation,com.google.common.math";version="18.0. 
0",com.google.common.io;uses:="javax.annotation,com.google.common.base, 
com.google.common.math,com.google.common.hash,com.google.common.collect 
,com.google.common.primitives";version="18.0.0",com.google.common.xml;u 
ses:="com.google.common.escape,javax.annotation";version="18.0.0",com.g 
oogle.common.reflect;uses:="javax.annotation,com.google.common.base,com 
.google.common.collect,com.google.common.primitives";version="18.0.0",c 
om.google.common.math;uses:="com.google.common.base,com.google.common.p 
rimitives,javax.annotation";version="18.0.0",com.google.common.annotati 
ons;version="18.0.0" 
Import-Package: javax.annotation;resolution:=optional,sun.misc;resolutio 
n:=optional 
Tool: Bnd-1.50.0 

回答

1

例如,還有其他方法可以在包中啓動邏輯,例如可以是Blueprint或Declarative Services。但我懷疑番石榴確實有這個,所以你在這裏看到的是一個典型的案例。 一個OSGi束通常遵循以下步驟:

一個)安裝
b)中解決
c)中開始
d)活性
E)停止
F)卸載

這是所有由於片段包本身不能啓動/激活,因此只有片段將保持已解析狀態。

如果你的包(或者番石榴在這種情況下)沒有一個顯式的Activator類,它將在活動階段被調用,該包仍然可以是活動的。

+0

是的。我認爲當一個bundle激活時,它不需要實例化任何類。但是當一個bundle有一個顯式的Activator類時,這個類將在活動階段被實例化。 –

相關問題