(一)生命周期相关的类
BundleActivator接口是作为OSGI framework的一个入口,一般来说每个bundle需要定义自己Activator类,并实现这个接口.
当bundle start的时候会调用BundleAcivator的start方法,对应的bundle stop的时候调用BundleActivator的stop方法.
在start()方法中进行一些程序初始化的工作,例如获得需要的resource,初始化类, stop()方法需要释放resource.
我们可以把start()方法理解为java程序的public static void main(String[]),也就是程序的入口.
public interface BundleActivator {
public void start(BundleContext context) throws Exception;
public void stop(BundleContext context) throws Exception;
}
BundleContext是bundle生命周期的上下文,对于某个bundle在它的生命周期中,它的BundleConext是唯一的而且不会发生变化的.
public interface BundleContext {
...
Str