Sunday, August 23, 2009

Building OSGi bundles using Maven Bundle Plugin

I came across a good article by Sameera on "How to build OSGi bundles using Maven Bundle Plugin". It gives detailed infromation on how to use maven bundle plugin to generate OSGi bundles. In this blogpost, I will demonstrate how a sample can be run. If you are hungry for more information read the above article.

1) Download and extract the samples.

2) Build the sample01
mvn clean install
3) Download Equinox.
eg: org.eclipse.osgi_3.5.0.v20090520.jar

4) Run the jar file using following command.
java -jar org.eclipse.osgi_3.5.0.v20090520.jar -console
5) In the command prompt execute following command.
osgi> ss
Framework is launched.

id State Bundle
0 ACTIVE org.eclipse.osgi_3.5.0.v20090520
6) Install the bundle
osgi>  install file:/home/heshan/Documents/Work/OSGi/maven_bundle_plugin_samples_0/sample01/target/sample01-1.0.0.jar
Bundle id is 1

osgi> ss
Framework is launched.

id State Bundle
0 ACTIVE org.eclipse.osgi_3.5.0.v20090520
1 ACTIVE org.wso2.mbp.sample01_1.0.0
7) Use the following commands to start and stop the bundles.
osgi> start 1
Hello World!!!

osgi> stop 1
Goodbye World!!!

No comments: