Tutorial:Work with osgi console

From OpenTutorials
Jump to: navigation, search

The OSGi console can be a useful tool when debugging or testing Cytoscape apps under development.

Starting the OSGi Console

To use the OSGi console, start Cytoscape using the command line. Open a terminal window and change directory to your Cytoscape installation. On MS Windows, type “cytoscape.bat”, on Mac or Linux, type “./cytoscape.sh”. After a while, Cytoscape will get started. On the terminal, a prompt that looks like the following will appear:

Cytoscape 3.0.1>

This is your OSGi interactive shell.

Useful OSGi Commands

Here is a list of commands you will find useful. You can also look at this page for more information, or use the "help" command to see a full list.

List Bundles

The command “list” will list all the Cytoscape bundles and their states, “Active”, “Installed”.

Cytoscape 3.0.1> list

Install a Bundle

To install your app bundle, use the "install" command. If you use Maven, you can reference a bundle installed in your repository as follows:

Cytoscape 3.0.1> install mvn:org.cytoscape.sample/sample02
Bundle ID: 169

You can install a bundle from a file:

Cytoscape 3.0.1> install file:/path/2/myApp.jar

After you issue this command, you will get your bundle ID if the command is executed successfully.

Start a Bundle

To start a bundle, use the "start" command. To do this, you need the bundle number (use the "list" command mentioned above if you don't know it). Then issue the following command: (substitute your own bundle number for 169)

Cytoscape 3.0.1> start 169

Invoke the “list” command - the bundle should now show up as "Active" if it started successfully.

[ 169] [Active     ] [            ] [  200] sample02 (3.0.0.alpha8-SNAPSHOT)

You can then use the app within Cytoscape.

Stop a Loaded Bundle

To stop a bundle that has been loaded, use the "stop" command with the bundle number as follows:

Cytoscape 3.0.1> stop 169

If you invoke the “list” command, you will notice that your bundle is now in state “Installed” instead of "Active".

[ 169] [Installed  ] [            ] [  200] sample02 (3.0.0.alpha8-SNAPSHOT)

Update a Bundle

To update a bundle that was previously installed, use the update command as follows:

Cytoscape 3.0.1> update 169

After you compile your app, you can use “update” to update your bundle. You may use this command a lot, when you are debugging your code.

Uninstall a Bundle

To uninstall a bundle, use the uninstall command as follows:

Cytoscape 3.0.1> uninstall 169

This will completely remove your app from Cytoscape. You can verify it with the 'list' command.