SlideShare a Scribd company logo
Serge
Huber,
Jahia
CTO
shuber@jahia.com

OSGi in 5 minutes
Why ?
• Most
mature
Java
“plug‐in”
technology
• Allows
hot
deployment/un‐deployment
• Manages
dependencies
between
plug‐ins
(aka

  OSGi
bundles)
• Offers
(opKonal)
addiKonal
services
(HTTP,

  configuraKon,
etc...)
What is an OSGi Bundle ?
                                                   JAR

• Basically
a
JAR
with:
                              MANIFEST.MF
  –AddiKonal
stuff
in
it’s
   Bundle-Name: Hello World


   manifest
file
                             Bundle-SymbolicName: org.example.helloworld
                             Bundle-Description: A Hello World bundle
                             Bundle-ManifestVersion: 2
                             Bundle-Version: 1.0.0

  –A
class
called
an
        Bundle-Activator: org.example.Activator
                             Export-Package:
                             org.example.helloworld;version="1.0.0"

   acKvator
to
register
     Import-Package: org.osgi.framework;version="1.3.0"



   services                  Classes
  –Your
code
and
resources   org.example.AcKvator
                             ...
  –(OpKonally)Other
JARs

   for
legacy
(migraKon)
    (OpKonal)
JARs
                             legacy‐1.0.jar
   purposes                  ...
OSGi Services
              Services
are
all
implemented
using
one
or
more
OSGi
bundles


Logging                      Component
RunKme              Wire
Admin


ConfiguraKon
Admin            Deployment
Admin              XML
Parser


Device
Access                Event
Admin                   Measurement
and
State


User
Admin                   ApplicaKon
Admin              My
Service
1


IO
Connector                 HTTP
Service                  My
Service
2


Preferences                  UPnP
Device
Service
Bundle Activator
• Simply
iniKalizes

  and
shuts
down
the
   package org.example;



  bundle
(if
needed)
                        import org.osgi.framework.BundleActivator;
                        import org.osgi.framework.BundleContext;

                        public class Activator implements BundleActivator {


• Can
register
with

                                private BundleContext context;

                                public void start(BundleContext context) throws Exception {
                                        System.out.println("Starting: Hello World");

  exisKng
services              }
                                        this.context = context;


                                public void stop(BundleContext context) throws Exception {

• Helper
classes
are
           }
                                        System.out.println("Stopping: Goodbye Cruel World");
                                        this.context = null;



  available
to
make

                        }




  things
easier
OSGi and Maven
• Very
good
match
as
both
know
about

  dependencies
• Maven
project
==
OSGi
bundle
• Maven
Felix
Plugin
does
the
packaging
for
you
!
             <plugin>
               <groupId>org.apache.felix</groupId>
               <artifactId>maven-bundle-plugin</artifactId>
               <extensions>true</extensions>
               <configuration>
                 <instructions>
                   <Export-Package>org.osgi.service.log</Export-Package>
                   <Private-Package>org.apache.felix.log.impl</Private-Package>
                   <Bundle-SymbolicName>${pom.artifactId}</Bundle-SymbolicName>
                   <Bundle-Activator>${pom.artifactId}.impl.Activator</Bundle-Activator>
                   <Export-
       Service>org.osgi.service.log.LogService,org.osgi.service.log.LogReaderService</
       Export-Service>
                 </instructions>
               </configuration>
             </plugin>
Learn more...
• OSGi
implementaKons
 –Eclipse
Equinox
:
hfp://eclipse.org/equinox/
(most

  mature,
was
born
out
of
Eclipse,
integrated
in

  Websphere
and
Eclipse)
 –Apache
Felix
:
hfp://felix.apache.org
(best
integraKon

  with
Maven,
evolving
rapidly,
used
in
Apache
Sling
and

  other
Apache
projects


More Related Content

PDF
OSGi Presentation
PDF
OSGi Blueprint Services
PDF
Intro To OSGi
PPT
The Web on OSGi: Here's How
PDF
Open Services Gateway Initiative (OSGI)
PDF
Benefits of OSGi in Practise
PPTX
Intro to OSGi
PDF
OSGi and Java EE: A Hybrid Approach to Enterprise Java Application Development
OSGi Presentation
OSGi Blueprint Services
Intro To OSGi
The Web on OSGi: Here's How
Open Services Gateway Initiative (OSGI)
Benefits of OSGi in Practise
Intro to OSGi
OSGi and Java EE: A Hybrid Approach to Enterprise Java Application Development

What's hot (20)

PDF
Modular Java applications with OSGi on Apache Karaf
PPT
Apache Aries: A blueprint for developing with OSGi and JEE
PDF
Karaf ee-apachecon eu-2012
PDF
Maximize the power of OSGi
PDF
OSGi & Java EE in GlassFish
PDF
OSGi & Java EE in GlassFish - Best of both worlds
PDF
OSGi-enabled Java EE applications in GlassFish
PDF
Use Case: Building OSGi Enterprise Applications (QCon 14)
PPTX
Step by step guide to create theme for liferay dxp 7
PDF
GlassFish v3, OSGi Equinox Felix
PPT
Managing Change
PDF
Scala and Play with Gradle
PDF
GlassFish v3 Prelude Aquarium Paris
PDF
Embrace Change - Embrace OSGi
PDF
OSGi Cloud Ecosystems (EclipseCon 2013)
PDF
Make JSF more type-safe with CDI and MyFaces CODI
PDF
Apache DeltaSpike
PDF
Java 9 Modularity in Action
PDF
OpenWebBeans and DeltaSpike at ApacheCon
PDF
Apache DeltaSpike the CDI toolbox
Modular Java applications with OSGi on Apache Karaf
Apache Aries: A blueprint for developing with OSGi and JEE
Karaf ee-apachecon eu-2012
Maximize the power of OSGi
OSGi & Java EE in GlassFish
OSGi & Java EE in GlassFish - Best of both worlds
OSGi-enabled Java EE applications in GlassFish
Use Case: Building OSGi Enterprise Applications (QCon 14)
Step by step guide to create theme for liferay dxp 7
GlassFish v3, OSGi Equinox Felix
Managing Change
Scala and Play with Gradle
GlassFish v3 Prelude Aquarium Paris
Embrace Change - Embrace OSGi
OSGi Cloud Ecosystems (EclipseCon 2013)
Make JSF more type-safe with CDI and MyFaces CODI
Apache DeltaSpike
Java 9 Modularity in Action
OpenWebBeans and DeltaSpike at ApacheCon
Apache DeltaSpike the CDI toolbox
Ad

Viewers also liked (8)

PDF
Introducing the Jahia Log Analyzer
PDF
Java modularity: life after Java 9
PDF
Jahia DX 7.2 : Bye bye felix, hello karaf
PPTX
GraphQL Introduction
PDF
Java 9 and Project Jigsaw
PDF
The Zero Bullshit Architecture
PDF
Provisioning the IoT
PPTX
Design Beautiful REST + JSON APIs
Introducing the Jahia Log Analyzer
Java modularity: life after Java 9
Jahia DX 7.2 : Bye bye felix, hello karaf
GraphQL Introduction
Java 9 and Project Jigsaw
The Zero Bullshit Architecture
Provisioning the IoT
Design Beautiful REST + JSON APIs
Ad

Similar to OSGi in 5 minutes (20)

PPTX
Intro to OSGi and Eclipse Virgo
PPT
OSGi & Blueprint
PDF
Easy-peasy OSGi Development with Bndtools - Neil Bartlett
PDF
Weld-OSGi, injecting easiness in OSGi
PDF
Create *real* modular Java applications - a brief introduction -
PDF
OSGi-enabled Java EE Applications using GlassFish
PDF
Tuscany : Applying OSGi After The Fact
ODP
Java Tech & Tools | OSGi Best Practices | Emily Jiang
PDF
VIB - Very Important Bundles
PDF
OSGi user forum dc metro v1
PDF
OSGi User Forum US DC Metro
PDF
Enterprise OSGi at eBay
PDF
OSGi introduction
PPTX
Introduction to OSGGi
PDF
OSGi In Anger - Tara Simpson
PDF
Osgi Sun 20080820
PPTX
Introduction to-osgi
PDF
OSGI in Java EE servers:Sneak peak
PDF
OSGi Mars World in Action
PDF
Eclipse_Building_Blocks
Intro to OSGi and Eclipse Virgo
OSGi & Blueprint
Easy-peasy OSGi Development with Bndtools - Neil Bartlett
Weld-OSGi, injecting easiness in OSGi
Create *real* modular Java applications - a brief introduction -
OSGi-enabled Java EE Applications using GlassFish
Tuscany : Applying OSGi After The Fact
Java Tech & Tools | OSGi Best Practices | Emily Jiang
VIB - Very Important Bundles
OSGi user forum dc metro v1
OSGi User Forum US DC Metro
Enterprise OSGi at eBay
OSGi introduction
Introduction to OSGGi
OSGi In Anger - Tara Simpson
Osgi Sun 20080820
Introduction to-osgi
OSGI in Java EE servers:Sneak peak
OSGi Mars World in Action
Eclipse_Building_Blocks

More from Serge Huber (9)

PPTX
ApacheCon NA 2019 : Adding AI to customer segmentation using Apache Unomi and...
PPTX
ApacheCon NA 2019 : Customer segmentation and personalization using apache unomi
PPTX
ApacheCon NA 2018 : Apache Unomi, an Open Source Customer Data Platformapache...
PDF
DEVOXX FR 2016 We're Watching You (Apache Unomi)
PDF
UXDev Summit Keynote : A real world story of Angular and Apache Unomi integra...
PDF
Apache Unomi In Depth - ApacheCon EU 2015 Session
PDF
Introducing Apache Unomi - JavaOne 2015 Session
PPT
Webinar Présentation jahia en collaboration avec Developpez.com
PDF
Portets to composite applications
ApacheCon NA 2019 : Adding AI to customer segmentation using Apache Unomi and...
ApacheCon NA 2019 : Customer segmentation and personalization using apache unomi
ApacheCon NA 2018 : Apache Unomi, an Open Source Customer Data Platformapache...
DEVOXX FR 2016 We're Watching You (Apache Unomi)
UXDev Summit Keynote : A real world story of Angular and Apache Unomi integra...
Apache Unomi In Depth - ApacheCon EU 2015 Session
Introducing Apache Unomi - JavaOne 2015 Session
Webinar Présentation jahia en collaboration avec Developpez.com
Portets to composite applications

Recently uploaded (20)

PPTX
Digital-Transformation-Roadmap-for-Companies.pptx
PDF
The Rise and Fall of 3GPP – Time for a Sabbatical?
PDF
Empathic Computing: Creating Shared Understanding
PDF
Encapsulation theory and applications.pdf
PDF
TokAI - TikTok AI Agent : The First AI Application That Analyzes 10,000+ Vira...
PPTX
20250228 LYD VKU AI Blended-Learning.pptx
PPTX
KOM of Painting work and Equipment Insulation REV00 update 25-dec.pptx
PDF
Electronic commerce courselecture one. Pdf
PDF
Agricultural_Statistics_at_a_Glance_2022_0.pdf
PPTX
PA Analog/Digital System: The Backbone of Modern Surveillance and Communication
PDF
NewMind AI Monthly Chronicles - July 2025
PDF
Unlocking AI with Model Context Protocol (MCP)
PPTX
Cloud computing and distributed systems.
PPTX
MYSQL Presentation for SQL database connectivity
PDF
Review of recent advances in non-invasive hemoglobin estimation
PDF
Encapsulation_ Review paper, used for researhc scholars
PDF
Architecting across the Boundaries of two Complex Domains - Healthcare & Tech...
PDF
Per capita expenditure prediction using model stacking based on satellite ima...
PDF
Reach Out and Touch Someone: Haptics and Empathic Computing
PDF
Network Security Unit 5.pdf for BCA BBA.
Digital-Transformation-Roadmap-for-Companies.pptx
The Rise and Fall of 3GPP – Time for a Sabbatical?
Empathic Computing: Creating Shared Understanding
Encapsulation theory and applications.pdf
TokAI - TikTok AI Agent : The First AI Application That Analyzes 10,000+ Vira...
20250228 LYD VKU AI Blended-Learning.pptx
KOM of Painting work and Equipment Insulation REV00 update 25-dec.pptx
Electronic commerce courselecture one. Pdf
Agricultural_Statistics_at_a_Glance_2022_0.pdf
PA Analog/Digital System: The Backbone of Modern Surveillance and Communication
NewMind AI Monthly Chronicles - July 2025
Unlocking AI with Model Context Protocol (MCP)
Cloud computing and distributed systems.
MYSQL Presentation for SQL database connectivity
Review of recent advances in non-invasive hemoglobin estimation
Encapsulation_ Review paper, used for researhc scholars
Architecting across the Boundaries of two Complex Domains - Healthcare & Tech...
Per capita expenditure prediction using model stacking based on satellite ima...
Reach Out and Touch Someone: Haptics and Empathic Computing
Network Security Unit 5.pdf for BCA BBA.

OSGi in 5 minutes

  • 2. Why ? • Most
mature
Java
“plug‐in”
technology • Allows
hot
deployment/un‐deployment • Manages
dependencies
between
plug‐ins
(aka
 OSGi
bundles) • Offers
(opKonal)
addiKonal
services
(HTTP,
 configuraKon,
etc...)
  • 3. What is an OSGi Bundle ? JAR • Basically
a
JAR
with: MANIFEST.MF –AddiKonal
stuff
in
it’s
 Bundle-Name: Hello World manifest
file Bundle-SymbolicName: org.example.helloworld Bundle-Description: A Hello World bundle Bundle-ManifestVersion: 2 Bundle-Version: 1.0.0 –A
class
called
an
 Bundle-Activator: org.example.Activator Export-Package: org.example.helloworld;version="1.0.0" acKvator
to
register
 Import-Package: org.osgi.framework;version="1.3.0" services Classes –Your
code
and
resources org.example.AcKvator ... –(OpKonally)Other
JARs
 for
legacy
(migraKon)
 (OpKonal)
JARs legacy‐1.0.jar purposes ...
  • 4. OSGi Services Services
are
all
implemented
using
one
or
more
OSGi
bundles Logging Component
RunKme Wire
Admin ConfiguraKon
Admin Deployment
Admin XML
Parser Device
Access Event
Admin Measurement
and
State User
Admin ApplicaKon
Admin My
Service
1 IO
Connector HTTP
Service My
Service
2 Preferences UPnP
Device
Service
  • 5. Bundle Activator • Simply
iniKalizes
 and
shuts
down
the
 package org.example; bundle
(if
needed) import org.osgi.framework.BundleActivator; import org.osgi.framework.BundleContext; public class Activator implements BundleActivator { • Can
register
with
 private BundleContext context; public void start(BundleContext context) throws Exception { System.out.println("Starting: Hello World"); exisKng
services } this.context = context; public void stop(BundleContext context) throws Exception { • Helper
classes
are
 } System.out.println("Stopping: Goodbye Cruel World"); this.context = null; available
to
make
 } things
easier
  • 6. OSGi and Maven • Very
good
match
as
both
know
about
 dependencies • Maven
project
==
OSGi
bundle • Maven
Felix
Plugin
does
the
packaging
for
you
! <plugin> <groupId>org.apache.felix</groupId> <artifactId>maven-bundle-plugin</artifactId> <extensions>true</extensions> <configuration> <instructions> <Export-Package>org.osgi.service.log</Export-Package> <Private-Package>org.apache.felix.log.impl</Private-Package> <Bundle-SymbolicName>${pom.artifactId}</Bundle-SymbolicName> <Bundle-Activator>${pom.artifactId}.impl.Activator</Bundle-Activator> <Export- Service>org.osgi.service.log.LogService,org.osgi.service.log.LogReaderService</ Export-Service> </instructions> </configuration> </plugin>
  • 7. Learn more... • OSGi
implementaKons –Eclipse
Equinox
:
hfp://eclipse.org/equinox/
(most
 mature,
was
born
out
of
Eclipse,
integrated
in
 Websphere
and
Eclipse) –Apache
Felix
:
hfp://felix.apache.org
(best
integraKon
 with
Maven,
evolving
rapidly,
used
in
Apache
Sling
and
 other
Apache
projects


Editor's Notes