OSGi Community Event 2016 Presentation by Matteo Rulli (FlairBit)
OSGi learning curve is steep but its benefits widely surpass difficulties: OSGi gives you sensible dependencies management, pluggable extensions mechanisms, strong modularity, out-of-the-box semantic versioning support and strong contract-based software development.
In this talk I’ll describe how to build an effective OSGi toolchain from the ground up: integrate maven and bndtools, set-up a test-driven development workflow on top of OSGi, use maven repositories as a baseline for semantic versioning and leverage bnd remote launcher to effectively debug bundles on remote target runtimes.
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
OSGi toolchain from the ground up - Matteo Rulli
1. OSGi toolchain from the ground up
Matteo Rulli - FlairBit
Do not duplicate or distribute without written permission from FlairBit S.r.l.
FlairBit S.r.l. - Viale Brigate Bisagno 12/1 - 16129 Genova (GE) - ITALY
2. This Presentation
• OSGi and IoT
• Pure maven approach
• Bndtools
• Integrate complex runtimes in bndtools: CXF example
• Remote debugging on external runtimes: Karaf
4. OSGi and IoT
• Isolated and loosely coupled services are more easily
distributable across different execution contexts
• A reasonable balance between hundreds-of-
processes-μServices and old-fashioned monoliths
• Services consistent versioning
• Productivity and sensible code re-use
5. Pure maven approach
• Let’s illustrate a trivial Cassandra Key-Value store
implementation with bnd, maven and equinox…
https://github.com/mrulli/com.flairbit.eclipsecon.onesix.git
6. Pure maven approach: projects
• The key-value implemetation: API and provider
• The GOGO command
• Integration test
• bndrun setting to resolve and launch
7. Bndtools
Bndtools brings all bnd features inside the Eclipse IDE
• Bundles Resolution
• TDD with JUnit
• Maven and OBR repo integration
• SemVer support
8. Apache Karaf
Curated OSGi runtime with
• Bundles and applications deployment
• Bundles Provisioning
• Powerfull remote ssh and web OSGi console
• Out-of-the-box OSGi support for many technologies
(CXF, Camel, …)
• Tons of other very useful features
10. CXF Karaf Features
• Up to 110 bundles get installed automatically
… manage them with a pom? Boring…
But I want to debug my integration test in my IDE!
11. Karaf Features in bnd(tools)
Karaf Feature Service is just an OSGi bundle with few dependencies:
karaf@root>bundle:tree-show 26
Bundle org.apache.karaf.deployer.features [26] is currently ACTIVE
org.apache.karaf.deployer.features [26]
+- org.apache.felix.fileinstall [4]
| +- org.apache.felix.configadmin [3]
| | +- org.ops4j.pax.logging.pax-logging-api [1]
| | +- org.apache.karaf.services.eventadmin [6]
| | +- org.apache.felix.metatype [5]
| +- org.ops4j.pax.logging.pax-logging-api [1]
+- org.ops4j.pax.logging.pax-logging-api [1]
+- org.apache.karaf.features.core [8]
+- org.apache.karaf.services.eventadmin [6]
+- org.apache.felix.configadmin [3]
+- org.ops4j.pax.url.mvn [7]
| +- org.apache.felix.configadmin [3]
| +- org.ops4j.pax.logging.pax-logging-api [1]
+- org.ops4j.pax.logging.pax-logging-api [1]
12. Karaf Features in bnd(tools)
• So you can install Feature Service in any OSGi distro,
not only within Karaf…
…let’s see this in action.
13. Debug Karaf w/ bnd remote agents
Requirements in Karaf for remote debugging w/ bnd:
• mvn:biz.aQute.bnd/biz.aQute.remote.agent/3.3.0
• scr feature (just because we use DS in the demo)
https://github.com/mrulli/com.flairbit.examples.karaf-debug
http://enroute.osgi.org/appnotes/bndtools-and-karaf.html
14. Conclusions
• Toolkits revolving around OSGi are more and more
refined
• Robustness of bnd and its derivative works is
enterprise-grade
• Thanks to OSGi modularity, interoperability among
OSGi distros can be quite satisfactory
• Thanks to OSGi enRoute initiative, OSGi is now
extensively documented