如果没有Bundle-Activator,OSGi包如何开始

时间:2017-03-08 17:18:47

标签: osgi

如果MANIFEST-MF文件中没有Bundle-Activator,OSGi包如何变为活动状态?例如,Google guava可以作为捆绑包运行并在Karaf容器中变为活动状态,但MANIFEST-MF文件不包含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 个答案:

答案 0 :(得分:1)

首先,还有其他方法可以在捆绑中启动逻辑,例如它可以是Blueprint或Declarative Services。但我怀疑番石榴确实有这个, 所以你在这里看到的是一个典型的案例。 OSGi包通常遵循以下步骤:

a)安装了 b)解决了 c)开始 d)积极的 e)停止 f)卸载

这适用于所有捆绑包,只有片段才能保持解析状态,因为片段捆绑包本身无法启动/激活。

如果你的bundle(或者在这种情况下是guava)没有一个显式的Activator类,它将在活动阶段被调用,那么bundle仍然可以是活动的。

相关问题