Your SlideShare is downloading. ×
OSGi in 5 minutes
OSGi in 5 minutes
OSGi in 5 minutes
OSGi in 5 minutes
OSGi in 5 minutes
OSGi in 5 minutes
OSGi in 5 minutes
Upcoming SlideShare
Loading in...5
×

Thanks for flagging this SlideShare!

Oops! An error has occurred.

×
Saving this for later? Get the SlideShare app to save on your phone or tablet. Read anywhere, anytime – even offline.
Text the download link to your phone
Standard text messaging rates apply

OSGi in 5 minutes

2,228

Published on

A (very) quick introduction to OSGi for Java developers. These slides are meant to be a quick overview of the technology and make you understand how useful it can be.

A (very) quick introduction to OSGi for Java developers. These slides are meant to be a quick overview of the technology and make you understand how useful it can be.

Published in: Technology, Education
0 Comments
2 Likes
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total Views
2,228
On Slideshare
0
From Embeds
0
Number of Embeds
1
Actions
Shares
0
Downloads
0
Comments
0
Likes
2
Embeds 0
No embeds

Report content
Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
No notes for slide
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • Transcript

    • 1. Serge
Huber,
Jahia
CTOshuber@jahia.comOSGi 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
bundlesLogging Component
RunKme Wire
AdminConfiguraKon
Admin Deployment
Admin XML
ParserDevice
Access Event
Admin Measurement
and
StateUser
Admin ApplicaKon
Admin My
Service
1IO
Connector HTTP
Service My
Service
2Preferences 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


    ×