How to create OSGi bundles using Felix iPOJO
From MediaWiki
Richard Gomes founded JQuantLib in Sep/07. He is Brazilian and settled in London since Aug/06. Richard is available for immediate assignment as consultant specialized on Java technologies and open source tools. |
This is a work in progress. Use at your own risk. You were warned! :(
Overview
We currently evaluating how OSGi must be used in order to make JQuantLib a library which applies the best practices on high availability on top of an OSGi container. This article explores how Apache Felix iPOJOs can be used in order to implement OSGi in a simple, lightweight and efficient way.
Foreword
Below you have a link to a tutorial which uses Felix iPOJO for building OSGi bundles
Install Felix and additional ops4J pax-url bundles
- Download an uncompress the entire Apache Felix 1.2.1 distribution into a folder of your convenience;
- Download an uncompress the entire OPS4J PAX-URL 0.3.2 distribution into a folder of your convenience;
Building test projects
- Download my test projects into your Eclipse workspace folder and uncompress it;
- Build them
cd workspace cd contrib.osgi.filetransfer_api mvn clean install cd .. cd contrib.osgi.filetransfer_impl mvn clean install cd .. cd contrib.osgi.filetransfer_client mvn clean install cd ..
Running Felix
cd ${FELIX_HOME}
java -server -jar bin/felix.jar
-> ps
START LEVEL 1
ID State Level Name
[ 0] [Active ] [ 0] System Bundle (1.2.1)
[ 1] [Active ] [ 1] Apache Felix Shell Service (1.0.2)
[ 2] [Active ] [ 1] Apache Felix Shell TUI (1.0.2)
[ 3] [Active ] [ 1] Apache Felix Bundle Repository (1.2.0)
-> start file:bundle/org.osgi.compendium-1.2.0.jar
-> start file:bundle/org.apache.felix.ipojo-1.0.0.jar
-> ps
START LEVEL 1
ID State Level Name
[ 0] [Active ] [ 0] System Bundle (1.2.1)
[ 1] [Active ] [ 1] Apache Felix Shell Service (1.0.2)
[ 2] [Active ] [ 1] Apache Felix Shell TUI (1.0.2)
[ 3] [Active ] [ 1] Apache Felix Bundle Repository (1.2.0)
[ 4] [Active ] [ 1] OSGi R4 Compendium Bundle (4.1.0)
[ 5] [Active ] [ 1] iPOJO (1.0.0)
-> start file:../ops4j-pax-url-0.3.2/pax-url-mvn-0.3.2.jar
-> ps
START LEVEL 1
ID State Level Name
[ 0] [Active ] [ 0] System Bundle (1.2.1)
[ 1] [Active ] [ 1] Apache Felix Shell Service (1.0.2)
[ 2] [Active ] [ 1] Apache Felix Shell TUI (1.0.2)
[ 3] [Active ] [ 1] Apache Felix Bundle Repository (1.2.0)
[ 4] [Active ] [ 1] OSGi R4 Compendium Bundle (4.1.0)
[ 5] [Active ] [ 1] iPOJO (1.0.0)
[ 6] [Active ] [ 1] OPS4J Pax Url - mvn: (0.3.2)
-> start mvn:org.ops4j.pax.logging/pax-logging-api/1.1.0
-> start mvn:org.ops4j.pax.logging/pax-logging-service/1.1.0
-> ps
START LEVEL 1
ID State Level Name
[ 0] [Active ] [ 0] System Bundle (1.2.1)
[ 1] [Active ] [ 1] Apache Felix Shell Service (1.0.2)
[ 2] [Active ] [ 1] Apache Felix Shell TUI (1.0.2)
[ 3] [Active ] [ 1] Apache Felix Bundle Repository (1.2.0)
[ 4] [Active ] [ 1] OSGi R4 Compendium Bundle (4.1.0)
[ 5] [Active ] [ 1] iPOJO (1.0.0)
[ 6] [Active ] [ 1] OPS4J Pax Url - mvn: (0.3.2)
[ 7] [Active ] [ 1] OPS4J - Pax Logging API (1.1.0)
[ 8] [Active ] [ 1] OPS4J - Pax Logging Service (1.1.0)
-> start file:/home/rgomes/workspace/contrib.osgi.filetransfer_api/target/contrib.osgi.filetransfer_api-0.0.1.jar
-> start file:/home/rgomes/workspace/contrib.osgi.filetransfer_impl/target/contrib.osgi.filetransfer_impl-0.0.1.jar
-> start file:/home/rgomes/workspace/contrib.osgi.filetransfer_client/target/contrib.osgi.filetransfer_client-0.0.1.jar
If everything is OK, you will see the URL http://www.jquantlib.org/ being printed on screen every 10secs and some log messages.
See also
- How to create OSGi bundles using Felix iPOJO
- How to create a Spring-DM bundle project using Maven (and Eclipse...)
- How to create a Spring-DM bundle using PAX scripts
RichardGomes 01:40, 31 October 2008 (UTC)


