Sunday, February 2, 2014

Understand OSGI Bundle Build And Deployment

OSGi stands for Open Service Gateway initiative. For daily development of OSGI bundles, we need to understand how it build and deployed. I have a simple camel osgi project which comes with camel 2.10.4 in examples/apache/camel/camel-example-osgi. In this short blogger, I want to explain what happened when you build and deploy the osgi bundle.

Here are the simple procedures I build and deploy the bundle:

    cd ${apache-camle-home}/examples/apache/camel/camel-example-osgi
    mvn clean install


Where the build Requests?

You should see the following lines at the end of the build.

[INFO] --- maven-bundle-plugin:2.3.7:install (default-install) @ camel-example-osgi ---
[INFO] Installing org/apache/camel/camel-example-osgi/2.10.4/camel-example-osgi-2.10.4.jar
[INFO] Writing OBR metadata
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 1:11.876s
[INFO] Finished at: Sun Feb 02 16:04:17 CST 2014
[INFO] Final Memory: 26M/435M
[INFO] ------------------------------------------------------------------------


This means the build is successful. But what has maven done? if you cd to you maven repository, which normally is located at $HOME/.m2/reposity. In my case, it is under:
    C:\Users\gliu\.m2\repository\org\apache\camel\camel-example-osgi\2.10.4
You can see that:
     org.apache.camel    --> groupID
     camel-example-osgi  --> artifact ID
     2.10.4              --> version number
Under that directory you should see the following files:
   camel-example-osgi-2.10.4.pom
   camel-example-osgi-2.10.4-features.xml
   camel-example-osgi-2.10.4.jar
   _remote.repositories

How to deploy the artifact to OSGi container

The deployment is straight forward. In the karaf container command line, you can type the following:
      osgi:install mvn:org.apache.camel/camel-example-osgi/2.10.4
      start 438
Where 438 is bundle id. Here is a windows snapshot:

1 comment:

Anypoint Studio Error: The project is missing Munit lIbrary to run tests

Anypoint Studio 7.9 has a bug. Even if we following the article: https://help.mulesoft.com/s/article/The-project-is-missing-MUnit-libraries-...