JBoss AS7 OSGi




          Thomas Diesler
            thomas.diesler@jboss.com




                                  1
Agenda
• OSGi Core
• Enterprise OSGi
• OSGi in AS7
OSGi Core: Modularity
• OSGi modules are called 'Bundles'
• Computed classloader delegation graph
• Bundles can be added,
  removed & updated dynamically JRE         JRE

• Side-by-side versioning
• Private truly private      Lib A
                             Lib A         Lib B
                                           Lib B          Lib A'
                                                          Lib A'

• No more Jar Hell
• OSGi Bundle can be a            Module A       Module B
                                  Module A       Module B
  plain Jar at the same time
OSGi Core: Services
• “SOA inside the JVM”
• Services looked up by type and/or custom
  filter
  – “I want a service that implements
    org.acme.Payment where location=US”
  – One or many
• Dynamic! Services can be updated without
  taking down the consumers
  – OSGi Service Consumers react to dynamism
The Dawning of Life

                              Attention on Modules




                           Appreciation of module
                               independence


                               Concern about module
                             life-cycle and governance




                                …but the problem
                                 already existed!




5                     © 2011 IBM Corporation
Cost vs Complexity
Cost
                               Big ball of mud


            Traditional

                                                 Many small &
                                                 focused modules
                          Modular




                                                   Complexity

       Modularity highly improves
                            *
            maintainability
OSGi Bundles vs. JBoss Modules

• OSGi is a standard             • Modules not portable
• Uses a complex resolver        • Uses explicit wiring
• Wiring based on rich           • Wiring based on module
  metadata. Package version        name. Multiple “slots” are
  just one criteria                supported
• Many compendium                • Exist in the context of AS7
  specifications and other 3rd   • Very fast resolution
  party bundles
• Attachable Fragments
• Sensitive to execution env
OSGi Service vs. MSC Services

• Keyed by Interface they       • Keyed by unique service
  implement                       name
• LDAP filter supported         • No filtering, name only
• Lifecycle tied to owner       • Lifecycle tied to owner
  bundle or explicit API          owner or explicit API
• Service dependency and        • Service dependency and
  injection via DS, Blueprint     injection by MSC API
• ServiceListener supported     • ServiceListener supported
• ServiceFactory supported      • Instance per service name
• ConfigurationAdmin            • ConfigAdmin in AS7
R5 Enterprise OSGi
• Mapping of a number of EE specs
     – Webapp               – JPA
     – JTA                  – JNDI
     – JDBC         – JMX
• Remote Services
• Resolver
• Repository
• Subsystems
• Blueprint
Enterprise OSGi - Future
•   RFC 146 JCA
•   RFP 133 Cloud Computing
•   RFP 146 - CDI Integration
•   RFP 152 - EJB Integration
OSGi Core in AS7
• AS7 is a fully compliant OSGi 4.2 Core
  Framework
  – TCK tests pass 100%
• Just deploy your OSGi Bundles
  – Through the standard AS7 deployment
    channels
OSGi Core Implementation
• Implemented from scratch on top of jboss-
  modules and jboss-msc
• For the OSGi resolver we use the one from
  Apache Felix
  – Resolver computes the bundle classloader
    wirings
  – Based on OSGi Metadata
     • e.g. Import-Package / Export-Package
AS7 OSGi Integration

• Use OSGi services in EE components
• Use EE components in OSGi services
• JBoss modules/msc as integration layer
• Every bundle is a module. Not every module
  is bundle
• Support for WebApp, EJB, CDI, JAX-RS,
  JAX-WS, JPA as OSGi deployments
• Support for Bundles in EAR files
Enterprise OSGi in AS7
• AS7 out of the Box:
  – OSGi Core, Compendium APIs
  – Enterprise OSGi JMX, JNDI, JTA, WebApp,
    Blueprint
  – OSGi ConfigAdmin, EventAdmin, HttpServer
  – Management through WebConsole
OSGi in AS7 – Next Steps
• OSGi R5 specification
• OSGi Enterprise Applications
• Provisioning service
Demo
• Show how an EJB3 can access an OSGi
  payment service
• Show how a Servlet can access an OSGi
  payment service
Q&A
Links

• AS7 home page
  http://www.jboss.org/jbossas
• AS7 OSGi home page
  http://www.jboss.org/jbossas/osgi
• OSGi Specifications
  http://www.osgi.org/Download/Release4V42
• JBoss OSGi Diary
  http://jbossosgi.blogspot.com
Acknowledgements
• Cost vs Complexity, Hal Hildebrand
  http://bit.ly/i42uBo
• Dawning of Life, Graham Charters, IBM

AS7/OSGi One Day Talk 2012

  • 1.
    JBoss AS7 OSGi Thomas Diesler thomas.diesler@jboss.com 1
  • 2.
    Agenda • OSGi Core •Enterprise OSGi • OSGi in AS7
  • 3.
    OSGi Core: Modularity •OSGi modules are called 'Bundles' • Computed classloader delegation graph • Bundles can be added, removed & updated dynamically JRE JRE • Side-by-side versioning • Private truly private Lib A Lib A Lib B Lib B Lib A' Lib A' • No more Jar Hell • OSGi Bundle can be a Module A Module B Module A Module B plain Jar at the same time
  • 4.
    OSGi Core: Services •“SOA inside the JVM” • Services looked up by type and/or custom filter – “I want a service that implements org.acme.Payment where location=US” – One or many • Dynamic! Services can be updated without taking down the consumers – OSGi Service Consumers react to dynamism
  • 5.
    The Dawning ofLife Attention on Modules Appreciation of module independence Concern about module life-cycle and governance …but the problem already existed! 5 © 2011 IBM Corporation
  • 6.
    Cost vs Complexity Cost Big ball of mud Traditional Many small & focused modules Modular Complexity Modularity highly improves * maintainability
  • 7.
    OSGi Bundles vs.JBoss Modules • OSGi is a standard • Modules not portable • Uses a complex resolver • Uses explicit wiring • Wiring based on rich • Wiring based on module metadata. Package version name. Multiple “slots” are just one criteria supported • Many compendium • Exist in the context of AS7 specifications and other 3rd • Very fast resolution party bundles • Attachable Fragments • Sensitive to execution env
  • 8.
    OSGi Service vs.MSC Services • Keyed by Interface they • Keyed by unique service implement name • LDAP filter supported • No filtering, name only • Lifecycle tied to owner • Lifecycle tied to owner bundle or explicit API owner or explicit API • Service dependency and • Service dependency and injection via DS, Blueprint injection by MSC API • ServiceListener supported • ServiceListener supported • ServiceFactory supported • Instance per service name • ConfigurationAdmin • ConfigAdmin in AS7
  • 9.
    R5 Enterprise OSGi •Mapping of a number of EE specs – Webapp – JPA – JTA – JNDI – JDBC – JMX • Remote Services • Resolver • Repository • Subsystems • Blueprint
  • 10.
    Enterprise OSGi -Future • RFC 146 JCA • RFP 133 Cloud Computing • RFP 146 - CDI Integration • RFP 152 - EJB Integration
  • 11.
    OSGi Core inAS7 • AS7 is a fully compliant OSGi 4.2 Core Framework – TCK tests pass 100% • Just deploy your OSGi Bundles – Through the standard AS7 deployment channels
  • 12.
    OSGi Core Implementation •Implemented from scratch on top of jboss- modules and jboss-msc • For the OSGi resolver we use the one from Apache Felix – Resolver computes the bundle classloader wirings – Based on OSGi Metadata • e.g. Import-Package / Export-Package
  • 13.
    AS7 OSGi Integration •Use OSGi services in EE components • Use EE components in OSGi services • JBoss modules/msc as integration layer • Every bundle is a module. Not every module is bundle • Support for WebApp, EJB, CDI, JAX-RS, JAX-WS, JPA as OSGi deployments • Support for Bundles in EAR files
  • 14.
    Enterprise OSGi inAS7 • AS7 out of the Box: – OSGi Core, Compendium APIs – Enterprise OSGi JMX, JNDI, JTA, WebApp, Blueprint – OSGi ConfigAdmin, EventAdmin, HttpServer – Management through WebConsole
  • 15.
    OSGi in AS7– Next Steps • OSGi R5 specification • OSGi Enterprise Applications • Provisioning service
  • 16.
    Demo • Show howan EJB3 can access an OSGi payment service • Show how a Servlet can access an OSGi payment service
  • 17.
  • 18.
    Links • AS7 homepage http://www.jboss.org/jbossas • AS7 OSGi home page http://www.jboss.org/jbossas/osgi • OSGi Specifications http://www.osgi.org/Download/Release4V42 • JBoss OSGi Diary http://jbossosgi.blogspot.com
  • 19.
    Acknowledgements • Cost vsComplexity, Hal Hildebrand http://bit.ly/i42uBo • Dawning of Life, Graham Charters, IBM

Editor's Notes

  • #2 Welcome to the wonderful world of OSGi!