SlideShare une entreprise Scribd logo
1  sur  55
Télécharger pour lire hors ligne
Copyright © 2005 - 2013 Paremus Ltd.
May not be reproduced by any means without express permission. All rights reserved.
Paremus Packager March 2013
Cook Up a Runtime with the OSGi Resolver
Neil Bartlett - Paremus
neil.bartlett@paremus.com
Friday, 29 March 13
Problem Statement (1)
Friday, 29 March 13
OSGi
“The Framework that Likes
to Say...”
Friday, 29 March 13
NOYOU CAN’T
Friday, 29 March 13
NO YOU CAN’T
• Example: missing import: org.wtf.
• Google for org.wtf, find that it’s part of bundle
com.acme.fml
• Download and install com.acme.fml, now you have
more missing imports: org.thingummy,
javax.whatever (version 3.0.2.SNAPSHOT).
• Go round again... and again... and again...
Friday, 29 March 13
THIS IS NOT A JOB
FOR HUMAN BEANS
Friday, 29 March 13
Problem Statement (2)
Friday, 29 March 13
NOTHING’S HAPPENING!
Friday, 29 March 13
Nothing’s Happening
• Oh you’re using Declarative Services! Did you
remember to include org.apache.felix.scr?
• Oh you’re using Blueprint. Did you remember to
include org.apache.aries.blueprint?
• Oh you’re using JPA. Did you remember to include
org.eclipse.gemini.jpa?
Friday, 29 March 13
Extender/Whiteboard
• NO direct/static dependency
• Dependency is implicit: without the extender, nothing
happens.
• NO diagnostic error messages
Friday, 29 March 13
Not Really Solutions
• Deployment Admin Packages
• Eclipse Features
• Virgo Plans/PARs
• Karaf KARs/Features
• etc...
Friday, 29 March 13
OSGi Release 5
Friday, 29 March 13
OSGi Release 5
• Released April 2012
• New Specification: Resolver and Repository
Friday, 29 March 13
Repositories
Friday, 29 March 13
Simple API!
public interface Repository {
Map<Requirement, Collection<Capability>> findProviders(
Collection<? extends Requirement> requirements);
}
Friday, 29 March 13
Repository
• Can return Resources from anywhere
• Should have knowledge of capabilities and
requirements of the resources it manages
• Database? XML file? Just an implementation detail.
Friday, 29 March 13
XML Index Format
<repository name='Local' xmlns='http://www.osgi.org/xmlns/repository/v1.0.0'>
<resource>
<capability namespace='osgi.identity'>
<attribute name='osgi.identity' value='org.apache.felix.gogo.runtime'/>
<attribute name='type' value='osgi.bundle'/>
<attribute name='version' type='Version' value='0.10.0'/>
</capability>
<capability namespace='osgi.content'>
<attribute name='osgi.content'
value='15e94961ae2d0046278686965fe6a34ad43d8d18719f5bc2304e725cdb57a379'/>
<attribute name='url' value='org.apache.felix.gogo.runtime/
org.apache.felix.gogo.runtime-0.10.0.jar'/>
<attribute name='size' type='Long' value='66965'/>
<attribute name='mime' value='application/vnd.osgi.bundle'/>
</capability>
<capability namespace='osgi.wiring.package'>
<attribute name='osgi.wiring.package' value='org.apache.felix.service.command'/>
<attribute name='version' type='Version' value='0.10.0'/>
<attribute name='status' value='provisional'/>
<attribute name='bundle-symbolic-name' value='org.apache.felix.gogo.runtime'/>
<attribute name='bundle-version' type='Version' value='0.10.0'/>
<directive name='mandatory' value='status'/>
</capability>
...
Friday, 29 March 13
Generating an Index
• RepoIndex: https://github.com/osgi/bindex
• Standalone library, also command line,ANT, OSGi
service, etc.
Friday, 29 March 13
Repository Implementations
• RI from Red Hat: github.com/jbosgi/jbosgi-repository
• bnd “Fixed Indexed Repo”
• Just needs a URI to an index
• bnd “Local Indexed Repo”
• Mutable, based on local file-system folder
• Automatically reindexes on deploy
Friday, 29 March 13
Resolver
Friday, 29 March 13
Simple API!
public interface Resolver {
Map<Resource, List<Wire>> resolve(ResolveContext context)
throws ResolutionException;
}
Friday, 29 March 13
Resolver Result
• Returns a Delta: new Resources, new Wires
• Can be used by OSGi Framework
• Use outside OSGi to discover resources
Friday, 29 March 13
DO NOT IMPLEMENT
• Implementing a Resolver is HARD
• Resolver is very generic.You almost certainly don’t
NEED to implement your own
Friday, 29 March 13
Resolver Implementation
• Just One: The RI from Apache Felix
• Used in Felix Framework
• Soon to be used in Equinox Framework
• Used by Subsystems Specification
• Used by Bnd(tools)
• Soon to be used in Paremus Nimble
Friday, 29 March 13
So the Resolver talks to the
Repository, right?
Friday, 29 March 13
WRONG
• Resolver has no knowledge of any Repository.
Friday, 29 March 13
At least it knows about current
Bundles and Wires, right?
Friday, 29 March 13
WRONG
• Resolver has no knowledge of existing state.
Friday, 29 March 13
Resolver is Clueless!
• Resolver just finds a solution to a puzzle
• The inputs to the puzzle depend on us: the Resolve
Context
Friday, 29 March 13
Resolve Context
Friday, 29 March 13
Resolve Context
• Implemented by Resolver clients. I.e., us!
• Guides the resolver.
Friday, 29 March 13
Not So Simple API!
public abstract class ResolveContext {
	 public Collection<Resource> getMandatoryResources() {
	 	 return emptyCollection();
	 }
	 public Collection<Resource> getOptionalResources() {
	 	 return emptyCollection();
	 }
	 public abstract Map<Resource, Wiring> getWirings();
	 public abstract List<Capability> findProviders(Requirement requirement);
	 public abstract boolean isEffective(Requirement requirement);
	 public abstract int insertHostedCapability(List<Capability> capabilities,
HostedCapability hostedCapability);
}
Friday, 29 March 13
getMandatoryResources()
• This is our starting point
• List of resources that must be present in the result
• Bndtools creates a single dummy Resource containing
the input Requirements
Friday, 29 March 13
getOptionalResources()
• List of resources we hope will be present in the result
• Failure to resolve one of these doesn’t break the whole
resolution
Friday, 29 March 13
getWirings()
• Map of existing resolved resources and their wires
• Inside OSGi, this is the already resolved bundles
• In Bndtools this is empty
Friday, 29 March 13
findProviders()
• Here’s the meat!
• The Resolver wants to resolve a requirement...
• ... asks us to find the candidate Capabilities to satisfy it
• We return a ranked collection of Capabilities
• Typically we talk to our Repositories
• Resolver tries to use the highest ranked candidate, but
no promises.
Friday, 29 March 13
GOTCHA
• Don’t go to Repositories for JRE packages etc.
• Always check system bundle capabilities first.
• Some Resources have “self-requirements”, e.g.
importing package exported by same bundle.
• Always check first if the resource’s own capabilities
satisfy the requirement
Friday, 29 March 13
isEffective()
• Decide whether to ignore the Requirement
Friday, 29 March 13
insertHostedCapability()
• Oh Mummy...
• Insert fragment capabilities into the list returned by
findProviders(), at the correct position
• More proof that fragments are horrible.
Friday, 29 March 13
Implementations
• Felix and Equinox Frameworks
• BndrunResolveContext in bnd project takes a .bndrun
file as input
Friday, 29 March 13
DEMO
Friday, 29 March 13
Requirement “Effectiveness”
Friday, 29 March 13
Effective
• Some requirements are “effective” at different times
• E.g.: Require-Capability: osgi.service;filter:=...
• Should Not block resolution by the OSGi
Framework
•Should guide OBR/Nimble/Bndtools to add a provider
to the result
Friday, 29 March 13
Effective
Require-Capability: osgi.service; 
filter:="(objectClass=org.example.exchange.api.Exchange)"; 
effective:=active
Friday, 29 March 13
Effective
• Requirements are only effective in OSGi Framework
resolution if effective == “resolve”
• ... but “resolve” is the default, so omitting the
“effective:” directive also works.
• Other Resolve Contexts (e.g. Bndtools) can decide by
implementing isEffective(Requirement).
Friday, 29 March 13
effective:=active
• No value for “effective:” is defined by OSGi other than
“resolve”
• “active” is a convention for requirements that apply to
active bundles.
• E.g.: extenders, whiteboard, services, etc
Friday, 29 March 13
Open Questions
Friday, 29 March 13
Choice
• Your app requires a Web container, e.g.
osgi.extender;filter:=“(osgi.extender
=osgi.wab)”
• Tomcat and Jetty are both available.
• It only makes sense to have one! How do we decide?
Friday, 29 March 13
Choice
• It’s all down to ResolveContext.findProviders()
• Ranked preference, Resolver tries to pick highest.
• Or we return just one.
Friday, 29 March 13
Current State-of-the-Art
• “Repository Path”
• Resources from earlier repos are preferred over later
repos.
• Forces us to have many, granular repos.
• Probably won’t scale.
Friday, 29 March 13
Future?
• Interactive Resolve.
• Ask the user, but cache the answer (...for how long?)
• Policies
• “Prefer Jetty over Tomcat”
• Repository Filters
Friday, 29 March 13
Conclusion
Friday, 29 March 13
What is an Application??
• A small number of bundles defining the high-level
functionality.
• All of the dependencies of the above.
• Curate your top-level bundles.
•Generate your dependency lists.
Friday, 29 March 13
Caution
• When should we resolve?
• The result can change if repo contents change!
• Resolve => Test => Resolve => Deploy to Prod... bang!
• WYTIWYR
• Persist your resolution result.
Friday, 29 March 13
Thank YouThank You
Friday, 29 March 13

Contenu connexe

Tendances

Migrating existing Projects to Wonder
Migrating existing Projects to WonderMigrating existing Projects to Wonder
Migrating existing Projects to Wonder
WO Community
 

Tendances (9)

Webinar: MongoDB Persistence with Java and Morphia
Webinar: MongoDB Persistence with Java and MorphiaWebinar: MongoDB Persistence with Java and Morphia
Webinar: MongoDB Persistence with Java and Morphia
 
Migrating existing Projects to Wonder
Migrating existing Projects to WonderMigrating existing Projects to Wonder
Migrating existing Projects to Wonder
 
Opening up the Social Web - Standards that are bridging the Islands
Opening up the Social Web - Standards that are bridging the Islands Opening up the Social Web - Standards that are bridging the Islands
Opening up the Social Web - Standards that are bridging the Islands
 
My sql tutorial-oscon-2012
My sql tutorial-oscon-2012My sql tutorial-oscon-2012
My sql tutorial-oscon-2012
 
Generators: The Final Frontier
Generators: The Final FrontierGenerators: The Final Frontier
Generators: The Final Frontier
 
MongoDB on Rails (and Ruby)
MongoDB on Rails (and Ruby)MongoDB on Rails (and Ruby)
MongoDB on Rails (and Ruby)
 
Exploring Clojurescript
Exploring ClojurescriptExploring Clojurescript
Exploring Clojurescript
 
Not Only Drupal
Not Only DrupalNot Only Drupal
Not Only Drupal
 
Pragmatische Plone Projekte
Pragmatische Plone ProjektePragmatische Plone Projekte
Pragmatische Plone Projekte
 

En vedette

The ultimate dependency manager shoot out - X Uiterlinden & S Mak
The ultimate dependency manager shoot out - X Uiterlinden & S MakThe ultimate dependency manager shoot out - X Uiterlinden & S Mak
The ultimate dependency manager shoot out - X Uiterlinden & S Mak
mfrancis
 

En vedette (6)

The ultimate dependency manager shoot out - X Uiterlinden & S Mak
The ultimate dependency manager shoot out - X Uiterlinden & S MakThe ultimate dependency manager shoot out - X Uiterlinden & S Mak
The ultimate dependency manager shoot out - X Uiterlinden & S Mak
 
OSGi Specification Evolution - BJ Hargrave
OSGi Specification Evolution - BJ HargraveOSGi Specification Evolution - BJ Hargrave
OSGi Specification Evolution - BJ Hargrave
 
Distributed Eventing in OSGi - Carsten Ziegeler
Distributed Eventing in OSGi - Carsten ZiegelerDistributed Eventing in OSGi - Carsten Ziegeler
Distributed Eventing in OSGi - Carsten Ziegeler
 
Location Provider with Privacy Using Localized Server and GPS
  Location Provider with Privacy Using Localized Server and GPS   Location Provider with Privacy Using Localized Server and GPS
Location Provider with Privacy Using Localized Server and GPS
 
Lisp 2
Lisp 2 Lisp 2
Lisp 2
 
Offline powerpoint
Offline powerpointOffline powerpoint
Offline powerpoint
 

Similaire à Cook Up a Runtime with The New OSGi Resolver - Neil Bartlett

Intro to JavaScript Testing
Intro to JavaScript TestingIntro to JavaScript Testing
Intro to JavaScript Testing
Ran Mizrahi
 
Intro to PHP Testing
Intro to PHP TestingIntro to PHP Testing
Intro to PHP Testing
Ran Mizrahi
 
eSynergy Andy Hawkins - Enabling DevOps through next generation configuration...
eSynergy Andy Hawkins - Enabling DevOps through next generation configuration...eSynergy Andy Hawkins - Enabling DevOps through next generation configuration...
eSynergy Andy Hawkins - Enabling DevOps through next generation configuration...
PatrickCrompton
 
Deploying Heterogeneous Artifacts to the Cloud with OSGi - Neil Bartlett
Deploying Heterogeneous Artifacts to the Cloud with OSGi - Neil BartlettDeploying Heterogeneous Artifacts to the Cloud with OSGi - Neil Bartlett
Deploying Heterogeneous Artifacts to the Cloud with OSGi - Neil Bartlett
mfrancis
 

Similaire à Cook Up a Runtime with The New OSGi Resolver - Neil Bartlett (20)

Implementing Quality on Java projects
Implementing Quality on Java projectsImplementing Quality on Java projects
Implementing Quality on Java projects
 
JRubyConf 2009
JRubyConf 2009JRubyConf 2009
JRubyConf 2009
 
Red Dirt Ruby Conference
Red Dirt Ruby ConferenceRed Dirt Ruby Conference
Red Dirt Ruby Conference
 
Js memory
Js memoryJs memory
Js memory
 
Coscup 2013 : Continuous Integration on top of hadoop
Coscup 2013 : Continuous Integration on top of hadoopCoscup 2013 : Continuous Integration on top of hadoop
Coscup 2013 : Continuous Integration on top of hadoop
 
Intro to JavaScript Testing
Intro to JavaScript TestingIntro to JavaScript Testing
Intro to JavaScript Testing
 
Intro to PHP Testing
Intro to PHP TestingIntro to PHP Testing
Intro to PHP Testing
 
Lessons from 4 years of driver develoment
Lessons from 4 years of driver develomentLessons from 4 years of driver develoment
Lessons from 4 years of driver develoment
 
Rails Intro & Tutorial
Rails Intro & TutorialRails Intro & Tutorial
Rails Intro & Tutorial
 
Ab(Using) the MetaCPAN API for Fun and Profit v2013
Ab(Using) the MetaCPAN API for Fun and Profit v2013Ab(Using) the MetaCPAN API for Fun and Profit v2013
Ab(Using) the MetaCPAN API for Fun and Profit v2013
 
eSynergy Andy Hawkins - Enabling DevOps through next generation configuration...
eSynergy Andy Hawkins - Enabling DevOps through next generation configuration...eSynergy Andy Hawkins - Enabling DevOps through next generation configuration...
eSynergy Andy Hawkins - Enabling DevOps through next generation configuration...
 
AppEngine Performance Tuning
AppEngine Performance TuningAppEngine Performance Tuning
AppEngine Performance Tuning
 
Deploying Heterogeneous Artifacts to the Cloud with OSGi - Neil Bartlett
Deploying Heterogeneous Artifacts to the Cloud with OSGi - Neil BartlettDeploying Heterogeneous Artifacts to the Cloud with OSGi - Neil Bartlett
Deploying Heterogeneous Artifacts to the Cloud with OSGi - Neil Bartlett
 
Everything you ever wanted to know about lotus script
Everything you ever wanted to know about lotus scriptEverything you ever wanted to know about lotus script
Everything you ever wanted to know about lotus script
 
node.js in action
node.js in actionnode.js in action
node.js in action
 
Testing iOS Apps
Testing iOS AppsTesting iOS Apps
Testing iOS Apps
 
State of Puppet - Puppet Camp Barcelona 2013
State of Puppet - Puppet Camp Barcelona 2013State of Puppet - Puppet Camp Barcelona 2013
State of Puppet - Puppet Camp Barcelona 2013
 
Front-end development automation with Grunt
Front-end development automation with GruntFront-end development automation with Grunt
Front-end development automation with Grunt
 
Back to the future with Java 7 (Geekout June/2011)
Back to the future with Java 7 (Geekout June/2011)Back to the future with Java 7 (Geekout June/2011)
Back to the future with Java 7 (Geekout June/2011)
 
Chef - Configuration Management for the Cloud
Chef - Configuration Management for the CloudChef - Configuration Management for the Cloud
Chef - Configuration Management for the Cloud
 

Plus de 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
 

Plus de mfrancis (20)

Eclipse Modeling Framework and plain OSGi the easy way - Mark Hoffman (Data I...
Eclipse Modeling Framework and plain OSGi the easy way - Mark Hoffman (Data I...Eclipse Modeling Framework and plain OSGi the easy way - Mark Hoffman (Data I...
Eclipse Modeling Framework and plain OSGi the easy way - Mark Hoffman (Data I...
 
OSGi and Java 9+ - BJ Hargrave (IBM)
OSGi and Java 9+ - BJ Hargrave (IBM)OSGi and Java 9+ - BJ Hargrave (IBM)
OSGi and Java 9+ - BJ Hargrave (IBM)
 
Simplify Web UX Coding using OSGi Modularity Magic - Paul Fraser (A2Z Living)
Simplify Web UX Coding using OSGi Modularity Magic - Paul Fraser (A2Z Living)Simplify Web UX Coding using OSGi Modularity Magic - Paul Fraser (A2Z Living)
Simplify Web UX Coding using OSGi Modularity Magic - Paul Fraser (A2Z Living)
 
OSGi for the data centre - Connecting OSGi to Kubernetes - Frank Lyaruu
OSGi for the data centre - Connecting OSGi to Kubernetes - Frank LyaruuOSGi for the data centre - Connecting OSGi to Kubernetes - Frank Lyaruu
OSGi for the data centre - Connecting OSGi to Kubernetes - Frank Lyaruu
 
Remote Management and Monitoring of Distributed OSGi Applications - Tim Verbe...
Remote Management and Monitoring of Distributed OSGi Applications - Tim Verbe...Remote Management and Monitoring of Distributed OSGi Applications - Tim Verbe...
Remote Management and Monitoring of Distributed OSGi Applications - Tim Verbe...
 
OSGi with Docker - a powerful way to develop Java systems - Udo Hafermann (So...
OSGi with Docker - a powerful way to develop Java systems - Udo Hafermann (So...OSGi with Docker - a powerful way to develop Java systems - Udo Hafermann (So...
OSGi with Docker - a powerful way to develop Java systems - Udo Hafermann (So...
 
A real world use case with OSGi R7 - Jurgen Albert (Data In Motion Consulting...
A real world use case with OSGi R7 - Jurgen Albert (Data In Motion Consulting...A real world use case with OSGi R7 - Jurgen Albert (Data In Motion Consulting...
A real world use case with OSGi R7 - Jurgen Albert (Data In Motion Consulting...
 
OSGi Feature Model - Where Art Thou - David Bosschaert (Adobe)
OSGi Feature Model - Where Art Thou - David Bosschaert (Adobe)OSGi Feature Model - Where Art Thou - David Bosschaert (Adobe)
OSGi Feature Model - Where Art Thou - David Bosschaert (Adobe)
 
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)
 

Dernier

Dernier (20)

FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Script
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century education
 
A Beginners Guide to Building a RAG App Using Open Source Milvus
A Beginners Guide to Building a RAG App Using Open Source MilvusA Beginners Guide to Building a RAG App Using Open Source Milvus
A Beginners Guide to Building a RAG App Using Open Source Milvus
 
MS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectorsMS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectors
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...
 
Apidays Singapore 2024 - Scalable LLM APIs for AI and Generative AI Applicati...
Apidays Singapore 2024 - Scalable LLM APIs for AI and Generative AI Applicati...Apidays Singapore 2024 - Scalable LLM APIs for AI and Generative AI Applicati...
Apidays Singapore 2024 - Scalable LLM APIs for AI and Generative AI Applicati...
 
Real Time Object Detection Using Open CV
Real Time Object Detection Using Open CVReal Time Object Detection Using Open CV
Real Time Object Detection Using Open CV
 
Ransomware_Q4_2023. The report. [EN].pdf
Ransomware_Q4_2023. The report. [EN].pdfRansomware_Q4_2023. The report. [EN].pdf
Ransomware_Q4_2023. The report. [EN].pdf
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 
Apidays Singapore 2024 - Modernizing Securities Finance by Madhu Subbu
Apidays Singapore 2024 - Modernizing Securities Finance by Madhu SubbuApidays Singapore 2024 - Modernizing Securities Finance by Madhu Subbu
Apidays Singapore 2024 - Modernizing Securities Finance by Madhu Subbu
 
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
 
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingRepurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
 
Corporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptxCorporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptx
 
MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of Terraform
 
Artificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyArtificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : Uncertainty
 
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
 

Cook Up a Runtime with The New OSGi Resolver - Neil Bartlett

  • 1. Copyright © 2005 - 2013 Paremus Ltd. May not be reproduced by any means without express permission. All rights reserved. Paremus Packager March 2013 Cook Up a Runtime with the OSGi Resolver Neil Bartlett - Paremus neil.bartlett@paremus.com Friday, 29 March 13
  • 3. OSGi “The Framework that Likes to Say...” Friday, 29 March 13
  • 5. NO YOU CAN’T • Example: missing import: org.wtf. • Google for org.wtf, find that it’s part of bundle com.acme.fml • Download and install com.acme.fml, now you have more missing imports: org.thingummy, javax.whatever (version 3.0.2.SNAPSHOT). • Go round again... and again... and again... Friday, 29 March 13
  • 6. THIS IS NOT A JOB FOR HUMAN BEANS Friday, 29 March 13
  • 9. Nothing’s Happening • Oh you’re using Declarative Services! Did you remember to include org.apache.felix.scr? • Oh you’re using Blueprint. Did you remember to include org.apache.aries.blueprint? • Oh you’re using JPA. Did you remember to include org.eclipse.gemini.jpa? Friday, 29 March 13
  • 10. Extender/Whiteboard • NO direct/static dependency • Dependency is implicit: without the extender, nothing happens. • NO diagnostic error messages Friday, 29 March 13
  • 11. Not Really Solutions • Deployment Admin Packages • Eclipse Features • Virgo Plans/PARs • Karaf KARs/Features • etc... Friday, 29 March 13
  • 12. OSGi Release 5 Friday, 29 March 13
  • 13. OSGi Release 5 • Released April 2012 • New Specification: Resolver and Repository Friday, 29 March 13
  • 15. Simple API! public interface Repository { Map<Requirement, Collection<Capability>> findProviders( Collection<? extends Requirement> requirements); } Friday, 29 March 13
  • 16. Repository • Can return Resources from anywhere • Should have knowledge of capabilities and requirements of the resources it manages • Database? XML file? Just an implementation detail. Friday, 29 March 13
  • 17. XML Index Format <repository name='Local' xmlns='http://www.osgi.org/xmlns/repository/v1.0.0'> <resource> <capability namespace='osgi.identity'> <attribute name='osgi.identity' value='org.apache.felix.gogo.runtime'/> <attribute name='type' value='osgi.bundle'/> <attribute name='version' type='Version' value='0.10.0'/> </capability> <capability namespace='osgi.content'> <attribute name='osgi.content' value='15e94961ae2d0046278686965fe6a34ad43d8d18719f5bc2304e725cdb57a379'/> <attribute name='url' value='org.apache.felix.gogo.runtime/ org.apache.felix.gogo.runtime-0.10.0.jar'/> <attribute name='size' type='Long' value='66965'/> <attribute name='mime' value='application/vnd.osgi.bundle'/> </capability> <capability namespace='osgi.wiring.package'> <attribute name='osgi.wiring.package' value='org.apache.felix.service.command'/> <attribute name='version' type='Version' value='0.10.0'/> <attribute name='status' value='provisional'/> <attribute name='bundle-symbolic-name' value='org.apache.felix.gogo.runtime'/> <attribute name='bundle-version' type='Version' value='0.10.0'/> <directive name='mandatory' value='status'/> </capability> ... Friday, 29 March 13
  • 18. Generating an Index • RepoIndex: https://github.com/osgi/bindex • Standalone library, also command line,ANT, OSGi service, etc. Friday, 29 March 13
  • 19. Repository Implementations • RI from Red Hat: github.com/jbosgi/jbosgi-repository • bnd “Fixed Indexed Repo” • Just needs a URI to an index • bnd “Local Indexed Repo” • Mutable, based on local file-system folder • Automatically reindexes on deploy Friday, 29 March 13
  • 21. Simple API! public interface Resolver { Map<Resource, List<Wire>> resolve(ResolveContext context) throws ResolutionException; } Friday, 29 March 13
  • 22. Resolver Result • Returns a Delta: new Resources, new Wires • Can be used by OSGi Framework • Use outside OSGi to discover resources Friday, 29 March 13
  • 23. DO NOT IMPLEMENT • Implementing a Resolver is HARD • Resolver is very generic.You almost certainly don’t NEED to implement your own Friday, 29 March 13
  • 24. Resolver Implementation • Just One: The RI from Apache Felix • Used in Felix Framework • Soon to be used in Equinox Framework • Used by Subsystems Specification • Used by Bnd(tools) • Soon to be used in Paremus Nimble Friday, 29 March 13
  • 25. So the Resolver talks to the Repository, right? Friday, 29 March 13
  • 26. WRONG • Resolver has no knowledge of any Repository. Friday, 29 March 13
  • 27. At least it knows about current Bundles and Wires, right? Friday, 29 March 13
  • 28. WRONG • Resolver has no knowledge of existing state. Friday, 29 March 13
  • 29. Resolver is Clueless! • Resolver just finds a solution to a puzzle • The inputs to the puzzle depend on us: the Resolve Context Friday, 29 March 13
  • 31. Resolve Context • Implemented by Resolver clients. I.e., us! • Guides the resolver. Friday, 29 March 13
  • 32. Not So Simple API! public abstract class ResolveContext { public Collection<Resource> getMandatoryResources() { return emptyCollection(); } public Collection<Resource> getOptionalResources() { return emptyCollection(); } public abstract Map<Resource, Wiring> getWirings(); public abstract List<Capability> findProviders(Requirement requirement); public abstract boolean isEffective(Requirement requirement); public abstract int insertHostedCapability(List<Capability> capabilities, HostedCapability hostedCapability); } Friday, 29 March 13
  • 33. getMandatoryResources() • This is our starting point • List of resources that must be present in the result • Bndtools creates a single dummy Resource containing the input Requirements Friday, 29 March 13
  • 34. getOptionalResources() • List of resources we hope will be present in the result • Failure to resolve one of these doesn’t break the whole resolution Friday, 29 March 13
  • 35. getWirings() • Map of existing resolved resources and their wires • Inside OSGi, this is the already resolved bundles • In Bndtools this is empty Friday, 29 March 13
  • 36. findProviders() • Here’s the meat! • The Resolver wants to resolve a requirement... • ... asks us to find the candidate Capabilities to satisfy it • We return a ranked collection of Capabilities • Typically we talk to our Repositories • Resolver tries to use the highest ranked candidate, but no promises. Friday, 29 March 13
  • 37. GOTCHA • Don’t go to Repositories for JRE packages etc. • Always check system bundle capabilities first. • Some Resources have “self-requirements”, e.g. importing package exported by same bundle. • Always check first if the resource’s own capabilities satisfy the requirement Friday, 29 March 13
  • 38. isEffective() • Decide whether to ignore the Requirement Friday, 29 March 13
  • 39. insertHostedCapability() • Oh Mummy... • Insert fragment capabilities into the list returned by findProviders(), at the correct position • More proof that fragments are horrible. Friday, 29 March 13
  • 40. Implementations • Felix and Equinox Frameworks • BndrunResolveContext in bnd project takes a .bndrun file as input Friday, 29 March 13
  • 43. Effective • Some requirements are “effective” at different times • E.g.: Require-Capability: osgi.service;filter:=... • Should Not block resolution by the OSGi Framework •Should guide OBR/Nimble/Bndtools to add a provider to the result Friday, 29 March 13
  • 45. Effective • Requirements are only effective in OSGi Framework resolution if effective == “resolve” • ... but “resolve” is the default, so omitting the “effective:” directive also works. • Other Resolve Contexts (e.g. Bndtools) can decide by implementing isEffective(Requirement). Friday, 29 March 13
  • 46. effective:=active • No value for “effective:” is defined by OSGi other than “resolve” • “active” is a convention for requirements that apply to active bundles. • E.g.: extenders, whiteboard, services, etc Friday, 29 March 13
  • 48. Choice • Your app requires a Web container, e.g. osgi.extender;filter:=“(osgi.extender =osgi.wab)” • Tomcat and Jetty are both available. • It only makes sense to have one! How do we decide? Friday, 29 March 13
  • 49. Choice • It’s all down to ResolveContext.findProviders() • Ranked preference, Resolver tries to pick highest. • Or we return just one. Friday, 29 March 13
  • 50. Current State-of-the-Art • “Repository Path” • Resources from earlier repos are preferred over later repos. • Forces us to have many, granular repos. • Probably won’t scale. Friday, 29 March 13
  • 51. Future? • Interactive Resolve. • Ask the user, but cache the answer (...for how long?) • Policies • “Prefer Jetty over Tomcat” • Repository Filters Friday, 29 March 13
  • 53. What is an Application?? • A small number of bundles defining the high-level functionality. • All of the dependencies of the above. • Curate your top-level bundles. •Generate your dependency lists. Friday, 29 March 13
  • 54. Caution • When should we resolve? • The result can change if repo contents change! • Resolve => Test => Resolve => Deploy to Prod... bang! • WYTIWYR • Persist your resolution result. Friday, 29 March 13