Part 2 – OSGi: Creating a workspace

< Part 1 –  OSGi: What, Why & How | OSGi tutorial home

To implement my OSGi based applications I am using Equinox (Eclipse Foundation). If you are using Eclipse IDE (which is based on OSGi) you don’ t need to download the OSGi core APIs as you can find it in the Eclipse_Home/plugins directory. If you are using Eclipse Ganymede, you will find a JAR org.eclipse.osgi_3.4.0.v20080605-1900.jar or a higher version. That’s all what we want (for now).

Equinox download: http://download.eclipse.org/eclipse/equinox/.


Workspace directory structure

The directory structure should look like this.

OSGiWorkspace
|-- configuration
|  |-- config.ini               - Framework configuration
|-- org.eclipse.osgi_3.4.2.jar  - Framework
|-- subin.orgi.simple.jar       - My bundle
|
|-- <other bundles, archives>

The config.ini is the place where we can configure the framework and bundle behavior. We can talk about it later.


Running the Equinox core

Copy org.eclipse.osgi JAR in to your workspace directory. You can start the OSGi framework by running the org.eclipse.osgi JAR file. Use the following command:

your/workspace/dir> java -jar org.eclipse.osgi_3.4.2.jar -console

This will start an OSGi console for us using which we can start, install, uninstall OSGi bundles.

osgi console

In the above screen shot you can see the OSGi console with the list of installed bundles. (I am using Equinox 3.4.2.)


Configuring the Equinox workspace
We can configure Equinox in various ways. I think its very early to mention all those things here. If you are really interested in knowing that, check this link.

Quick start guide: http://www.eclipse.org/equinox/documents/quickstart.php


Starting Equinox faceless
When we start Equinox core using the above command, it will launch an OSGi console. There is a way to start Equinox faceless (with out console). Try this command.

java -jar org.eclipse.osgi_3.4.2.jar -console 8281 -noExit

This will make Equinox to launch the OSGi console in port 8281 which we can access using Telnet on port 8281. Try this.

telnet localhost 8281

osgi console telnet

Read more on starting Equinox faceless: http://www.eclipsezone.com/eclipse/forums/t93976.rhtml


References

http://www.eclipse.org/equinox/documents/quickstart.php
http://www.eclipsezone.com/

Advertisements