搭建简单的OSGI的hello world

来源:互联网 发布:什么软件可以下载图片 编辑:程序博客网 时间:2024/05/22 05:30
OSGI项目的搭建
一.项目搭建
1.新建工程的时候选择插件工程。
2.选择 an OSGi framework:Equinox
3.选择一个Available Template: Hello OSGi Bundle
4.项目新建完成。


二.配置运行环境
在Run Configurations中选择Bundles
在Target Platform中选择下面的配置项:
org.eclipse.equinox.console
org.apache.felix.gogo.command
org.apache.felix.gogo.runtime
org.apache.felix.gogo.shell


三.启动环境
选择运行刚才配置的启动环境,系统控制台将输出
“Hello World!!
osgi>
”输入ss查看当前多启动的Bundle包
控制台的输出如下:
id State       Bundle
0 ACTIVE      org.eclipse.osgi_3.9.1.v20140110-1610
2 ACTIVE      osgi02_1.0.0.qualifier
3 ACTIVE      org.apache.felix.gogo.runtime_0.10.0.v201209301036
4 ACTIVE      org.eclipse.equinox.console_1.0.100.v20130429-0953
5 ACTIVE      org.apache.felix.gogo.shell_0.10.0.v201212101605
6 ACTIVE      org.apache.felix.gogo.command_0.10.0.v201209301215


四.简单的控制台操作
1.ss:查看当前运行中的bundles包,该功能包含查看bundle序号,状态,名字
2.stop x:停止当前运行中的序号为X的bundle包
3.start x:启动ss所查看的序号为x的bundle包。


五.注意事项
在使用控制台停止某个bundle的时候,一定需要看清楚,是不是系统的bundle,
如果不想系统关闭,下面这些bundle不能随意停止,否则就会停止服务:
org.eclipse.equinox.console
org.apache.felix.gogo.command
org.apache.felix.gogo.runtime
org.apache.felix.gogo.shell
0 0
原创粉丝点击