Your SlideShare is downloading. ×
0
OSGi overview
OSGi overview
OSGi overview
OSGi overview
OSGi overview
OSGi overview
OSGi overview
OSGi overview
OSGi overview
OSGi overview
OSGi overview
OSGi overview
OSGi overview
OSGi overview
OSGi overview
OSGi overview
OSGi overview
OSGi overview
OSGi overview
OSGi overview
OSGi overview
OSGi overview
OSGi overview
OSGi overview
OSGi overview
OSGi overview
OSGi overview
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 overview

741

Published on

0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total Views
741
On Slideshare
0
From Embeds
0
Number of Embeds
0
Actions
Shares
0
Downloads
16
Comments
0
Likes
0
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

Transcript

  • 1. OSGi Overview Presenter: Alex ProcaBJUG - 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 GoodDifferent 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

×