Benefits of OSGi in Practise
Upcoming SlideShare
Loading in...5
×
 

Like this? Share it with your network

Share

Benefits of OSGi in Practise

on

  • 5,381 views

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

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

Statistics

Views

Total Views
5,381
Views on SlideShare
4,688
Embed Views
693

Actions

Likes
8
Downloads
147
Comments
1

8 Embeds 693

http://blog.servidoresdeaplicaciones.com 657
http://devcenter.cloudyle.com 25
https://twitter.com 5
http://www.365dailyjournal.com 2
http://translate.googleusercontent.com 1
http://feedly.com 1
http://www.google.es 1
http://documentation.cloudyle.com 1
More...

Accessibility

Categories

Upload Details

Uploaded via as Adobe PDF

Usage Rights

CC Attribution License

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Processing…
  • 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?
    Are you sure you want to
    Your message goes here
    Processing…
Post Comment
Edit your comment

Benefits of OSGi in Practise Presentation Transcript

  • 1. 1 Benefits of OSGi in Practice David Bosschaert Principal Engineer JBoss/Red Hat OSGi EEG co-chair October 2012
  • 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. JavaOne Slide Template Title Agenda ● Introduction to OSGi ● OSGi Modularity ● OSGi Services ● Specifications ● Demo
  • 4. JavaOne Slide Template Title OSGi a brief introduction
  • 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. 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. OSGi Framework implementations ● The most popular OSGi implementations are open source: ● Eclipse Equinox ● Apache Felix ● JBoss AS 7 ● Knopflerfish ● Commercial implementations also exist
  • 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. JavaOne Slide Template Title OSGi – Modularity
  • 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. 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. 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. 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. JavaOne Slide Template Title OSGi – Services
  • 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. 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. 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. 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. 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. 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. 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. 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. 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. 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. 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. 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. 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. JavaOne Slide Template Title OSGi migration challenges
  • 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. 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. JavaOne Slide Template Title OSGi – Specifications
  • 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. 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. OSGi Applied
  • 35. JavaOne Slide Template Title Demo and Questions ● Online version: http://www.youtube.com/watch?v=S8AI3TqiVk4
  • 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. 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. JavaOne Slide Template Title Click to add title ● Click to add an outline