SlideShare a Scribd company logo
1 of 25
Download to read offline
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
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
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
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
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
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
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
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
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
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!
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
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
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?
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!
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!
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
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
…
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”
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
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
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!
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
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
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?
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

More Related Content

More from mfrancis

Migrating from PDE to Bndtools in Practice - Amit Kumar Mondal (Deutsche Tele...
Migrating from PDE to Bndtools in Practice - Amit Kumar Mondal (Deutsche Tele...Migrating from PDE to Bndtools in Practice - Amit Kumar Mondal (Deutsche Tele...
Migrating from PDE to Bndtools in Practice - Amit Kumar Mondal (Deutsche Tele...
mfrancis
 
How OSGi drives cross-sector energy management - Jörn Tümmler (SMA Solar Tech...
How OSGi drives cross-sector energy management - Jörn Tümmler (SMA Solar Tech...How OSGi drives cross-sector energy management - Jörn Tümmler (SMA Solar Tech...
How OSGi drives cross-sector energy management - Jörn Tümmler (SMA Solar Tech...
mfrancis
 
Improved developer productivity thanks to Maven and OSGi - Lukasz Dywicki (Co...
Improved developer productivity thanks to Maven and OSGi - Lukasz Dywicki (Co...Improved developer productivity thanks to Maven and OSGi - Lukasz Dywicki (Co...
Improved developer productivity thanks to Maven and OSGi - Lukasz Dywicki (Co...
mfrancis
 
Prototyping IoT systems with a hybrid OSGi & Node-RED platform - Bruce Jackso...
Prototyping IoT systems with a hybrid OSGi & Node-RED platform - Bruce Jackso...Prototyping IoT systems with a hybrid OSGi & Node-RED platform - Bruce Jackso...
Prototyping IoT systems with a hybrid OSGi & Node-RED platform - Bruce Jackso...
mfrancis
 
Visualization of OSGi based Software Architectures in Virtual Reality - Lisa ...
Visualization of OSGi based Software Architectures in Virtual Reality - Lisa ...Visualization of OSGi based Software Architectures in Virtual Reality - Lisa ...
Visualization of OSGi based Software Architectures in Virtual Reality - Lisa ...
mfrancis
 
Journey from Monolith to a Modularized Application - Approach and Key Learnin...
Journey from Monolith to a Modularized Application - Approach and Key Learnin...Journey from Monolith to a Modularized Application - Approach and Key Learnin...
Journey from Monolith to a Modularized Application - Approach and Key Learnin...
mfrancis
 

More from mfrancis (20)

Migrating from PDE to Bndtools in Practice - Amit Kumar Mondal (Deutsche Tele...
Migrating from PDE to Bndtools in Practice - Amit Kumar Mondal (Deutsche Tele...Migrating from PDE to Bndtools in Practice - Amit Kumar Mondal (Deutsche Tele...
Migrating from PDE to Bndtools in Practice - Amit Kumar Mondal (Deutsche Tele...
 
OSGi CDI Integration Specification - Ray Augé (Liferay)
OSGi CDI Integration Specification - Ray Augé (Liferay)OSGi CDI Integration Specification - Ray Augé (Liferay)
OSGi CDI Integration Specification - Ray Augé (Liferay)
 
How OSGi drives cross-sector energy management - Jörn Tümmler (SMA Solar Tech...
How OSGi drives cross-sector energy management - Jörn Tümmler (SMA Solar Tech...How OSGi drives cross-sector energy management - Jörn Tümmler (SMA Solar Tech...
How OSGi drives cross-sector energy management - Jörn Tümmler (SMA Solar Tech...
 
Improved developer productivity thanks to Maven and OSGi - Lukasz Dywicki (Co...
Improved developer productivity thanks to Maven and OSGi - Lukasz Dywicki (Co...Improved developer productivity thanks to Maven and OSGi - Lukasz Dywicki (Co...
Improved developer productivity thanks to Maven and OSGi - Lukasz Dywicki (Co...
 
It Was Twenty Years Ago Today - Building an OSGi based Smart Home System - Ch...
It Was Twenty Years Ago Today - Building an OSGi based Smart Home System - Ch...It Was Twenty Years Ago Today - Building an OSGi based Smart Home System - Ch...
It Was Twenty Years Ago Today - Building an OSGi based Smart Home System - Ch...
 
Popular patterns revisited on OSGi - Christian Schneider (Adobe)
Popular patterns revisited on OSGi - Christian Schneider (Adobe)Popular patterns revisited on OSGi - Christian Schneider (Adobe)
Popular patterns revisited on OSGi - Christian Schneider (Adobe)
 
Integrating SLF4J and the new OSGi LogService 1.4 - BJ Hargrave (IBM)
Integrating SLF4J and the new OSGi LogService 1.4 - BJ Hargrave (IBM)Integrating SLF4J and the new OSGi LogService 1.4 - BJ Hargrave (IBM)
Integrating SLF4J and the new OSGi LogService 1.4 - BJ Hargrave (IBM)
 
OSG(a)i: because AI needs a runtime - Tim Verbelen (imec)
OSG(a)i: because AI needs a runtime - Tim Verbelen (imec)OSG(a)i: because AI needs a runtime - Tim Verbelen (imec)
OSG(a)i: because AI needs a runtime - Tim Verbelen (imec)
 
Flying to Jupiter with OSGi - Tony Walsh (ESA) & Hristo Indzhov (Telespazio V...
Flying to Jupiter with OSGi - Tony Walsh (ESA) & Hristo Indzhov (Telespazio V...Flying to Jupiter with OSGi - Tony Walsh (ESA) & Hristo Indzhov (Telespazio V...
Flying to Jupiter with OSGi - Tony Walsh (ESA) & Hristo Indzhov (Telespazio V...
 
MicroProfile, OSGi was meant for this - Ray Auge (Liferay)
MicroProfile, OSGi was meant for this - Ray Auge (Liferay)MicroProfile, OSGi was meant for this - Ray Auge (Liferay)
MicroProfile, OSGi was meant for this - Ray Auge (Liferay)
 
Prototyping IoT systems with a hybrid OSGi & Node-RED platform - Bruce Jackso...
Prototyping IoT systems with a hybrid OSGi & Node-RED platform - Bruce Jackso...Prototyping IoT systems with a hybrid OSGi & Node-RED platform - Bruce Jackso...
Prototyping IoT systems with a hybrid OSGi & Node-RED platform - Bruce Jackso...
 
How to connect your OSGi application - Dirk Fauth (Bosch)
How to connect your OSGi application - Dirk Fauth (Bosch)How to connect your OSGi application - Dirk Fauth (Bosch)
How to connect your OSGi application - Dirk Fauth (Bosch)
 
Visualization of OSGi based Software Architectures in Virtual Reality - Lisa ...
Visualization of OSGi based Software Architectures in Virtual Reality - Lisa ...Visualization of OSGi based Software Architectures in Virtual Reality - Lisa ...
Visualization of OSGi based Software Architectures in Virtual Reality - Lisa ...
 
Turtles all the Way Up – From OSGi bundles to Fog Computing - Tim Ward (Paremus)
Turtles all the Way Up – From OSGi bundles to Fog Computing - Tim Ward (Paremus)Turtles all the Way Up – From OSGi bundles to Fog Computing - Tim Ward (Paremus)
Turtles all the Way Up – From OSGi bundles to Fog Computing - Tim Ward (Paremus)
 
OSGi in Action - How we use OSGi to build Open Liberty - Alasdair Nottingham ...
OSGi in Action - How we use OSGi to build Open Liberty - Alasdair Nottingham ...OSGi in Action - How we use OSGi to build Open Liberty - Alasdair Nottingham ...
OSGi in Action - How we use OSGi to build Open Liberty - Alasdair Nottingham ...
 
Software AG Application Modularity - OSGi and JPMS (Jigsaw)
Software AG Application Modularity - OSGi and JPMS (Jigsaw)Software AG Application Modularity - OSGi and JPMS (Jigsaw)
Software AG Application Modularity - OSGi and JPMS (Jigsaw)
 
Journey from Monolith to a Modularized Application - Approach and Key Learnin...
Journey from Monolith to a Modularized Application - Approach and Key Learnin...Journey from Monolith to a Modularized Application - Approach and Key Learnin...
Journey from Monolith to a Modularized Application - Approach and Key Learnin...
 
Eclipse microprofile config and OSGi config admin - E Jiang
Eclipse microprofile config and OSGi config admin - E JiangEclipse microprofile config and OSGi config admin - E Jiang
Eclipse microprofile config and OSGi config admin - E Jiang
 
Smart IoTt on OSGi with Apache Openwhisk - C Ziegeler & D Bosschaert
Smart IoTt on OSGi with Apache Openwhisk - C Ziegeler & D BosschaertSmart IoTt on OSGi with Apache Openwhisk - C Ziegeler & D Bosschaert
Smart IoTt on OSGi with Apache Openwhisk - C Ziegeler & D Bosschaert
 
When whiteboards play together. JAX-RS and servlets the OSGi way - M Hoffmann...
When whiteboards play together. JAX-RS and servlets the OSGi way - M Hoffmann...When whiteboards play together. JAX-RS and servlets the OSGi way - M Hoffmann...
When whiteboards play together. JAX-RS and servlets the OSGi way - M Hoffmann...
 

Recently uploaded

Hyatt driving innovation and exceptional customer experiences with FIDO passw...
Hyatt driving innovation and exceptional customer experiences with FIDO passw...Hyatt driving innovation and exceptional customer experiences with FIDO passw...
Hyatt driving innovation and exceptional customer experiences with FIDO passw...
FIDO Alliance
 
Easier, Faster, and More Powerful – Alles Neu macht der Mai -Wir durchleuchte...
Easier, Faster, and More Powerful – Alles Neu macht der Mai -Wir durchleuchte...Easier, Faster, and More Powerful – Alles Neu macht der Mai -Wir durchleuchte...
Easier, Faster, and More Powerful – Alles Neu macht der Mai -Wir durchleuchte...
panagenda
 
Harnessing Passkeys in the Battle Against AI-Powered Cyber Threats.pptx
Harnessing Passkeys in the Battle Against AI-Powered Cyber Threats.pptxHarnessing Passkeys in the Battle Against AI-Powered Cyber Threats.pptx
Harnessing Passkeys in the Battle Against AI-Powered Cyber Threats.pptx
FIDO Alliance
 
CORS (Kitworks Team Study 양다윗 발표자료 240510)
CORS (Kitworks Team Study 양다윗 발표자료 240510)CORS (Kitworks Team Study 양다윗 발표자료 240510)
CORS (Kitworks Team Study 양다윗 발표자료 240510)
Wonjun Hwang
 

Recently uploaded (20)

AI+A11Y 11MAY2024 HYDERBAD GAAD 2024 - HelloA11Y (11 May 2024)
AI+A11Y 11MAY2024 HYDERBAD GAAD 2024 - HelloA11Y (11 May 2024)AI+A11Y 11MAY2024 HYDERBAD GAAD 2024 - HelloA11Y (11 May 2024)
AI+A11Y 11MAY2024 HYDERBAD GAAD 2024 - HelloA11Y (11 May 2024)
 
JavaScript Usage Statistics 2024 - The Ultimate Guide
JavaScript Usage Statistics 2024 - The Ultimate GuideJavaScript Usage Statistics 2024 - The Ultimate Guide
JavaScript Usage Statistics 2024 - The Ultimate Guide
 
UiPath manufacturing technology benefits and AI overview
UiPath manufacturing technology benefits and AI overviewUiPath manufacturing technology benefits and AI overview
UiPath manufacturing technology benefits and AI overview
 
Simplifying Mobile A11y Presentation.pptx
Simplifying Mobile A11y Presentation.pptxSimplifying Mobile A11y Presentation.pptx
Simplifying Mobile A11y Presentation.pptx
 
Hyatt driving innovation and exceptional customer experiences with FIDO passw...
Hyatt driving innovation and exceptional customer experiences with FIDO passw...Hyatt driving innovation and exceptional customer experiences with FIDO passw...
Hyatt driving innovation and exceptional customer experiences with FIDO passw...
 
Introduction to use of FHIR Documents in ABDM
Introduction to use of FHIR Documents in ABDMIntroduction to use of FHIR Documents in ABDM
Introduction to use of FHIR Documents in ABDM
 
Easier, Faster, and More Powerful – Alles Neu macht der Mai -Wir durchleuchte...
Easier, Faster, and More Powerful – Alles Neu macht der Mai -Wir durchleuchte...Easier, Faster, and More Powerful – Alles Neu macht der Mai -Wir durchleuchte...
Easier, Faster, and More Powerful – Alles Neu macht der Mai -Wir durchleuchte...
 
WebRTC and SIP not just audio and video @ OpenSIPS 2024
WebRTC and SIP not just audio and video @ OpenSIPS 2024WebRTC and SIP not just audio and video @ OpenSIPS 2024
WebRTC and SIP not just audio and video @ OpenSIPS 2024
 
Harnessing Passkeys in the Battle Against AI-Powered Cyber Threats.pptx
Harnessing Passkeys in the Battle Against AI-Powered Cyber Threats.pptxHarnessing Passkeys in the Battle Against AI-Powered Cyber Threats.pptx
Harnessing Passkeys in the Battle Against AI-Powered Cyber Threats.pptx
 
Vector Search @ sw2con for slideshare.pptx
Vector Search @ sw2con for slideshare.pptxVector Search @ sw2con for slideshare.pptx
Vector Search @ sw2con for slideshare.pptx
 
Human Expert Website Manual WCAG 2.0 2.1 2.2 Audit - Digital Accessibility Au...
Human Expert Website Manual WCAG 2.0 2.1 2.2 Audit - Digital Accessibility Au...Human Expert Website Manual WCAG 2.0 2.1 2.2 Audit - Digital Accessibility Au...
Human Expert Website Manual WCAG 2.0 2.1 2.2 Audit - Digital Accessibility Au...
 
Six Myths about Ontologies: The Basics of Formal Ontology
Six Myths about Ontologies: The Basics of Formal OntologySix Myths about Ontologies: The Basics of Formal Ontology
Six Myths about Ontologies: The Basics of Formal Ontology
 
AI mind or machine power point presentation
AI mind or machine power point presentationAI mind or machine power point presentation
AI mind or machine power point presentation
 
Generative AI Use Cases and Applications.pdf
Generative AI Use Cases and Applications.pdfGenerative AI Use Cases and Applications.pdf
Generative AI Use Cases and Applications.pdf
 
Portal Kombat : extension du réseau de propagande russe
Portal Kombat : extension du réseau de propagande russePortal Kombat : extension du réseau de propagande russe
Portal Kombat : extension du réseau de propagande russe
 
Introduction to FIDO Authentication and Passkeys.pptx
Introduction to FIDO Authentication and Passkeys.pptxIntroduction to FIDO Authentication and Passkeys.pptx
Introduction to FIDO Authentication and Passkeys.pptx
 
JohnPollard-hybrid-app-RailsConf2024.pptx
JohnPollard-hybrid-app-RailsConf2024.pptxJohnPollard-hybrid-app-RailsConf2024.pptx
JohnPollard-hybrid-app-RailsConf2024.pptx
 
CORS (Kitworks Team Study 양다윗 발표자료 240510)
CORS (Kitworks Team Study 양다윗 발표자료 240510)CORS (Kitworks Team Study 양다윗 발표자료 240510)
CORS (Kitworks Team Study 양다윗 발표자료 240510)
 
Continuing Bonds Through AI: A Hermeneutic Reflection on Thanabots
Continuing Bonds Through AI: A Hermeneutic Reflection on ThanabotsContinuing Bonds Through AI: A Hermeneutic Reflection on Thanabots
Continuing Bonds Through AI: A Hermeneutic Reflection on Thanabots
 
Event-Driven Architecture Masterclass: Challenges in Stream Processing
Event-Driven Architecture Masterclass: Challenges in Stream ProcessingEvent-Driven Architecture Masterclass: Challenges in Stream Processing
Event-Driven Architecture Masterclass: Challenges in Stream Processing
 

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

  • 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. 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. 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. 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. 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. 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. 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. 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. 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. 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. 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. 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. 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. 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. 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. 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. 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. 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. 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. 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. 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. 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. 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. 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. 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