List bundle ID's only on servicemix

杀马特。学长 韩版系。学妹 提交于 2020-01-02 12:00:13

问题


I'm using ServiceMix and I was trying to list some bundles and retrieve only there bundle ID. I'm trying to do the following:

osgi:list | grep -i | awk xxx

I tried to use awk but that's not provided in ServiceMix. I also tried to use shell:exec like this:

osgi:list | grep -i | shell:exec awk 'xxx'

But that doesn't work either, maybe my approach is completely wrong. Does anybody else have some experience how I could achieve my goal of only retrieving the id's of a bundle?


回答1:


You can always make use of Karaf's shell language (Works as of karaf 2.3.1)

bundles = $.context bundles ;
echo "Printing bundle information" ;
each ($bundles) {
    symbolicName = $it symbolicName ;
    bundleId = (($it bundleid) toString) ;
    echo "Symbolic name : " $symbolicName " Bundle Id : " $bundleId ;
}

When ran this will output something similiar to :

Symbolic name :  org.apache.felix.framework  Bundle Id :  0
Symbolic name :  org.ops4j.pax.url.mvn  Bundle Id :  1
Symbolic name :  org.ops4j.pax.url.wrap  Bundle Id :  2
Symbolic name :  org.ops4j.pax.logging.pax-logging-service  Bundle Id :  3



回答2:


I dont think there is a sed/awk command. And the list command cannot only just show the bundle id.

You can log a JIRA ticket for an enhancement. Maybe for options to the list command to select what to list only (bundle id, bundle version, state etc.) http://karaf.apache.org/index/community/support.html



来源:https://stackoverflow.com/questions/16014100/list-bundle-ids-only-on-servicemix

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!