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.

OSGi enRoute for R7 – getting started the easy way! - Tim Ward (Paremus)

75 views

Published on

OSGi Community Event 2018 presentation by Tim Ward (Paremus)

Abstract: Developing OSGi applications is considered by many to be a black art. People talk about PDE, target platforms, bnd workspaces, and all sorts of things that non OSGi developers have never even heard of, let alone used! Understandably this has given the impression that OSGi is hard to use, but the secret is that OSGi is easy!

The OSGi enRoute project was created by the OSGi Alliance as a tool for non OSGi developers who want to get started with OSGi. It therefore provides templates, examples, and a development model that will be familiar to almost every Java developer. With the release of OSGi R7 now complete this has enabled a rich, flexible selection of APIs and implementations just waiting for you to pick them up and get going.

This talk is primarily aimed at those with little previous OSGi experience, but even experienced developers will learn something new! I will describe the three main pieces of the OSGi enRoute project, and how they work together to provide a simple, effective development experience. The talk will also demonstrate using the OSGi enRoute project to develop a simple microservice application.

Published in: Technology
  • Be the first to comment

OSGi enRoute for R7 – getting started the easy way! - Tim Ward (Paremus)

  1. 1. Copyright © 2018 Paremus Ltd. May not be reproduced by any means without express permission. All rights reserved. OSGi enRoute Quickstart - A Beginners Guide to OSGi October 2018 Tim Ward
 tim.ward@paremus.com OSGi enRoute Quickstart - A Beginners Guide to OSGi
  2. 2. Copyright © 2018 Paremus Ltd. May not be reproduced by any means without express permission. All rights reserved. OSGi enRoute Quickstart - A Beginners Guide to OSGi October 2018 Who is Tim Ward? Chief Technology Officer at Paremus 10 years developing OSGi specifications Co-chair of the OSGi IoT Expert Group Interested in Asynchronous Distributed Systems Author of Manning’s Enterprise OSGi in Action http://www.manning.com/cummins @TimothyWard
  3. 3. Copyright © 2018 Paremus Ltd. May not be reproduced by any means without express permission. All rights reserved. OSGi enRoute Quickstart - A Beginners Guide to OSGi October 2018 OSGi Modularity in 60 seconds
  4. 4. Copyright © 2018 Paremus Ltd. May not be reproduced by any means without express permission. All rights reserved. OSGi enRoute Quickstart - A Beginners Guide to OSGi October 2018 OSGi Modules OSGi is a modularity framework for Java The Modules are JAR files known as “Bundles” Bundles have private internal code Shared packages must be exported Exported packages must be imported to be accessible org.a.api org.a.api org.b.impl
  5. 5. Copyright © 2018 Paremus Ltd. May not be reproduced by any means without express permission. All rights reserved. OSGi enRoute Quickstart - A Beginners Guide to OSGi October 2018 OSGi Modules (2) The metadata for a bundle lives in the Manifest The manifest headers define: A name for the bundle A version for the bundle The imported/exported packages for the bundle Other requirements/capabilities Getting the Manifest correct is vitally important
  6. 6. Copyright © 2018 Paremus Ltd. May not be reproduced by any means without express permission. All rights reserved. OSGi enRoute Quickstart - A Beginners Guide to OSGi October 2018 OSGi Services OSGi Bundles communicate using the Service Registry This allows for dynamic, loosely coupled interaction Consumer Provider B Provider A
  7. 7. Copyright © 2018 Paremus Ltd. May not be reproduced by any means without express permission. All rights reserved. OSGi enRoute Quickstart - A Beginners Guide to OSGi October 2018 OSGi Services OSGi Services are dynamic They can come and go at any time OSGi services may depend on other services You must unregister if your dependency unregisters One change can cascade across lots of modules Failing to use services properly gives poor quality bundles
  8. 8. Copyright © 2018 Paremus Ltd. May not be reproduced by any means without express permission. All rights reserved. OSGi enRoute Quickstart - A Beginners Guide to OSGi October 2018 Developing for OSGi
  9. 9. Copyright © 2018 Paremus Ltd. May not be reproduced by any means without express permission. All rights reserved. OSGi enRoute Quickstart - A Beginners Guide to OSGi October 2018 Developing bundles Ok, so that took more than 60 seconds… Developing bundles involves writing Java code as normal Then you have to get the Manifest correct Do you really know all the packages you use in your code? If you’re using services then you must listen for them Failure to do so leads to start up ordering concerns
  10. 10. Copyright © 2018 Paremus Ltd. May not be reproduced by any means without express permission. All rights reserved. OSGi enRoute Quickstart - A Beginners Guide to OSGi October 2018 That sounds like a nightmare!
  11. 11. Copyright © 2018 Paremus Ltd. May not be reproduced by any means without express permission. All rights reserved. OSGi enRoute Quickstart - A Beginners Guide to OSGi October 2018 The reason for OSGi enRoute When people start to use OSGi for the first time… They look at the core specification (not a bad idea) They get as far as “Bundle-Activator” and then stop 😞 The compendium specification contains many vital things They look for examples on the internet Some examples are very old, or just not very good! Hand writing a manifest file is never a good idea
  12. 12. Copyright © 2018 Paremus Ltd. May not be reproduced by any means without express permission. All rights reserved. OSGi enRoute Quickstart - A Beginners Guide to OSGi October 2018 The reason for OSGi enRoute (2) There are lots of good tools for writing OSGi bundles They are often not well documented, and set up is rarely trivial The latest OSGi specs are much more user friendly Annotation driven services, requirements, capabilities We need a go-to place which demonstrates OSGi best practices A familiar toolchain Worked examples using the OSGi compendium
  13. 13. Copyright © 2018 Paremus Ltd. May not be reproduced by any means without express permission. All rights reserved. OSGi enRoute Quickstart - A Beginners Guide to OSGi October 2018 So what is OSGi enRoute?
  14. 14. Copyright © 2018 Paremus Ltd. May not be reproduced by any means without express permission. All rights reserved. OSGi enRoute Quickstart - A Beginners Guide to OSGi October 2018 The anatomy of OSGi enRoute OSGi enRoute is a GitHub project using Maven OSGi enRoute provides four things for users 1. Example Projects 2. Maven Project Templates (Archetypes) 3. Usefully curated OSGi Indexes/Maven dependencies 4. A Website describing how to use all of these things!
  15. 15. Copyright © 2018 Paremus Ltd. May not be reproduced by any means without express permission. All rights reserved. OSGi enRoute Quickstart - A Beginners Guide to OSGi October 2018 Why is OSGi enRoute using Maven Because it’s the right choice! Some people love Maven, and some people hate it But pretty much everyone knows how to use it! OSGi enRoute isn’t a build tool tutorial Deliberately use the most common tool Fit in with established layouts and patterns Allow users to continue using all of their other tools/plugins Importantly, there are plugins from bnd to do all the hard work!
  16. 16. Copyright © 2018 Paremus Ltd. May not be reproduced by any means without express permission. All rights reserved. OSGi enRoute Quickstart - A Beginners Guide to OSGi October 2018 The OSGi enRoute examples OSGi enRoute provides examples using the Compendium JAX-RS whiteboard microservices Transaction Control based Data Access Using JPA or JDBC! Using and Customising the OSGi Converter Each example is provided with a guide to the key points All bundle metadata and services automatically managed
  17. 17. Copyright © 2018 Paremus Ltd. May not be reproduced by any means without express permission. All rights reserved. OSGi enRoute Quickstart - A Beginners Guide to OSGi October 2018 The OSGi enRoute archetypes Archetypes are a fancy Maven name for project templates They can be published to repositories, and used via Maven tools There are lots of different enRoute archetypes Setting up a new build Creating an API bundle Creating a JAX-RS microservice bundle Integration testing Wrapping up a runnable application …
  18. 18. Copyright © 2018 Paremus Ltd. May not be reproduced by any means without express permission. All rights reserved. OSGi enRoute Quickstart - A Beginners Guide to OSGi October 2018 The OSGi enRoute indexes In some ways these seem less important They’re actually the basis for everything else! A key problem when starting OSGi is finding stuff And what you do find can be of questionable quality The indexes wrap up groups of useful dependencies They include reference implementations of OSGi specifications All of the contents are vetted for “good OSGi packaging”
  19. 19. Copyright © 2018 Paremus Ltd. May not be reproduced by any means without express permission. All rights reserved. OSGi enRoute Quickstart - A Beginners Guide to OSGi October 2018 The OSGi enRoute website Available at https://enroute.osgi.org Contributions can be made on GitHub (osgi/osgi.enroute.site) The primary goal of the website is to explain the examples Several examples have step-by-step tutorials All of the tutorials can be run from the command line Optional instructions show how to use the Eclipse IDE The website also provides basic background and FAQs
  20. 20. Copyright © 2018 Paremus Ltd. May not be reproduced by any means without express permission. All rights reserved. OSGi enRoute Quickstart - A Beginners Guide to OSGi October 2018 Using OSGi enRoute
  21. 21. Copyright © 2018 Paremus Ltd. May not be reproduced by any means without express permission. All rights reserved. OSGi enRoute Quickstart - A Beginners Guide to OSGi October 2018 How to use OSGi enRoute It’s been 15 slides since the last picture… You’ve all done very well 😊 The purpose of enRoute is to be quick and easy So the best way to explain it is to use it!
  22. 22. Copyright © 2018 Paremus Ltd. May not be reproduced by any means without express permission. All rights reserved. OSGi enRoute Quickstart - A Beginners Guide to OSGi October 2018 Switch to Eclipse
  23. 23. Copyright © 2018 Paremus Ltd. May not be reproduced by any means without express permission. All rights reserved. OSGi enRoute Quickstart - A Beginners Guide to OSGi October 2018 Evaluate the Sessions -1 0 +1 Sign in and vote at eclipsecon.org
  24. 24. Copyright © 2018 Paremus Ltd. May not be reproduced by any means without express permission. All rights reserved. OSGi enRoute Quickstart - A Beginners Guide to OSGi October 2018 Questions?
  25. 25. Copyright © 2018 Paremus Ltd. May not be reproduced by any means without express permission. All rights reserved. OSGi enRoute Quickstart - A Beginners Guide to OSGi October 2018 www.paremus.com @Paremus info@paremus.com

×