SlideShare a Scribd company logo
OSGi Overview

      Presenter: Alex Proca



BJUG - 23 oct 2012
Plan
   Problem
   Solution
   Architecture
   Tools
   Demo & Q




                   BJUG - 23 oct 2012
Plan
   Problem
       Dependency Management
           Version Hell
           Conflicting dependencies
           Class loading issues
       Dynamic Behavior
           Difficulties to control component lifecycle
       Lack of a pure modularity solution
   Solution
   Architecture
   Tools
   Demo & Q

                                               BJUG - 23 oct 2012
Dependency Management
   Version Hell - The first case is when a developer or deployer of a Java application
    has accidentally made two different versions of a library available to the system. This will
    not be considered an error by the system. Rather, the system will load classes from one
    or the other library. Adding the new library to the list of available libraries instead of
    replacing it, may see the application still behaving as though the old library is in use,
    which it may well be
   Conflicting dependencies - Another version of the problem arises when two
    libraries (or a library and the application) require different versions of the same third
    library. If both versions of the third library use the same class names, there is no way to
    load both versions of the third library with the same classloader
   Class loading issues - The most complex JAR hell problems arise in circumstances
    that take advantage of the full complexity of the classloading system. A Java program is
    not required to use only a single "flat" classloader, but instead may be composed of
    several (potentially very many) nested, cooperating classloaders. Classes loaded by
    different classloaders may interact in complex ways not fully comprehended by a
    developer, leading to inexplicable errors or bugs.



                                                    BJUG - 23 oct 2012
Dynamic Behavior

   Components and services needs to be installed / removed
   Components need to get updated / replaced
   Components need to be started / stopped



   Example
       Eclipse install/remove plugins/features




                                                  BJUG - 23 oct 2012
Lack of a pure modularity solution
   JVM does not address modularity
       JAR is a black box
           No dependency and no version


   Pure JVM modularity ?
       Jigsaw for JDK 8


   But OSGi is available now




                                           BJUG - 23 oct 2012
Plan
   Problem
   Solution
       OSGi layers
       Deployment infrastructure
           Bundle = byte code + metadata (imports / exports)
           Bundle Activator
           Bundle Dependencies
           Bundles have a lifecycle
           Bundles have their own class loader
           Bundle Versioning
       Service Platform
       Security Layer
       Issues
       Related Projects
   Tools
   Demo & Q

                                                  BJUG - 23 oct 2012
OSGi layers
   OSGi Framework
       Bundles (modules)
       Execution environment
       Application lifecycle
       Services
           Service registry
       Security
   Application share the same JVM




                                BJUG - 23 oct 2012
Bundle
   Bundle - Basic deployment entity (~ application, library)
       Versioned (1.0.2.rc3 – major, minor, micro, qualifier)
       Declaratively specified dependencies
       Represented as JAR file of
           Code, resources
           Extended Manifest file
   Bundle fragments
       Similar to bundles
           Allow extending an existing bundle (often used for testing extended
            bundle)
           Requires a host bundle



                                             BJUG - 23 oct 2012
Bundle Activator
   Class defined in manifest.mf
       Bundle-Activator header
           Can be an external class

   Handle bundle start / stop
       Start
           Register services
           Create service trackers
           Start threads
       Stop
           Release resources
               Unregister own services
               Release used services


                                          BJUG - 23 oct 2012
Bundle dependencies
   Expose packages
       List all of (packages + versions + attributes)
       Fine grained package filtering
   Import Bundle
       Require specific versions (ex. [10.0.0, 13.0.1) )
   Require bundle
       Restricts further changes in API (not recommended)
   Bundle Class path
       Embedded bundle dependencies
           Maven bnd plugin uses this feature to transform some non OSGi
            libraries to OSGi bundles


                                            BJUG - 23 oct 2012
Bundle life cycle




                    BJUG - 23 oct 2012
Separate classloaders




                        BJUG - 23 oct 2012
Bundle Versioning
                                                                    Good
Different versions of ZAB in same JVM

                                                                   FOO
               FOO                  Bad (ClassCastException)
               1.0.0
                                            FOO                            ZAB
                                                                           1.0.0
     BAR                     LIB             ZAB                   BAR
     1.0.4                  1.0.1            1.0.0


              Common                         BAR
     ZAB                    ZAB
     1.0.0                  1.1.0             ZAB
                                              1.0.0


                                              BJUG - 23 oct 2012
Plan
   Problem
   Solution
       OSGi layers
       Deployment infrastructure
       Service Platform
           Registering Service
           Consuming Service
           Service Tracker
       Security Layer
       Issues
       Related Projects
   Tools
   Demo & Q

                                    BJUG - 23 oct 2012
Service
   Bundles – modular but still static entities
       How to communicate between bundles?
   Services – dynamic in OSGi
       Can appear / disappear at runtime in according to a condition
       For one service name multiple providers can exist
   Service
       Object registered by a bundle
           BundleContext.registerService(Interface, Impl, Properties)
           Framework automatically unregister all services of stopped bundle




                                             BJUG - 23 oct 2012
Registering Service
   Programmatically in Bundle Activator
       Problems : semantics not clear



   Declaratively
       DS
           Service-Component header refers to xml declaring the service




                                            BJUG - 23 oct 2012
Consuming Service
   Bundle can search for service implementing specific
    interface
   Components
       Declare getter components




                                    BJUG - 23 oct 2012
Service tracker – Consuming Service
   Tracking for service
       Filters by some properties defined with the service
           LDAP syntax (ex. (&(type=“dh”)(heavy=“false”)))




                                             BJUG - 23 oct 2012
Plan
   Problem
   Solution
       OSGi layers
       Deployment infrastructure
       Service Platform
       Security Layer
       Issues
       Implementations
       Related Projects
   Tools
   Demo & Q

                                    BJUG - 23 oct 2012
Security Layer
   Optional (most people does not use security)
   Based on Java 2 Security Architecture
   4 roles
       Developer
           Adds local permissions to the bundle by signning
       Deployer
           Sign the bundle and deploy
       Operator
           Full control all time
       End User



                                             BJUG - 23 oct 2012
Issues

   No repository defined in standards
       Planned for OSGi4
       Equinox have p2 repo


   Bundle dependency resolver
       Resolving bundles can take long time




                                       BJUG - 23 oct 2012
Implementations
   Equinox
       Bundles can be directories too
       Used by eclipse IDE
   Felix
   Concierge
   Knoplerfish




                                         BJUG - 23 oct 2012
Related Projects
   rOSGi – access services in a remote OSGi
   Glassfish v3
       OSGi replace HK2 (module system)
       Uses Apache Felix
   Spring DM
       Donated to eclipse as Virgo project
       Integration of OSGi inside spring
   Spring application platform
       Similar concepts to OSGi
       Defines bundle repository
   JSR 227
       Java modules, proposed OSGi interoperability

                                       BJUG - 23 oct 2012
Tools



   m2eclipse – bridge between eclipse and maven
   Tycho – build OSGi with maven
   Tycho Extras – utils for OSGi builds




                                BJUG - 23 oct 2012
Credits
   Polyglot OSGi -
    http://www.slideshare.net/mstine/polyglot-osgi
   Introduction to OSGi -
    http://www.slideshare.net/iocanel/introduction-toosgi
   OSGi presentation CZJUG -
    http://www.slideshare.net/mmalohlava/osgi-presentation




                                 BJUG - 23 oct 2012
Thank you




     BJUG - 23 oct 2012

More Related Content

PDF
From Distributed to Pervasive OSGi
PPTX
Intro to OSGi
PDF
OSGi & Java EE in GlassFish - Best of both worlds
PDF
OSGi Presentation
PDF
OSGi Blueprint Services
PDF
Modules all the way down: OSGi and the Java Platform Module System
PDF
What's Expected in Java 7
KEY
OSGi in 5 minutes
From Distributed to Pervasive OSGi
Intro to OSGi
OSGi & Java EE in GlassFish - Best of both worlds
OSGi Presentation
OSGi Blueprint Services
Modules all the way down: OSGi and the Java Platform Module System
What's Expected in Java 7
OSGi in 5 minutes

What's hot (20)

PDF
OSGi-enabled Java EE applications in GlassFish
PDF
Jax london 2011
PDF
Architecture | Modular Enterprise Applications | Mark Nuttall
PPTX
Modularity of The Java Platform Javaday (http://javaday.org.ua/)
PDF
Intro To OSGi
PDF
OSGi Service Platform Release 4 Overview - BJ Hargrave, IBM & Peter Kriens, a...
PPTX
Comparison between Oracle JDK, Oracle OpenJDK, and Red Hat OpenJDK.v1.0.20191009
PPT
Managing Change
PDF
Smooth transition to Eclipse in practice
PDF
Introduction to Google Web Toolkit
PDF
OpenJDK Penrose Presentation (JavaOne 2012)
PPTX
Java 7 - What's New?
PDF
The glideinWMS approach to the ownership of System Images in the Cloud World
ZIP
Practical OSGi
PDF
Rogue bundles
PPTX
How to implement a simple dalvik virtual machine
PDF
OSGi-enabled Java EE Applications using GlassFish at JCertif 2011
PDF
Using the OSGi Application Model on Mobile Devices with CLDC JVM - Dimitar Va...
PDF
OSGi & Java EE in GlassFish
PDF
Scaling Puppet Usage to a Global Organization
OSGi-enabled Java EE applications in GlassFish
Jax london 2011
Architecture | Modular Enterprise Applications | Mark Nuttall
Modularity of The Java Platform Javaday (http://javaday.org.ua/)
Intro To OSGi
OSGi Service Platform Release 4 Overview - BJ Hargrave, IBM & Peter Kriens, a...
Comparison between Oracle JDK, Oracle OpenJDK, and Red Hat OpenJDK.v1.0.20191009
Managing Change
Smooth transition to Eclipse in practice
Introduction to Google Web Toolkit
OpenJDK Penrose Presentation (JavaOne 2012)
Java 7 - What's New?
The glideinWMS approach to the ownership of System Images in the Cloud World
Practical OSGi
Rogue bundles
How to implement a simple dalvik virtual machine
OSGi-enabled Java EE Applications using GlassFish at JCertif 2011
Using the OSGi Application Model on Mobile Devices with CLDC JVM - Dimitar Va...
OSGi & Java EE in GlassFish
Scaling Puppet Usage to a Global Organization
Ad

Viewers also liked (20)

PDF
OSGi Benefits for the Pervasive Value Chain - D Bandera
PPTX
PDF
OSGi In A Nutshell
PDF
OSGi Community Event 2010 - OSGi Technical Update
PDF
Release 4 from a Business Perspective - Peter Kriens, OSGi Alliance Fellow; T...
PDF
Leveraging OSGi Technology for End-to-End Reconfigurability- Enabling a Seaml...
PDF
Keynote: OSGi Past, Present and Future - Alex Blewitt
PDF
Technical Specification Overview - OSGi World Congress 2002 Workshop Intro - ...
PDF
OSGi IoT Demo @ CeBIT 2016
PDF
OSGi Specification Evolution - BJ Hargrave
PDF
OSGi -Simplifying the IoT Gateway - Walt Bowers
PDF
How the OSGi Residential Specifications can help to build an ecosystem for sm...
PDF
OSGi for IoT: the good, the bad and the ugly - Tim Verbelen
PDF
OSGi Technology Value Proposition - December 2013
PPT
OSGi & Blueprint
PDF
Why OSGi?
PPTX
OSGi Training for Carbon Developers
PDF
Benefits of OSGi in Practise
PDF
Concierge - Bringing OSGi (back) to Embedded Devices
PDF
Business and IoT Economic Alchemy or Another Anticlimax - March 2016 - OSGi A...
OSGi Benefits for the Pervasive Value Chain - D Bandera
OSGi In A Nutshell
OSGi Community Event 2010 - OSGi Technical Update
Release 4 from a Business Perspective - Peter Kriens, OSGi Alliance Fellow; T...
Leveraging OSGi Technology for End-to-End Reconfigurability- Enabling a Seaml...
Keynote: OSGi Past, Present and Future - Alex Blewitt
Technical Specification Overview - OSGi World Congress 2002 Workshop Intro - ...
OSGi IoT Demo @ CeBIT 2016
OSGi Specification Evolution - BJ Hargrave
OSGi -Simplifying the IoT Gateway - Walt Bowers
How the OSGi Residential Specifications can help to build an ecosystem for sm...
OSGi for IoT: the good, the bad and the ugly - Tim Verbelen
OSGi Technology Value Proposition - December 2013
OSGi & Blueprint
Why OSGi?
OSGi Training for Carbon Developers
Benefits of OSGi in Practise
Concierge - Bringing OSGi (back) to Embedded Devices
Business and IoT Economic Alchemy or Another Anticlimax - March 2016 - OSGi A...
Ad

Similar to OSGi overview (20)

PPTX
Modular Java
PDF
Osgi Sun 20080820
PDF
Open Services Gateway Initiative (OSGI)
PDF
OSGi tech session
PDF
CodeCamp Iasi 10 march 2012 - SolvingThePuzzle
PPT
Osgi Webinar
PPT
Os gi introduction made by Ly MInh Phuong-SOC team
PPTX
Modularity of the Java Platform (OSGi, Jigsaw and Penrose)
PPTX
Introduction to OSGGi
PPTX
Java Modularity with OSGi
PDF
Create *real* modular Java applications - a brief introduction -
PDF
OSGi Applications Clustering using Distributed Shared Memory
PPTX
OSGi in Action Chapter 1 and 2
PPTX
Introduction to OSGi - Part-1
PPT
OSGi Persistence With EclipseLink
PDF
OSGi-enabled Java EE Applications using GlassFish
PPTX
Hybrid Applications
ODP
Frankenstein's IDE: NetBeans and OSGi
PDF
OSGI Modularity
PPT
Enabling modularization through OSGi and SpringDM
Modular Java
Osgi Sun 20080820
Open Services Gateway Initiative (OSGI)
OSGi tech session
CodeCamp Iasi 10 march 2012 - SolvingThePuzzle
Osgi Webinar
Os gi introduction made by Ly MInh Phuong-SOC team
Modularity of the Java Platform (OSGi, Jigsaw and Penrose)
Introduction to OSGGi
Java Modularity with OSGi
Create *real* modular Java applications - a brief introduction -
OSGi Applications Clustering using Distributed Shared Memory
OSGi in Action Chapter 1 and 2
Introduction to OSGi - Part-1
OSGi Persistence With EclipseLink
OSGi-enabled Java EE Applications using GlassFish
Hybrid Applications
Frankenstein's IDE: NetBeans and OSGi
OSGI Modularity
Enabling modularization through OSGi and SpringDM

OSGi overview

  • 1. OSGi Overview Presenter: Alex Proca BJUG - 23 oct 2012
  • 2. Plan  Problem  Solution  Architecture  Tools  Demo & Q BJUG - 23 oct 2012
  • 3. Plan  Problem  Dependency Management  Version Hell  Conflicting dependencies  Class loading issues  Dynamic Behavior  Difficulties to control component lifecycle  Lack of a pure modularity solution  Solution  Architecture  Tools  Demo & Q BJUG - 23 oct 2012
  • 4. Dependency Management  Version Hell - The first case is when a developer or deployer of a Java application has accidentally made two different versions of a library available to the system. This will not be considered an error by the system. Rather, the system will load classes from one or the other library. Adding the new library to the list of available libraries instead of replacing it, may see the application still behaving as though the old library is in use, which it may well be  Conflicting dependencies - Another version of the problem arises when two libraries (or a library and the application) require different versions of the same third library. If both versions of the third library use the same class names, there is no way to load both versions of the third library with the same classloader  Class loading issues - The most complex JAR hell problems arise in circumstances that take advantage of the full complexity of the classloading system. A Java program is not required to use only a single "flat" classloader, but instead may be composed of several (potentially very many) nested, cooperating classloaders. Classes loaded by different classloaders may interact in complex ways not fully comprehended by a developer, leading to inexplicable errors or bugs. BJUG - 23 oct 2012
  • 5. Dynamic Behavior  Components and services needs to be installed / removed  Components need to get updated / replaced  Components need to be started / stopped  Example  Eclipse install/remove plugins/features BJUG - 23 oct 2012
  • 6. Lack of a pure modularity solution  JVM does not address modularity  JAR is a black box  No dependency and no version  Pure JVM modularity ?  Jigsaw for JDK 8  But OSGi is available now BJUG - 23 oct 2012
  • 7. Plan  Problem  Solution  OSGi layers  Deployment infrastructure  Bundle = byte code + metadata (imports / exports)  Bundle Activator  Bundle Dependencies  Bundles have a lifecycle  Bundles have their own class loader  Bundle Versioning  Service Platform  Security Layer  Issues  Related Projects  Tools  Demo & Q BJUG - 23 oct 2012
  • 8. OSGi layers  OSGi Framework  Bundles (modules)  Execution environment  Application lifecycle  Services  Service registry  Security  Application share the same JVM BJUG - 23 oct 2012
  • 9. Bundle  Bundle - Basic deployment entity (~ application, library)  Versioned (1.0.2.rc3 – major, minor, micro, qualifier)  Declaratively specified dependencies  Represented as JAR file of  Code, resources  Extended Manifest file  Bundle fragments  Similar to bundles  Allow extending an existing bundle (often used for testing extended bundle)  Requires a host bundle BJUG - 23 oct 2012
  • 10. Bundle Activator  Class defined in manifest.mf  Bundle-Activator header  Can be an external class  Handle bundle start / stop  Start  Register services  Create service trackers  Start threads  Stop  Release resources  Unregister own services  Release used services BJUG - 23 oct 2012
  • 11. Bundle dependencies  Expose packages  List all of (packages + versions + attributes)  Fine grained package filtering  Import Bundle  Require specific versions (ex. [10.0.0, 13.0.1) )  Require bundle  Restricts further changes in API (not recommended)  Bundle Class path  Embedded bundle dependencies  Maven bnd plugin uses this feature to transform some non OSGi libraries to OSGi bundles BJUG - 23 oct 2012
  • 12. Bundle life cycle BJUG - 23 oct 2012
  • 13. Separate classloaders BJUG - 23 oct 2012
  • 14. Bundle Versioning Good Different versions of ZAB in same JVM FOO FOO Bad (ClassCastException) 1.0.0 FOO ZAB 1.0.0 BAR LIB ZAB BAR 1.0.4 1.0.1 1.0.0 Common BAR ZAB ZAB 1.0.0 1.1.0 ZAB 1.0.0 BJUG - 23 oct 2012
  • 15. Plan  Problem  Solution  OSGi layers  Deployment infrastructure  Service Platform  Registering Service  Consuming Service  Service Tracker  Security Layer  Issues  Related Projects  Tools  Demo & Q BJUG - 23 oct 2012
  • 16. Service  Bundles – modular but still static entities  How to communicate between bundles?  Services – dynamic in OSGi  Can appear / disappear at runtime in according to a condition  For one service name multiple providers can exist  Service  Object registered by a bundle  BundleContext.registerService(Interface, Impl, Properties)  Framework automatically unregister all services of stopped bundle BJUG - 23 oct 2012
  • 17. Registering Service  Programmatically in Bundle Activator  Problems : semantics not clear  Declaratively  DS  Service-Component header refers to xml declaring the service BJUG - 23 oct 2012
  • 18. Consuming Service  Bundle can search for service implementing specific interface  Components  Declare getter components BJUG - 23 oct 2012
  • 19. Service tracker – Consuming Service  Tracking for service  Filters by some properties defined with the service  LDAP syntax (ex. (&(type=“dh”)(heavy=“false”))) BJUG - 23 oct 2012
  • 20. Plan  Problem  Solution  OSGi layers  Deployment infrastructure  Service Platform  Security Layer  Issues  Implementations  Related Projects  Tools  Demo & Q BJUG - 23 oct 2012
  • 21. Security Layer  Optional (most people does not use security)  Based on Java 2 Security Architecture  4 roles  Developer  Adds local permissions to the bundle by signning  Deployer  Sign the bundle and deploy  Operator  Full control all time  End User BJUG - 23 oct 2012
  • 22. Issues  No repository defined in standards  Planned for OSGi4  Equinox have p2 repo  Bundle dependency resolver  Resolving bundles can take long time BJUG - 23 oct 2012
  • 23. Implementations  Equinox  Bundles can be directories too  Used by eclipse IDE  Felix  Concierge  Knoplerfish BJUG - 23 oct 2012
  • 24. Related Projects  rOSGi – access services in a remote OSGi  Glassfish v3  OSGi replace HK2 (module system)  Uses Apache Felix  Spring DM  Donated to eclipse as Virgo project  Integration of OSGi inside spring  Spring application platform  Similar concepts to OSGi  Defines bundle repository  JSR 227  Java modules, proposed OSGi interoperability BJUG - 23 oct 2012
  • 25. Tools  m2eclipse – bridge between eclipse and maven  Tycho – build OSGi with maven  Tycho Extras – utils for OSGi builds BJUG - 23 oct 2012
  • 26. Credits  Polyglot OSGi - http://www.slideshare.net/mstine/polyglot-osgi  Introduction to OSGi - http://www.slideshare.net/iocanel/introduction-toosgi  OSGi presentation CZJUG - http://www.slideshare.net/mmalohlava/osgi-presentation BJUG - 23 oct 2012
  • 27. Thank you BJUG - 23 oct 2012