How to Deploy a Custom System Bundle
A good developer will create their own framework to be extended by interface OSGI bundles for easy development and for code reusability. Customization is key!
Join the DZone community and get the full member experience.Join For Free
The intention of this blog is to give an idea to those (like me) who suffered from having no or little guidance when engineering an ESB. Before you decide how to start engineering your own ESB, decide on the right ESB tool. This blog makes use of Apache ServiceMix 7.0.0.M1 as an ESB tool, Apache maven 3.3.1 and Apache camel for development.
Apache Maven installation.
JDK 1.7 or above.
Custom OSGI bundle to be deployed as system bundle.
Third-party installation to a local Maven repo.
Apache ServiceMix 7.0.0.M1 or above.
Deploying Custom OSGI Bundle as System Bundle
Why use system bundle deployment? A good developer will create his or her own framework which offers features like constructors, security, error handling, database connectivity, third-party service connectivity, multithreading ability, clustering, high availability, extensibility, etc., to be extended by interface OSGI bundles for easy development and for code reusability. Apache ServiceMix activates bundles and context when deployed one in a deploy folder, but will do another if it's a system feature. The difference is that former deployments will be repetitive for each restart of ServiceMix/Karaf; the later method is just one-time.
The framework bundle shouldn't be restarted each and every time the ServiceMix starts. Otherwise, it isn't customized. A framework should be installed as a feature in ServiceMix only once and should be customized by interface bundles. Hence, a custom OSGI framework bundle should be deployed as system bundle.
Now, how do we deploy it as system bundle? Here are the steps.
Download Apache ServiceMix.
Extract the downloaded ZIP into a working directory.
Set the below variables in System’s Environment Variables:
$KARAF_HOME/etc/org.ops4j.pax.url.mvn.cfgto change the location of Maven’s
settings.xmlas ServiceMix refers to Maven’s default local repository path
Change the value of the config parameter
Create the below Karaf system folder:
Paste the Maven-built framework.
Include this entry in
mvn\:com.test.base/my-framework/0.0.1-SNAPSHOT = 16.
If any dependency of system bundle deployed throws an error, install those features. Examples:
group id: com.test.base artifact id: my-framework version: 0.0.1-SNAPSHOT
Folder structure to be created:
That's it! Now, your preconfigured ESB is ready. You can create your interface that extends the OSGI system bundle and deploy it in ServiceMix for servicing requests.
Opinions expressed by DZone contributors are their own.