Starting with OSGi? Try Pax Runner!

Check also the second article on Pax-Runner: Provisioning Files

Despite what you can read in forums or mailing lists, starting with OSGi is just a matter of minutes if you use the right tool. And the name of the right tool is Pax Runner.

Pax Runner Logo

Pax Runner claims to be

a tool to provision OSGi bundles in all major open source OSGi framework implementations (Felix, Equinox, Knopflerfish, Concierge).

but is actually much more. With Pax Runner you can start any OSGi container, in different versions and configurations, and with different sets of preloaded bundles. It’s particularly useful to try your bundles with all the OSGi implementations.

Let’s see now how an absolute beginner can use Pax Runner to start playing with OSGi.

First of all, you need to download the latest version of Pax Runner from the download page; in our case, we will download Pax Runner 1.1.1 for java 1.5 and beyond (zip).

Unzip the downloaded file and add to your system PATH the “bin” folder (in our case, pax-runner-1.1.1/bin/)

Now type: pax-run.sh (on Unix, or the correspondent .bat file on Windows) and see Pax Runner in action:

$ pax-run.sh
    ______  ________  __  __
   / __  / /  __   / / / / /
  /  ___/ /  __   / _\ \ _/
 /  /    /  / /  / / _\ \
/__/    /__/ /__/ /_/ /_/

Pax Runner (1.1.1) from OPS4J - http://www.ops4j.org
----------------------------------------------------

 -> Using config [classpath:META-INF/runner.properties]
 -> Using only arguments from command line
 -> Preparing framework [Felix 1.8.1]
 -> Downloading bundles...
 -> Felix 1.8.1 : 368237 bytes @ [ 141kBps ]
 -> org.osgi.compendium (4.1.0) : 514214 bytes @ [ 172kBps ]
 -> org.apache.felix.shell (1.2.0) : 59114 bytes @ [ 1642kBps ]
 -> org.apache.felix.shell.tui.plugin (1.2.0) : 12455 bytes @ [ 30kBps ]
 -> Using execution environment [J2SE-1.6]
 -> Runner has successfully finished his job!

Welcome to Felix.
=================
 -> 

As you can see, Pax Runner has downloaded Apache Felix and some basic bundles; what you see is the Apache Felix Console: just type help to start playing with it.

Do you want to see how Equinox looks like? Starting Equinox and playing with its console is as simple as typing pax-run.sh –platform=equinox

pax-run.sh --platform=equinox
    ______  ________  __  __
   / __  / /  __   / / / / /
  /  ___/ /  __   / _\ \ _/
 /  /    /  / /  / / _\ \
/__/    /__/ /__/ /_/ /_/

Pax Runner (1.1.1) from OPS4J - http://www.ops4j.org
----------------------------------------------------

 -> Using config [classpath:META-INF/runner.properties]
 -> Using only arguments from command line
 -> Preparing framework [Equinox 3.5.0]
 -> Downloading bundles...
 -> Equinox 3.5.0 : 1122602 bytes @ [ 215kBps ]
 -> Eclipse utilities : 22471 bytes @ [ 387kBps ]
 -> Eclipse compendium services : 66065 bytes @ [ 359kBps ]
 -> Using execution environment [J2SE-1.6]
 -> Runner has successfully finished his job!

osgi>

</pre>

Finally, Pax Runner defines the concept of <i>Profiles</i>; a profile is a pre-defined set of bundles. Every user can define its own profiles, but the tool comes with a initial set of profiles.
Let's say you can to start Knopflerfish with all the bundles implementing the OSGi Log Service; with Pax Runner you just need to type: <b>pax-run.sh --platform=knopflerfish --profiles=log</b>

[bash]
pax-run.sh --platform=knopflerfish --profiles=log
    ______  ________  __  __
   / __  / /  __   / / / / /
  /  ___/ /  __   / _\ \ _/
 /  /    /  / /  / / _\ \
/__/    /__/ /__/ /_/ /_/

Pax Runner (1.1.1) from OPS4J - http://www.ops4j.org
----------------------------------------------------

 -> Using config [classpath:META-INF/runner.properties]
 -> Using only arguments from command line
 -> Scan bundles from [scan-composite:mvn:org.ops4j.pax.runner.profiles/log//composite]
 -> Scan bundles from [scan-bundle:mvn:org.ops4j.pax.logging/pax-logging-api/1.3.0]
 -> Scan bundles from [scan-bundle:mvn:org.ops4j.pax.logging/pax-logging-service/1.3.0]
 -> Provision bundle [mvn:org.ops4j.pax.logging/pax-logging-api/1.3.0, at default start level, bundle will be started, bundle will be loaded from the cache]
 -> Provision bundle [mvn:org.ops4j.pax.logging/pax-logging-service/1.3.0, at default start level, bundle will be started, bundle will be loaded from the cache]
 -> Preparing framework [Knopflerfish 2.3.1]
 -> Downloading bundles...
 -> Knopflerfish 2.3.1 : 366660 bytes @ [ 161kBps ]
 -> org.osgi.compendium : 689150 bytes @ [ 195kBps ]
 -> Knopflerfish Console : 36329 bytes @ [ 257kBps ]
 -> Knopflerfish Console TTY : 6153 bytes @ [ 256kBps ]
 -> Knopflerfish Framework Commands : 26090 bytes @ [ 208kBps ]
 -> mvn:org.ops4j.pax.logging/pax-logging-api/1.3.0 : 86184 bytes @ [ 225kBps ]
 -> mvn:org.ops4j.pax.logging/pax-logging-service/1.3.0 : 426219 bytes @ [ 183kBps ]
 -> Using execution environment [J2SE-1.6]
 -> Runner has successfully finished his job!

Knopflerfish OSGi framework, version 4.1.3
Copyright 2003-2009 Knopflerfish. All Rights Reserved.

See http://www.knopflerfish.org for more information.
Loading xargs url file:knopflerfish/config.ini
Installed and started: file:bundles/osgi.compendium_4.0.1.jar (id#1)
Installed and started: file:bundles/org.knopflerfish.bundle.console_2.0.1.jar (id#2)
Installed and started: file:bundles/org.knopflerfish.bundle.consoletty-IMPL_2.0.0.jar (id#3)
Installed and started: file:bundles/org.knopflerfish.bundle.frameworkcommands-IMPL_2.0.5.jar (id#4)
Installed and started: file:bundles/org.ops4j.pax.logging.pax-logging-api_1.3.0.jar (id#5)
Installed and started: file:bundles/org.ops4j.pax.logging.pax-logging-service_1.3.0.jar (id#6)
> org.ops4j.pax.logging.pax-logging-api[org.ops4j.pax.logging.internal.Activator] : Enabling SLF4J API support.
org.ops4j.pax.logging.pax-logging-api[org.ops4j.pax.logging.internal.Activator] : Enabling Jakarta Commons Logging API support.
org.ops4j.pax.logging.pax-logging-api[org.ops4j.pax.logging.internal.Activator] : Enabling Log4J API support.
org.ops4j.pax.logging.pax-logging-api[org.ops4j.pax.logging.internal.Activator] : Enabling Avalon Logger API support.
org.ops4j.pax.logging.pax-logging-api[org.ops4j.pax.logging.internal.Activator] : Enabling JULI Logger API support.
[startlevel job thread] DEBUG org.ops4j.pax.logging.pax-logging-service - BundleEvent STARTED
[main] DEBUG system.bundle - FrameworkEvent STARTED
Framework launched

 ->  ps
   id  level/state name
   --------------------
    0  0/active    System Bundle
    1  1/active    osgi.compendium
    2  1/active    Console
    3  1/active    TTY-Console-IMPL
    4  1/active    FW-Commands-IMPL
    5  5/active    OPS4J Pax Logging - API
    6  5/active    OPS4J Pax Logging - Service

As you can see, Knopflerfish is up and running, and the Pax Logging bundles are installed.

Pax Runner offers much more than these basic functionalities; check the documentation for more details.

osgi, pax, tutorial

If you enjoyed this post, please consider to leave a comment or subscribe to the feed and get future articles delivered to your feed reader.

Comments

8 Responses to “Starting with OSGi? Try Pax Runner!”

Leave Comment

(required)

(required)