我也来玩Equinox(三)

16 篇文章 0 订阅
16 篇文章 0 订阅
  运行成功了,我们先来熟悉一下OSGI 的命令吧: 在控制台中输入 help ,显示帮助

osgi> help

Valid commands:

---Controlling the OSGi framework---

 launch - start the OSGi Framework

 shutdown - shutdown the OSGi Framework

 close - shutdown and exit

 exit - exit immediately (System.exit)

 init - uninstall all bundles

 setprop <key>=<value> - set the OSGi property

---Controlling Bundles---

 install - install and optionally start bundle from the given URL

 uninstall - uninstall the specified bundle(s)

 start - start the specified bundle(s)

 stop - stop the specified bundle(s)

 refresh - refresh the packages of the specified bundles

 update - update the specified bundle(s)

---Displaying Status---

 status [-s [<comma separated list of bundle states>]  [<segment of bsn>]] - display installed bundles and registered services

 ss [-s [<comma separated list of bundle states>]  [<segment of bsn>]] - display installed bundles (short status)

 services {filter} - display registered service details

 packages {<pkgname>|<id>|<location>} - display imported/exported package details

 bundles [-s [<comma separated list of bundle states>]  [<segment of bsn>]] - display details for all installed bundles

 bundle (<id>|<location>) - display details for the specified bundle(s)

 headers (<id>|<location>) - print bundle headers

 log (<id>|<location>) - display log entries

---Extras---

 exec <command> - execute a command in a separate process and wait

 fork <command> - execute a command in a separate process

 gc - perform a garbage collection

 getprop  { name } - displays the system properties with the given name, or all of them.

---Controlling Start Level---

 sl {(<id>|<location>)} - display the start level for the specified bundle, or for the framework if no bundle specified

 setfwsl <start level> - set the framework start level

 setbsl <start level> (<id>|<location>) - set the start level for the bundle(s)

 setibsl <start level> - set the initial bundle start level

---Controlling the Profiling---

 profilelog - Display & flush the profile log messages

---Eclipse Runtime commands.---

 diag - Displays unsatisfied constraints for the specified bundle(s).

---Controlling the Console---

 more - More prompt for console output

逐个命令来执行看看效果 

一、ss命令:查看所有的插件的运行状态:

osgi> ss

Framework is launched.

id State       Bundle

0 ACTIVE      org.eclipse.osgi_3.3.0.v20070530

406 ACTIVE      myFirstEquinoxExample_1.0.0

 

//ss命令是查看所有的插件的运行状态

二、shutdown命令:停止OSGI整个框架:

osgi> shutdown

已经成功将这个插件停止/卸载了

osgi> ss

Framework is shutdown.

id State       Bundle

0 RESOLVED    org.eclipse.osgi_3.3.0.v20070530

406 INSTALLED   myFirstEquinoxExample_1.0.0

//可以看到 shutdown 命令将整个OSGI都停用了,所有的 插件的状态都已经 不是 Active 状态了,//RESOLVED状态表示已经卸载,处于待命状态,可以随时通过 start 指定的ID 唤醒插件状态

三、launch命令:启动OSGI整个框架:

osgi> launch

osgi> ss

Framework is launched.

id State       Bundle

0 ACTIVE      org.eclipse.osgi_3.3.0.v20070530

406 RESOLVED    myFirstEquinoxExample_1.0.0

osgi> 

//这时发现只有org.eclipse.osgi_3.3.0.v20070530这个插件已经启动了,其他的插件还处于 //RESOLVED 状态,这时我们可以通过 stop 命令来停止指定的插件

四、install命令:安装指定路径的插件:

为了测试这个功能,我们在新建一个 Equinox 项目,然后右键 "导出" -> "插件开发" -> "可部署插件和功能段" -> "下一步" ->

在这里我们选择导入到 C: 盘,完成

在控制台输入插件的完整路径

osgi> install file:///C:/plugins/mySecondEquinoxExample_1.0.0.jar

Bundle id is 407

osgi> ss

Framework is launched.

id State       Bundle

0 ACTIVE      org.eclipse.osgi_3.3.0.v20070530

406 RESOLVED    myFirstEquinoxExample_1.0.0

407 INSTALLED   mySecondEquinoxExample_1.0.0

//可以看到 OSGI 分配了一个ID 给 mySecondEquinoxExample 这个项目,并使他处于已经安装的状态

五、uninstall命令:卸载指定的插件

osgi> ss

Framework is launched.

id State       Bundle

0 ACTIVE      org.eclipse.osgi_3.3.0.v20070530

406 RESOLVED    myFirstEquinoxExample_1.0.0

407 ACTIVE      mySecondEquinoxExample_1.0.0

osgi> uninstall 406

osgi> ss

Framework is launched.

id State       Bundle

0 ACTIVE      org.eclipse.osgi_3.3.0.v20070530

407 ACTIVE      mySecondEquinoxExample_1.0.0

//可以发现 myFirstEquinoxExample 这个项目已经被移除了

六、start命令:启动指定插件

osgi> ss

Framework is launched.

id State       Bundle

0 ACTIVE      org.eclipse.osgi_3.3.0.v20070530

406 RESOLVED    myFirstEquinoxExample_1.0.0

407 INSTALLED   mySecondEquinoxExample_1.0.0

osgi> start 407

这是的又一个OSGI的例子

osgi> ss

Framework is launched.

id State       Bundle

0 ACTIVE      org.eclipse.osgi_3.3.0.v20070530

406 RESOLVED    myFirstEquinoxExample_1.0.0

407 ACTIVE      mySecondEquinoxExample_1.0.0

七、stop 命令: 停止插件命令

osgi> ss

Framework is launched.

id State       Bundle

0 ACTIVE      org.eclipse.osgi_3.3.0.v20070530

407 ACTIVE      mySecondEquinoxExample_1.0.0

osgi> stop 407

已经成功将第二个插件停止/卸载了

osgi> ss

Framework is launched.

id State       Bundle

0 ACTIVE      org.eclipse.osgi_3.3.0.v20070530

407 RESOLVED    mySecondEquinoxExample_1.0.0

八、update命令:更新指定的插件

为了测试这个命令,我现在将第二个插件中的内容进行更新,然后在导出到刚才哪个位置

osgi> update 407

osgi> ss

Framework is launched.

id State       Bundle

0 ACTIVE      org.eclipse.osgi_3.3.0.v20070530

407 INSTALLED   mySecondEquinoxExample_1.0.0

osgi> start 407

这个本来是第二个插件的,现在内容进行了更新!

看见没有,数据已经更新了!

  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值