{"id":311,"date":"2014-06-15T04:07:26","date_gmt":"2014-06-15T09:07:26","guid":{"rendered":"http:\/\/www.buluschek.com\/?p=311"},"modified":"2023-07-02T10:49:23","modified_gmt":"2023-07-02T08:49:23","slug":"felix-gogo-shell-command-examples-cheat-sheet","status":"publish","type":"post","link":"https:\/\/www.buluschek.com\/?p=311","title":{"rendered":"Felix Gogo shell command examples &#038; cheat sheet"},"content":{"rendered":"<p>A short overview of frequently used Felix Gogo OSGi commands with examples.<\/p>\n<ul>\n<ul>\n<li>List all installed bundles on the system (nb. lb is short for list-bundles)\n<pre>g! lb\r\nSTART LEVEL 1\r\nID|State |Level|Name\r\n0|Active | 0|System Bundle (4.2.1)\r\n1|Active | 1|Apache Felix Bundle Repository (1.6.6)\r\n...\r\n<\/pre>\n<\/li>\n<li>Get the current framework startlevel and then sets it. When setting a new level, all levels in between the current and the new level are activated in between.\n<pre>g! frameworklevel\r\nLevel is 1\r\ng! frameworklevel 2\r\ng! frameworklevel\r\nLevel is 2\r\n<\/pre>\n<\/li>\n<li>For bundles which will be newly installed, set which bundle start level they will have assigned (here level 3) after install\n<pre>g! bundlelevel -i 3<\/pre>\n<\/li>\n<li>For bundles already installed, set the bundle start level, here to level 5 for bundles 94 and 172\n<pre>g! bundlelevel -s 5 94 172<\/pre>\n<\/li>\n<li>Set bundle 23 to be started, when the frameworklevel gets equal or above the bundle&#8217;s start level (resp stop)\n<pre>g! start 23\r\ng! stop 23<\/pre>\n<\/li>\n<li>Install a bundle from a local file or a remote location. (note using a repository instead of direct links is described below)\n<pre>g! install file:\/\/\/path\/to\/bundle.jar\r\nBundle ID: 173\r\ng! install http:\/\/www.example.com\/path\/to\/bundle.jar\r\nBundle ID: 174<\/pre>\n<\/li>\n<li>Update a bundle from it&#8217;s default location (here bundle 174)\n<pre>g! update 174<\/pre>\n<\/li>\n<li>Uninstall a bundle\n<pre>g! uninstall 174<\/pre>\n<\/li>\n<li>Get detailed infos on a bundles headers (basically the manifest content)\n<pre>g! headers 3\r\nApache Felix EventAdmin (3)\r\n---------------------------\r\nBnd-LastModified = 1349073346464\r\n...\r\nBundle-SymbolicName = org.apache.felix.eventadmin\r\n...\r\nBundle-Version = 1.3.2\r\n...\r\nExport-Package = org.osgi.service.event;uses:=\"org.osgi.framework\";version=\"1.3\"\r\n...<\/pre>\n<\/li>\n<\/ul>\n<\/ul>\n<p>&nbsp;<\/p>\n<ul>\n<li>Get list of services offered by a bundle (here bundle 2)\n<pre>g! inspect capability service 2\r\norg.apache.felix.configadmin [2] provides:\r\n------------------------------------------\r\nservice; org.apache.felix.cm.PersistenceManager with properties:\r\nservice.description = Platform Filesystem Persistence Manager\r\nservice.id = 5\r\nservice.pid = org.apache.felix.cm.file.FilePersistenceManager\r\nservice.ranking = -2147483648\r\nservice.vendor = Apache Software Foundation\r\nUsed by:\r\norg.apache.felix.configadmin [2]\r\n...<\/pre>\n<\/li>\n<li>Refresh bundles, so that they let go of old packages and surely use the new ones you just updated. If neceessary this will restart the bundles\n<pre>g! refresh<\/pre>\n<\/li>\n<li>Print the System properties\n<pre>g! system:getproperties\r\njava.vm.version 24.51-b03\r\nsun.jnu.encoding ANSI_X3.4-1968\r\n...<\/pre>\n<\/li>\n<\/ul>\n<p>&nbsp;<\/p>\n<h4>Interaction with an OBR, a remote OSGi bundle repository<\/h4>\n<ul>\n<li>List all and add remote repositories\n<pre>g! repos list\r\nNo repository URLs are set.\r\ng! repos add http:\/\/updates.example.com\/repository\/repository.xml\r\ng! repos list\r\nhttp:\/\/updates.example.com\/repository\/repository.xml\r\n<\/pre>\n<\/li>\n<li>Refresh the list of provided bundle of a repository\n<pre>repos refresh http:\/\/updates.example.com\/repository\/repository.xml<\/pre>\n<\/li>\n<li>List content of remote repositories\n<pre>g! list\r\nMy First Bundle (0.0.1.SNAPSHOT)\r\nMy Second Bundle (0.0.3.SNAPSHOT, ...)\r\n<\/pre>\n<\/li>\n<li>Install from remote repository\n<pre>g! deploy \"My First Bundle\"\r\nTarget resource(s):\r\n-------------------\r\nMy First Bundle (0.0.1.SNAPSHOT)\r\nDeploying...\r\ndone.<\/pre>\n<\/li>\n<\/ul>\n<h4>Built-in commands<\/h4>\n<ul>\n<li>Use grep to filter output.\n<pre>g! lb | grep Felix\r\n  1|Active     |    1|Apache Felix Configuration Admin Service (1.8.0)\r\n 37|Active     |    1|Apache Felix Dependency Manager (3.2.0)\r\n ...\r\n<\/pre>\n<\/li>\n<\/ul>\n<h4>Using registered services<\/h4>\n<ul>\n<li>Get a service and call methods on it\n<pre>_sref = $.context getServiceReference \"com.example.MyServiceInterface\"\r\n_srv = $.context getService $_sref\r\n$_srv getFooBar\r\n...\r\n$.context ungetService $_sref\r\n<\/pre>\n<p>or with a filter<\/p>\n<pre>\r\n_srefs = $.context getServiceReferences \"com.example.MyServiceInterface\" \"(filterKey=filterValue)\";\r\n_srv = $.context getService ($_srefs 0)\r\n$_srv getFooBar\r\n...\r\n_srv = $.context ungetService ($_srefs 0)\r\n<\/pre>\n<\/li>\n<\/ul>\n","protected":false},"excerpt":{"rendered":"<p>A short overview of frequently used Felix Gogo OSGi commands with examples. List all installed bundles on the system (nb. lb is short for list-bundles) g! lb START LEVEL 1 ID|State |Level|Name 0|Active | 0|System Bundle (4.2.1) 1|Active | 1|Apache Felix Bundle Repository (1.6.6) &#8230; Get the current framework startlevel and then sets it. When [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[25,1],"tags":[],"class_list":["post-311","post","type-post","status-publish","format-standard","hentry","category-osgi","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/www.buluschek.com\/index.php?rest_route=\/wp\/v2\/posts\/311","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.buluschek.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.buluschek.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.buluschek.com\/index.php?rest_route=\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.buluschek.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=311"}],"version-history":[{"count":14,"href":"https:\/\/www.buluschek.com\/index.php?rest_route=\/wp\/v2\/posts\/311\/revisions"}],"predecessor-version":[{"id":335,"href":"https:\/\/www.buluschek.com\/index.php?rest_route=\/wp\/v2\/posts\/311\/revisions\/335"}],"wp:attachment":[{"href":"https:\/\/www.buluschek.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=311"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.buluschek.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=311"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.buluschek.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=311"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}