• Save
OSGi For Eclipse Developers
Upcoming SlideShare
Loading in...5
×
 

OSGi For Eclipse Developers

on

  • 8,023 views

A presentation given at JAX 2009

A presentation given at JAX 2009

Statistics

Views

Total Views
8,023
Slideshare-icon Views on SlideShare
7,554
Embed Views
469

Actions

Likes
17
Downloads
0
Comments
1

14 Embeds 469

http://eclipsesource.com 298
http://curiosidades-java.blogspot.com 51
http://osgilook.com 37
http://www.slideshare.net 32
http://curiosidades-java.blogspot.com.es 15
http://osgilook.wordpress.com 10
http://curiosidades-java.blogspot.mx 9
http://karinajcc.blogspot.com 5
http://curiosidades-java.blogspot.com.ar 4
http://www.linkedin.com 4
http://wellingtondoc.blogspot.com 1
http://translate.googleusercontent.com 1
http://209.85.129.132 1
http://www.eclipsesource.innoopract.com 1
More...

Accessibility

Categories

Upload Details

Uploaded via as Apple Keynote

Usage Rights

© All Rights Reserved

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel

11 of 1

  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Processing…
Post Comment
Edit your comment
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />

OSGi For Eclipse Developers OSGi For Eclipse Developers Presentation Transcript

  • OSGi for Eclipse Developers Chris Aniszczyk (EclipseSource) zx@eclipsesource.com http://twitter.com/caniszczyk Bernd Kolb (SAP) bernd.kolb@sap.com http://twitter.com/berndkolb Martin Lippert (it-agile) lippert@acm.org © 2009 by C. Aniszczyk, B. Kolb | OSGi for Eclipse Developers | April 23rd, 2009
  • Overview • Introduction • Topics Frameworks o Import-Package vs. Require-Bundle o Dynamic Bundles o Versioning o Extensions and Services o Compendium Services o OSGi Tooling o • Conclusion © 2009 by C. Aniszczyk, B. Kolb | OSGi for Eclipse Developers | April 23rd, 2009
  • Introduction • OSGi Alliance Worldwide consortium of technology innovators that advances o OSGi technology • OSGi Technology Set of specifications that define a dynamic component system for o Java OSGi is a lot more than Eclipse • Many Eclipse developers oblivious to OSGi topics • How about starting with a history lesson? © 2009 by C. Aniszczyk, B. Kolb | OSGi for Eclipse Developers | April 23rd, 2009
  • A Blast from the Past... • Eclipse had it's own non-standard plug-in model • OSGi and old Eclipse plug-in model were similar © 2009 by C. Aniszczyk, B. Kolb | OSGi for Eclipse Developers | April 23rd, 2009
  • Eclipse + OSGi FTW • Eclipse went to OSGi in 3.0 with Equinox* The transition went “smoothly” o *http://portal.acm.org/citation.cfm?id=1086616 © 2009 by C. Aniszczyk, B. Kolb | OSGi for Eclipse Developers | April 23rd, 2009
  • © 2009 by C. Aniszczyk, B. Kolb | OSGi for Eclipse Developers | April 23rd, 2009
  • Eclipse folks Plug-In © 2009 by C. Aniszczyk, B. Kolb | OSGi for Eclipse Developers | April 23rd, 2009
  • Eclipse OSGi folks guys Bundle Plug-In © 2009 by C. Aniszczyk, B. Kolb | OSGi for Eclipse Developers | April 23rd, 2009
  • Overview • Introduction • Topics Frameworks o Import-Package vs. Require-Bundle o Dynamic Bundles o Versioning o Extensions and Services o Compendium Services o OSGi Tooling o • Conclusion © 2009 by C. Aniszczyk, B. Kolb | OSGi for Eclipse Developers | April 23rd, 2009
  • Frameworks • There’s a world outside of Eclipse and Equinox © 2009 by C. Aniszczyk, B. Kolb | OSGi for Eclipse Developers | April 23rd, 2009
  • Be aware of special headers… • Forget about: Eclipse-BuddyPolicy o Eclipse-PatchFragment o Eclipse-SourceBundle o Eclipse-… o Otherwise you are tied to Equinox • Tip: PAX Runner to test against multiple frameworks http://wiki.ops4j.org/display/ops4j/Pax+Runner o © 2009 by C. Aniszczyk, B. Kolb | OSGi for Eclipse Developers | April 23rd, 2009
  • Overview • Introduction • Topics Frameworks o Import-Package vs. Require-Bundle o Dynamic Bundles o Versioning o Extensions and Services o Compendium Services o OSGi Tooling o • Conclusion © 2009 by C. Aniszczyk, B. Kolb | OSGi for Eclipse Developers | April 23rd, 2009
  • The Alien called “Import-Package” • Eclipse Dependencies are declared using Require-Bundle o Never heard of Import-Package, sounds strange o Plug-in • OSGi Uuuha, no, please don’t use Require-Bundle at all o o Instead, define dependencies using Import-Package Bundle © 2009 by C. Aniszczyk, B. Kolb | OSGi for Eclipse Developers | April 23rd, 2009
  • What is the difference? • Require-Bundle Imports all exported packages of the bundle, including re- o exported and split bundle packages p-1.0.1 p-1.0.1 q-1.0 q-1.0 t u Require Bundle • Import-Package Import just the package you need o p-1.0 p-1.0.1 q-1.0 q-1.0 t u Import Package © 2009 by C. Aniszczyk, B. Kolb | OSGi for Eclipse Developers | April 23rd, 2009
  • When to use what? • Prefer using Import-Package Lighter coupling between bundles o Less visibilities o Eases refactoring p-1.0.1 o p-1.0 q-1.0 t u q-1.0 • Require-Bundle, when necessary Higher coupling between bundles o Use only for very specific situations: o  split packages (same package in different bundles) © 2009 by C. Aniszczyk, B. Kolb | OSGi for Eclipse Developers | April 23rd, 2009
  • Overview • Introduction • Topics Frameworks o Import-Package vs. Require-Bundle o Dynamic Bundles o Versioning o Extensions and Services o Compendium Services o OSGi Tooling o • Conclusion © 2009 by C. Aniszczyk, B. Kolb | OSGi for Eclipse Developers | April 23rd, 2009
  • Bundles are dynamic? You're kidding… © 2009 by C. Aniszczyk, B. Kolb | OSGi for Eclipse Developers | April 23rd, 2009
  • Dynamics with OSGi • OSGi allows you to manage bundles at runtime Install o Update o Uninstall o • But there is no magic behind the scenes nothing is changed automatically o objects stay the same o references remain valid o • This means you need to cleanup after yourself so the GC can help you! © 2009 by C. Aniszczyk, B. Kolb | OSGi for Eclipse Developers | April 23rd, 2009
  • Updating a bundle at runtime means... • Dependent bundles (with wires to the updated bundle via Require-Bundle or Import-Package) are stopped and re-started • The consequence: updating a bundle might cause the system to “restart” o this is not what I associate with “cool dynamics” o  When programming anticipate OSGi’s dynamics © 2009 by C. Aniszczyk, B. Kolb | OSGi for Eclipse Developers | April 23rd, 2009
  • Think about dependencies • Less is more! Less dependencies o Dependency Inversion Principle (DIP) o • Think more about APIs API in separate bundle o depend only on API bundle o implementation can change o © 2009 by C. Aniszczyk, B. Kolb | OSGi for Eclipse Developers | April 23rd, 2009
  • Overview • Introduction • Topics Frameworks o Import-Package vs. Require-Bundle o Dynamic Bundles o Versioning o Extensions and Services o Compendium Services o OSGi Tooling o • Conclusion © 2009 by C. Aniszczyk, B. Kolb | OSGi for Eclipse Developers | April 23rd, 2009
  • Versioning Guidelines • Bundle-Version: 3.4.2.qualifier  3 - major version  4 - minor version  2 - micro version • From the OSGi specification... • Eclipse Versioning Guidelines  http://wiki.eclipse.org/Version_Numbering © 2009 by C. Aniszczyk, B. Kolb | OSGi for Eclipse Developers | April 23rd, 2009
  • Versioning Bundles • On Bundle level Each Bundle has a version o You should set a version range when using require-bundle o • On Package level Packages should also have a version when exported o o Remember: Import-Package o Package imports should have version ranges as well! • Summary Version everything! o A version isn’t a marketing number! o © 2009 by C. Aniszczyk, B. Kolb | OSGi for Eclipse Developers | April 23rd, 2009
  • Versioning Tools • PDE API Tools  http://www.eclipse.org/pde/pde-api-tools/ • Assists with the mechanics of API evolution Binary compatibility (breaking) issues  API leaks  API freeze issues  Suggestions bundle versions  Runs headless and in your workspace  © 2009 by C. Aniszczyk, B. Kolb | OSGi for Eclipse Developers | April 23rd, 2009
  • Overview • Introduction • Topics Frameworks o Import-Package vs. Require-Bundle o Dynamic Bundles o Versioning o Extensions and Services o Compendium Services o OSGi Tooling o • Conclusion © 2009 by C. Aniszczyk, B. Kolb | OSGi for Eclipse Developers | April 23rd, 2009
  • OSGi Services – another alien… • Services? SOA? Oh no... please no buzzwords!!! • Something like Extension Points? • Hey, wait! o OSGi Services are the key feature to build modular and dynamic apps © 2009 by C. Aniszczyk, B. Kolb | OSGi for Eclipse Developers | April 23rd, 2009
  • OSGi Services – your best friend OSGi Service providers: OSGi Service consumers: implement an interface and register lookup a service via the interface an implementation © 2009 by C. Aniszczyk, B. Kolb | OSGi for Eclipse Developers | April 23rd, 2009
  • Versioned Contracts • the service interface is the contract many consumers possible o many producers possible o • this contract is versioned multiple versions of service might be available o you get only those that matches your dependencies o You cannot get that with extension points singleton bundles − You always get the latest version − © 2009 by C. Aniszczyk, B. Kolb | OSGi for Eclipse Developers | April 23rd, 2009
  • “You come and go” • A bundle is started: services are registered o and available from that on o • A bundle is stopped: services are unregistered o no longer available o • OSGi services are dynamic by definition! + dozens of techniques to deal with these dynamics o © 2009 by C. Aniszczyk, B. Kolb | OSGi for Eclipse Developers | April 23rd, 2009
  • Life Cycle Differences • Services are bound to the ACTIVE state • Extensions are available in RESOLVED state © 2009 by C. Aniszczyk, B. Kolb | OSGi for Eclipse Developers | April 23rd, 2009
  • Declarative and lazy • OSGi services are bound to the active state they need class loading to happen o they need objects to be created o • There are declarative approaches for OSGi services OSGi Declarative Services o OSGi Blueprint o Spring Dynamic Modules o iPOJO o © 2009 by C. Aniszczyk, B. Kolb | OSGi for Eclipse Developers | April 23rd, 2009
  • When to use what? • OSGi Services: Dependencies between bundles o Dynamics o Looser coupling o quot;I provide a service for anybody out therequot; o quot;I need a service and don't care who delivers itquot; o • Extension-Registry: UI contributions (too small for OSGi services) o Non-code contributions o quot;I open up myself for extensions that I don't know upfrontquot; o If you have tons of thousand of extensions o © 2009 by C. Aniszczyk, B. Kolb | OSGi for Eclipse Developers | April 23rd, 2009
  • Overview • Introduction • Topics Frameworks o Import-Package vs. Require-Bundle o Dynamic Bundles o Versioning o Extensions and Services o Compendium Services o OSGi Tooling o • Conclusion © 2009 by C. Aniszczyk, B. Kolb | OSGi for Eclipse Developers | April 23rd, 2009
  • Compendium Services • OSGi has spec’d 20+ services • LogService • EventAdmin • HttpService • Declarative Services • Configuration Admin © 2009 by C. Aniszczyk, B. Kolb | OSGi for Eclipse Developers | April 23rd, 2009
  • LogService • A general purpose message logger (20kb) • LogService Log message, level, exception, service ref, bundle o • LogReaderService Retrieve current or previous log entries o • Note: ExtendedLogService (bug 260672) named loggers o extended log entry (e.g., thread id) o filters for log listeners o © 2009 by C. Aniszczyk, B. Kolb | OSGi for Eclipse Developers | April 23rd, 2009
  • EventAdmin • An inter-bundle pub-sub system (30kb) • EventAdmin publish events synchronously and asynchronously o  postEvent(new Event(quot;com/acme/timerquot;, time ));  sendEvent(new Event(quot;com/acme/timerquot;, time )); • EventHandler handle events based on topics o  handleEvent(Event event) • Event has topic and properties as attributes o © 2009 by C. Aniszczyk, B. Kolb | OSGi for Eclipse Developers | April 23rd, 2009
  • HttpService • A way to register servlets and resources • HttpService Register servlets and resources o • Http Registry (org.eclipse.equinox.http.registry) © 2009 by C. Aniszczyk, B. Kolb | OSGi for Eclipse Developers | April 23rd, 2009
  • Declarative Services • A declarative model for publishing, finding and binding to OSGi services (150kb) • ServiceTracker's – the programmatic way to get a service – suck © 2009 by C. Aniszczyk, B. Kolb | OSGi for Eclipse Developers | April 23rd, 2009
  • Declarative Services Tooling Graphical Editor • Validation • Source Editing • © 2009 by C. Aniszczyk, B. Kolb | OSGi for Eclipse Developers | April 23rd, 2009
  • ConfigAdmin • A service to configure components (bundles) o A configuration is a list of key-value pairs • The configuration admin service persists and distributes these configurations to interested parties • Components to be configured register a ManagedService • To apply several configurations of the same kind you could use a ManagedServiceFactory © 2009 by C. Aniszczyk, B. Kolb | OSGi for Eclipse Developers | April 23rd, 2009
  • Overview • Introduction • Topics Frameworks o Import-Package vs. Require-Bundle o Dynamic Bundles o Versioning o Extensions and Services o Compendium Services o OSGi Tooling o • Conclusion © 2009 by C. Aniszczyk, B. Kolb | OSGi for Eclipse Developers | April 23rd, 2009
  • PDE • Eclipse has been tooling OSGi forever with PDE Plug-ins == Bundles! Blugins? o • PDE Tools: Bundles o Fragments o Declarative Services o • New Plug-in Project wizard has OSGi love © 2009 by C. Aniszczyk, B. Kolb | OSGi for Eclipse Developers | April 23rd, 2009
  • BND • Bundle Tool (BND) creates and diagnoses OSGi bundles o Maven, Eclipse and Ant integration o http://www.aqute.biz/Code/Bnd o • Relies on specification (.bnd file) + classpath • Generates bundle artifacts like manifests • Useful for converting third party libs to bundles © 2009 by C. Aniszczyk, B. Kolb | OSGi for Eclipse Developers | April 23rd, 2009
  • Sigil • Provides OSGi Tooling • http://sigil.codecauldron.org/ • driven by sigil.properties file • BND used under the covers • bundles fetched from repositories  based on your Import-Package statements © 2009 by C. Aniszczyk, B. Kolb | OSGi for Eclipse Developers | April 23rd, 2009
  • © 2009 by C. Aniszczyk, B. Kolb | OSGi for Eclipse Developers | April 23rd, 2009
  • Thank you for your attention! • Questions and feedback welcome! C. Aniszczyk zx@eclipsesource.com http://twitter.com/caniszczyk B. Kolb bernd.kolb@sap.com http://twitter.com/berndkolb M. Lippert (it-agile) lippert@acm.org © 2009 by C. Aniszczyk, B. Kolb | OSGi for Eclipse Developers | April 23rd, 2009