Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.
1
Benefits of OSGi in Practice
David Bosschaert
Principal Engineer
JBoss/Red Hat
OSGi EEG co-chair
October 2012
JavaOne Slide Template Title
About me
● Background in AI / Computer Science,
University of Amsterdam (1996)
● Developing s...
JavaOne Slide Template Title
Agenda
● Introduction to OSGi
● OSGi Modularity
● OSGi Services
● Specifications
● Demo
JavaOne Slide Template Title
OSGi
a brief introduction
OSGi – a brief intro
● Dynamic Module and Services platform for Java
● Started 1999
● Specifications created in the OSGi A...
OSGi – areas
Core: the OSGi Framework
● Modularity
● Services
● Lifecycle and Dynamicity
● Security
Enterprise: services &...
OSGi Framework implementations
● The most popular OSGi implementations are
open source:
● Eclipse Equinox
● Apache Felix
●...
OSGi Enterprise implementations
Also available in open source, in projects such as:
● Commercial implementations exist
● F...
JavaOne Slide Template Title
OSGi – Modularity
Modularity
Non-modular components often keep growing
● blurring their responsibility
● increasing complexity
● making main...
OSGi Modularity
● In OSGi Modules are called Bundles
● With OSGi Modularity you must declare what a
module provides and wh...
OSGi Modularity (2)
● Improves maintainability
● as module boundaries and function must be made
clear
● tends to improve c...
JavaOne Slide Template Title
OSGi Modularity in Practice
● From a Java point of view. Just use classes as normal:
package ...
JavaOne Slide Template Title
OSGi – Services
Brief intro to
OSGi Services
● Services are Java Objects (POJOs)
● registered by Bundles
● consumed by Bundles
● “SOA insi...
OSGi Services
How can we increase software reuse?
● With OSGi Services there is no direct link between the service
consume...
JavaOne Slide Template Title
OSGi Services
How can I tailor my services more effectively?
● Customizations are needed for
...
JavaOne Slide Template Title
Dynamic Service Selection
The triangle represents an OSGi service
Bundle XBundle X
objectClas...
JavaOne Slide Template Title
OSGi Services and Consolidation
I need to replace a Service with an alternative technology
● ...
JavaOne Slide Template Title
OSGi Services and Bugfixes
● OSGi Service-based development can help a lot here
● Let's say S...
Bundle X 1.0Bundle X 1.0
service A
OSGi Services and Bugfixes
consumer
consumer
consumer
Apply service bugfixes without do...
Bundle X 1.0Bundle X 1.0
service A
OSGi Services and Bugfixes
consumer
consumer
consumer
Apply service bugfixes without do...
Bundle X 1.0Bundle X 1.0
service A
OSGi Services and Bugfixes
consumer
consumer
consumer
Bundle X 1.1Bundle X 1.1
service ...
service A
OSGi Services and Bugfixes
consumer
consumer
consumer
Bundle X 1.1Bundle X 1.1
service A'
Apply service bugfixes...
service A
OSGi Services and Bugfixes
consumer
consumer
consumer
Bundle X 1.1Bundle X 1.1
service A'
consumer
consumer
Appl...
OSGi Services and Bugfixes
Bundle X 1.1Bundle X 1.1
service A'
consumer
consumer
Apply service bugfixes without downtime
“...
OSGi Services Summary
● SOA within the Java VM
● Multiple services can provide the same API
● Dynamic (can come and go at ...
JavaOne Slide Template Title
OSGi migration challenges
Challenges – modularity
Migrating existing applications to modular environment is challenging
● Applies to any modular sys...
Challenges – tooling
● Using OSGi works best when using the right tools
● Generally a combination of tools should be selec...
JavaOne Slide Template Title
OSGi – Specifications
JavaOne Slide Template Title
OSGi Core Specification (R5)
● Modularity layer and Bundle specification
● Services layer
● S...
OSGi Enterprise Specification (R5)
● Addresses Enterprise use-cases
● Standard Service APIs
● Configuration
Config Admin /...
OSGi Applied
JavaOne Slide Template Title
Demo and Questions
● Online version:
http://www.youtube.com/watch?v=S8AI3TqiVk4
JavaOne Slide Template Title
References
Specs: http://www.osgi.org/Specifications
Semantic Versioning
White Paper:
http://...
JavaOne Slide Template Title
Image credits
● Images from openclipart.org
Cockroach – TrnsltLife
Merge Arrow – spongman
Bui...
JavaOne Slide Template Title
Click to add title
● Click to add an outline
Upcoming SlideShare
Loading in …5
×

Benefits of OSGi in Practise

10,748 views

Published on

Presentation outlining the benefits of OSGi and also touching on the challenges when migrating an existing system to OSGi.

Published in: Technology, Education
  • Nice preso. A minor comment:
    'Oracle GlassFish Server' is the commercial product derived out of artifacts from GlassFish project and other projects. Could you please specify 'GlassFish' instead of 'Oracle GlassFish' as the OpenSource project name in slide #8?
       Reply 
    Are you sure you want to  Yes  No
    Your message goes here

Benefits of OSGi in Practise

  1. 1. 1 Benefits of OSGi in Practice David Bosschaert Principal Engineer JBoss/Red Hat OSGi EEG co-chair October 2012
  2. 2. JavaOne Slide Template Title About me ● Background in AI / Computer Science, University of Amsterdam (1996) ● Developing software since mid-1980s, working with Java since 1997 ● Joined IONA Technologies, Ireland, 1999 ● Involvement with OSGi specs from 2007 ● EEG co-chair 2009 ● At JBoss/Red Hat since 2010 ● Involved in Apache, JBoss, Eclipse and some github-based opensource projects
  3. 3. JavaOne Slide Template Title Agenda ● Introduction to OSGi ● OSGi Modularity ● OSGi Services ● Specifications ● Demo
  4. 4. JavaOne Slide Template Title OSGi a brief introduction
  5. 5. OSGi – a brief intro ● Dynamic Module and Services platform for Java ● Started 1999 ● Specifications created in the OSGi Alliance ● a non-profit Standards Development Organization ● members include: IBM, Oracle, Red Hat, Adobe, Siemens, TIBCO, France Telecom, Deutsche Telekom, Technicolor, NTT, Hitachi & many more ● www.osgi.org
  6. 6. OSGi – areas Core: the OSGi Framework ● Modularity ● Services ● Lifecycle and Dynamicity ● Security Enterprise: services & component on top of Core Framework ● Addressing Enterprise use-cases, such as: ● Service Distribution ● Component models and IoC ● Configuration and Management ● JavaEE integration ● Cloud Computing Residential and embedded services/components
  7. 7. OSGi Framework implementations ● The most popular OSGi implementations are open source: ● Eclipse Equinox ● Apache Felix ● JBoss AS 7 ● Knopflerfish ● Commercial implementations also exist
  8. 8. OSGi Enterprise implementations Also available in open source, in projects such as: ● Commercial implementations exist ● For the full list go to: http://en.wikipedia.org/wiki/OSGi_Specification_Implementations Apache Aries Eclipse Gemini Apache CXF Ops4J Pax Apache Felix Oracle GlassFish Eclipse ECF JBoss Eclipse Equinox KnowHowLab.org
  9. 9. JavaOne Slide Template Title OSGi – Modularity
  10. 10. Modularity Non-modular components often keep growing ● blurring their responsibility ● increasing complexity ● making maintenance harder over time ● scope creep ● in the end: a Big Ball of Mud[1] OSGi: ● instead of an ever growing component: ● many separate modules ● each with a clear function (and clear API) [1] http://en.wikipedia.org/wiki/Big_ball_of_mud “I struggle to maintain this application because I don't fully understand what it does”
  11. 11. OSGi Modularity ● In OSGi Modules are called Bundles ● With OSGi Modularity you must declare what a module provides and what it needs. ● Typically Java packages ● Can be other capabilities ● Everything not explicitly declared as provided is internal à not accessible to other modules Bundle ABundle A org.foo.api org.foo.impl Bundle BBundle B org.bar.impl
  12. 12. OSGi Modularity (2) ● Improves maintainability ● as module boundaries and function must be made clear ● tends to improve cohesion ● and reduce coupling ● Non-monolithic ● allow for fine-grained updates of the system ● Concurrent versions ● multiple versions of the same module can co-exist ● allows for gradual upgrades
  13. 13. JavaOne Slide Template Title OSGi Modularity in Practice ● From a Java point of view. Just use classes as normal: package org.acme.package1; import org.acme.package2.MyClass; ... MyClass ax = new MyClass(); ax.foo() ● OSGi Module Metadata in MANIFEST.MF Export-Package: org.acme.package1; version=1.2 Import-Package: org.acme.package2; version=[1.1, 2) Compiler support by some, e.g Eclipse javac Runtime enforcement by OSGi Framework
  14. 14. JavaOne Slide Template Title OSGi – Services
  15. 15. Brief intro to OSGi Services ● Services are Java Objects (POJOs) ● registered by Bundles ● consumed by Bundles ● “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 Bundle YBundle YBundle XBundle X
  16. 16. OSGi Services How can we increase software reuse? ● With OSGi Services there is no direct link between the service consumer and provider ● not even a text or XML file somewhere ● they communicate through a predefined API ● improves re-usability ● In OSGi software reuse is visibly much higher than elsewhere ● Given clear APIs implementations can be swapped ● even at runtime ● OSGi standardizes some Service APIs ● organizations sometimes do the same “We have many different components that perform a similar task”
  17. 17. JavaOne Slide Template Title OSGi Services How can I tailor my services more effectively? ● Customizations are needed for ● Premium customers vs community users ● Customers who bought specific functionality ● Government vs commercial customers è Services can be used to swap in/out customizations ● To tailor a service, just provide an alternative for a given API ● Services can be selected based on API and Properties ● Properties can be used to find the right set of services for a given customer “We have many customizations that are labour intensive to support”
  18. 18. JavaOne Slide Template Title Dynamic Service Selection The triangle represents an OSGi service Bundle XBundle X objectClass=org.api.MySvc myType=regular Bundle A (consumer)Bundle A (consumer) myFilter=(&(objectClass=org.api.MySvc) (myType=premium)) MySvc svc=getService(myFilter) svc.doSomething() Bundle YBundle Y objectClass=org.api.MySvc myType=premium Service selected based on filter
  19. 19. JavaOne Slide Template Title OSGi Services and Consolidation I need to replace a Service with an alternative technology ● If the API of the new technology can be mapped to the existing service ● Create an OSGi Service that wraps the alternative ● Replace the bundle providing the existing service with another bundle providing the wrapped technology ● If no mapping can take place ● OSGi can still help through multiple concurrent versions ● Gradual migration “Business consolidation brings many integration challenges”
  20. 20. JavaOne Slide Template Title OSGi Services and Bugfixes ● OSGi Service-based development can help a lot here ● Let's say Service A1 contains a bug ● Service A1 has many active clients ● We don't want to kill the clients ● But new clients should use the fixed service ● Service A2 is a fixed version of the service ● Implementation has changed, API hasn't ● Install bundle with Service A2 ● Service A1 and A2 exist concurrently ● Uninstall bundle with Service A1 ● Old clients can still finish using the service ● Will not be handed out to new clients “We need to minimize downtime needed to apply bugfixes”
  21. 21. Bundle X 1.0Bundle X 1.0 service A OSGi Services and Bugfixes consumer consumer consumer Apply service bugfixes without downtime “We need to minimize downtime needed to apply bugfixes”
  22. 22. Bundle X 1.0Bundle X 1.0 service A OSGi Services and Bugfixes consumer consumer consumer Apply service bugfixes without downtime “We need to minimize downtime needed to apply bugfixes”
  23. 23. Bundle X 1.0Bundle X 1.0 service A OSGi Services and Bugfixes consumer consumer consumer Bundle X 1.1Bundle X 1.1 service A' Apply service bugfixes without downtime “We need to minimize downtime needed to apply bugfixes”
  24. 24. service A OSGi Services and Bugfixes consumer consumer consumer Bundle X 1.1Bundle X 1.1 service A' Apply service bugfixes without downtime “We need to minimize downtime needed to apply bugfixes”
  25. 25. service A OSGi Services and Bugfixes consumer consumer consumer Bundle X 1.1Bundle X 1.1 service A' consumer consumer Apply service bugfixes without downtime “We need to minimize downtime needed to apply bugfixes”
  26. 26. OSGi Services and Bugfixes Bundle X 1.1Bundle X 1.1 service A' consumer consumer Apply service bugfixes without downtime “We need to minimize downtime needed to apply bugfixes”
  27. 27. OSGi Services Summary ● SOA within the Java VM ● Multiple services can provide the same API ● Dynamic (can come and go at runtime) ● and OSGi Service Consumers know how to deal with this ● Lookup based on LDAP-style filters ● look up one or many ● OSGi Services are normally within the Java VM ● also: Distributed OSGi Services ● OSGi Remote Services specifications
  28. 28. JavaOne Slide Template Title OSGi migration challenges
  29. 29. Challenges – modularity Migrating existing applications to modular environment is challenging ● Applies to any modular system, not just OSGi ● Requires some planning ● I would suggest a gradual approach ● start with a large bundle containing much of the existing functionality ● splitting off smaller modules over time Prevalent modularity anti-patterns ● Class.forName() ● java.util.ServiceLoader ● Thread context classloader ● Solutions exist for each, but requires some attention
  30. 30. Challenges – tooling ● Using OSGi works best when using the right tools ● Generally a combination of tools should be selected, for ● Development (IDE) ● Command-line build ● Testing ● Deployment ● etc... ● New documentation on toolchains: ● http://wiki.osgi.org/wiki/ToolChains ● Great new book: Enterprise OSGi in Action, Cummins et al
  31. 31. JavaOne Slide Template Title OSGi – Specifications
  32. 32. JavaOne Slide Template Title OSGi Core Specification (R5) ● Modularity layer and Bundle specification ● Services layer ● Service Registry ● Life Cycle layer ● Everything dynamic! add, remove, start, stop, update bundles ● Security layer ● Generic capabilities and requirements model ● … and some low-level building blocks …
  33. 33. OSGi Enterprise Specification (R5) ● Addresses Enterprise use-cases ● Standard Service APIs ● Configuration Config Admin / MetaType specs ● Component models (IoC) Blueprint and Declarative Services ● Eventing Event Admin spec ● Service Distribution ● Remote Services and Remote Service Admin ● Repository specification ● Subsystems (multi-bundle deployment entities) ● JavaEE integration (JTA, JNDI, JPA, JDBC, ...) ● … and more …
  34. 34. OSGi Applied
  35. 35. JavaOne Slide Template Title Demo and Questions ● Online version: http://www.youtube.com/watch?v=S8AI3TqiVk4
  36. 36. JavaOne Slide Template Title References Specs: http://www.osgi.org/Specifications Semantic Versioning White Paper: http://www.osgi.org/wiki/uploads/Links/ SemanticVersioning.pdf Books: Enterprise OSGi in Action (Holly Cummins / Tim Ward) ISBN: 9781617290138 (Nov 2012) early access download: http://www.manning.com/cummins/ OSGi in Action (Richard Hall et al) ISBN: 9781933988917 OSGi in Depth (Alex Alves) ISBN: 9781935182177 Java Application Architecture: Modularity Patterns with Examples using OSGi (Kirk Knoernschild) ISBN: 9780321247131
  37. 37. JavaOne Slide Template Title Image credits ● Images from openclipart.org Cockroach – TrnsltLife Merge Arrow – spongman Buildings – jean_victor_balin Mr Happy – shokunin Boy, Girl, Man – dcatcherex Jigsaw puzzle – Benjamin Pavie Toolkit – bogdanco
  38. 38. JavaOne Slide Template Title Click to add title ● Click to add an outline

×