开发使用简单激活的 OSGi 捆绑软件

用于控制 OSGi 捆绑软件代码生命周期的最简单方法是在捆绑软件的其中一个类中实现 org.osgi.framework.BundleActivator 接口。当服务器启动和停止捆绑软件时,会调用 BundleActivator 接口的启动和停止方法。

关于此任务

如果您正在使用 WebSphere® Application Server Developer Tools,请创建 OSGi 捆绑软件项目,然后在该项目中创建 OSGi BundleActivator 类。然后,通过向捆绑软件 MANIFEST.MF 文件添加 Bundle-Activator 头来向 OSGi 框架标识捆绑软件 activator 类。例如:Bundle-Activator: com.example.bundle.Activator

示例

package com.example.bundle;

import org.osgi.framework.BundleActivator;
import org.osgi.framework.BundleContext;

public class Activator implements BundleActivator {
	public void start(BundleContext context) throws Exception {
		System.out.println("Sample bundle starting");
				// Insert bundle activation logic here
	}

		public void stop(BundleContext context) throws Exception {
		System.out.println("Sample bundle stopping");
				// Insert bundle deactivation logic here
	}
}

用于指示主题类型的图标 任务主题

文件名:twlp_bundle_simple_activation.html