Getting started with OSGi on Apache Felix


To work with OSGi modules (or bundles), you’ll have to use, I let you guess …, an OSGi container. There a few open source containers including Apache Felix and Eclipse Equinox. The first one is used in application such as Glassfish v3, Service Mix 4, … and the second one in … Eclipse IDE of course.

Let’s start with downloading Apache Felix here and choose Felix Framework Distribution 3.0.3.

Unzip it and run the container (felix-framework-3.0.3/bin/felix.jar) with :

java -jar bin/felix.jar

You’ll have a g! prompt (fore felix console “gogo”) where you can enter the help command :

____________________________
Welcome to Apache Felix Gogo

g! help
felix:bundlelevel
felix:cd
felix:frameworklevel
felix:headers
felix:help
felix:inspect
felix:install
felix:lb
felix:log
felix:ls
felix:refresh
felix:resolve
felix:start
felix:stop
felix:uninstall
felix:update
felix:which
gogo:cat
gogo:each
gogo:echo
gogo:format
gogo:getopt
gogo:gosh
gogo:grep
gogo:not
gogo:set
gogo:sh
gogo:source
gogo:tac
gogo:telnetd
gogo:type
gogo:until
obr:deploy
obr:info
obr:javadoc
obr:list
obr:repos
obr:source
g!

List installed bundle

g! felix:lb
START LEVEL 1
 ID|State      |Level|Name
 0|Active     |    0|System Bundle (3.0.3)
 1|Active     |    1|Apache Felix Bundle Repository (1.6.2)
 2|Active     |    1|Apache Felix Gogo Command (0.6.1)
 3|Active     |    1|Apache Felix Gogo Runtime (0.6.1)
 4|Active     |    1|Apache Felix Gogo Shell (0.6.1)

Install bundles

g! felix:install file:bundle/helloworld.jar
Bundle ID: 18

Start installed bundles

g! felix:start 18
Hello World!

Stop Apache Felix

felix:stop 0

Don’t be surprised next time you launch Apache Felix, installed bundles will automatically be reloaded thanks to felix-cache.

To continue …

Advertisements

2 thoughts on “Getting started with OSGi on Apache Felix

  1. I’ve been browsing on-line more than 3 hours these days, but I never discovered any fascinating article like yours. It’s lovely price enough for me.
    In my opinion, if all webmasters and bloggers made
    just right content material as you probably did, the web might be
    a lot more helpful than ever before.

  2. This is very helpful. Why does the step by step procedure in the apache website have different commands? Thanks for you help by the way. U saved my time

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s