Modular Applications with 
OSGi on Apache Karaf 
Ioan Eugen Stan 
@ieugen222 
stan.ieugen@gmail.com
About me 
● IT Consultant (Java, Architecture) 
● Open Source Hacker 
● Web: http://ieugen.ro/ 
● http://github.com/ieugen 
● @ieugen222
Agenda 
● Problem statement 
● Short intro to OSGi 
● Apache Karaf and OSGi universe 
● Building an App 
https://github.com/ieugen/java2days-20 
14-osgi-karaf
Modularity is a big issue 
● Deals with software complexity over 
time 
● Jigsaw - Java started from JDK-7 (start 
2009) 
● Has many aspects: deployment, 
management, runtime
Why modularity? 
● Reduce complexity 
● Allow parallel development 
● Improve component re-usability 
● Upgrade proof systems
When Applications can Roam Freely, P. Kriens - http://slideplayer.us/slide/732791/
A solution for Java modularity? 
Jigsaw was delayed again (does not 
address dynamism) 
Try OSGi – the de facto standard for 
Java modularity
OSGi – overview 
● Modular system for Java/JVM 
● Service platform 
● Dynamic component model
http://www.slideshare.net/mfrancis/osgi-technology-value-proposition-december-2013
OSGi Benefits 
● Reduced Complexity 
● Promotes Reuse 
● Real World – things appear/disappear 
● Dynamic updates
OSGi Service Gateway Architecture 
Application / Bundles 
Services 
Service registry 
Life cycle 
Modules 
Java Virtual Machine 
Operating System 
Hardware 
Security 
http://en.wikipedia.org/wiki/OSGi
OSGi Architecture (2) 
Bundle 1 Bundle 2 Bundle n 
System Services 
e.g. Java ME CDC, SE, EE 
e.g. Windows, Linux VxWorks, QNX 
http://en.wikipedia.org/wiki/OSGi 
C/C++ 
OSGi Framework 
Java Runtime Environment 
Operating System 
Hardware 
Drivers 
Server Platform 
JNI
Apache Karaf 
Apache Karaf is a small OSGi based 
runtime which provides a lightweight 
container onto which various 
components and applications can be 
deployed. 
http://karaf.apache.org/
Karaf Architecture
Features 
● Hot deployment of bundles 
● Dynamic configuration 
● Provisioning of applications 
● Native OS integration 
● Remote Access (SSH, Web) 
● ...
Projects 
● OPS4j - https://github.com/ops4j 
● OSGi JAX-RS Connector 
https://github.com/hstaudacher/osgi-j 
ax-rs-connector
Demo time
Thank you. 
Time for questions.

Modular Java applications with OSGi on Apache Karaf

  • 1.
    Modular Applications with OSGi on Apache Karaf Ioan Eugen Stan @ieugen222 stan.ieugen@gmail.com
  • 2.
    About me ●IT Consultant (Java, Architecture) ● Open Source Hacker ● Web: http://ieugen.ro/ ● http://github.com/ieugen ● @ieugen222
  • 3.
    Agenda ● Problemstatement ● Short intro to OSGi ● Apache Karaf and OSGi universe ● Building an App https://github.com/ieugen/java2days-20 14-osgi-karaf
  • 4.
    Modularity is abig issue ● Deals with software complexity over time ● Jigsaw - Java started from JDK-7 (start 2009) ● Has many aspects: deployment, management, runtime
  • 5.
    Why modularity? ●Reduce complexity ● Allow parallel development ● Improve component re-usability ● Upgrade proof systems
  • 6.
    When Applications canRoam Freely, P. Kriens - http://slideplayer.us/slide/732791/
  • 7.
    A solution forJava modularity? Jigsaw was delayed again (does not address dynamism) Try OSGi – the de facto standard for Java modularity
  • 8.
    OSGi – overview ● Modular system for Java/JVM ● Service platform ● Dynamic component model
  • 9.
  • 10.
    OSGi Benefits ●Reduced Complexity ● Promotes Reuse ● Real World – things appear/disappear ● Dynamic updates
  • 11.
    OSGi Service GatewayArchitecture Application / Bundles Services Service registry Life cycle Modules Java Virtual Machine Operating System Hardware Security http://en.wikipedia.org/wiki/OSGi
  • 12.
    OSGi Architecture (2) Bundle 1 Bundle 2 Bundle n System Services e.g. Java ME CDC, SE, EE e.g. Windows, Linux VxWorks, QNX http://en.wikipedia.org/wiki/OSGi C/C++ OSGi Framework Java Runtime Environment Operating System Hardware Drivers Server Platform JNI
  • 13.
    Apache Karaf ApacheKaraf is a small OSGi based runtime which provides a lightweight container onto which various components and applications can be deployed. http://karaf.apache.org/
  • 14.
  • 15.
    Features ● Hotdeployment of bundles ● Dynamic configuration ● Provisioning of applications ● Native OS integration ● Remote Access (SSH, Web) ● ...
  • 16.
    Projects ● OPS4j- https://github.com/ops4j ● OSGi JAX-RS Connector https://github.com/hstaudacher/osgi-j ax-rs-connector
  • 17.
  • 18.
    Thank you. Timefor questions.