OSGi Application Provisioning Deep Dive - QCon New York Provisioning Deep...About me David...
Transcript of OSGi Application Provisioning Deep Dive - QCon New York Provisioning Deep...About me David...
![Page 1: OSGi Application Provisioning Deep Dive - QCon New York Provisioning Deep...About me David Bosschaert (davidb@apache.org) 㽋 Works at Adobe R&D Basel 㽋 Co-chair OSGi EEG 㽋 Apache](https://reader034.fdocuments.in/reader034/viewer/2022042023/5e7b9f8d4d594206c316b8e3/html5/thumbnails/1.jpg)
Subsystems, Repository, Contracts and more...David Bosschaert
OSGi Application Provisioning
Deep Dive
1 of 41
![Page 2: OSGi Application Provisioning Deep Dive - QCon New York Provisioning Deep...About me David Bosschaert (davidb@apache.org) 㽋 Works at Adobe R&D Basel 㽋 Co-chair OSGi EEG 㽋 Apache](https://reader034.fdocuments.in/reader034/viewer/2022042023/5e7b9f8d4d594206c316b8e3/html5/thumbnails/2.jpg)
About me
David Bosschaert ([email protected])⦿ Works at Adobe R&D Basel⦿ Co-chair OSGi EEG⦿ Apache committer⦿ Open-source and cloudenthusiast
2 of 41
![Page 3: OSGi Application Provisioning Deep Dive - QCon New York Provisioning Deep...About me David Bosschaert (davidb@apache.org) 㽋 Works at Adobe R&D Basel 㽋 Co-chair OSGi EEG 㽋 Apache](https://reader034.fdocuments.in/reader034/viewer/2022042023/5e7b9f8d4d594206c316b8e3/html5/thumbnails/3.jpg)
Topics
⦿ A look at the latest Declarative Services⦿ Using Subsystems to package and deploy⦿ OSGi Repository to resolve dependencies⦿ Portable Java Contracts
... demo throughout ...
3 of 41
![Page 4: OSGi Application Provisioning Deep Dive - QCon New York Provisioning Deep...About me David Bosschaert (davidb@apache.org) 㽋 Works at Adobe R&D Basel 㽋 Co-chair OSGi EEG 㽋 Apache](https://reader034.fdocuments.in/reader034/viewer/2022042023/5e7b9f8d4d594206c316b8e3/html5/thumbnails/4.jpg)
Running ExampleDevice Monitor
... a little webapp to monitor all your gadgets ...
4 of 41
![Page 5: OSGi Application Provisioning Deep Dive - QCon New York Provisioning Deep...About me David Bosschaert (davidb@apache.org) 㽋 Works at Adobe R&D Basel 㽋 Co-chair OSGi EEG 㽋 Apache](https://reader034.fdocuments.in/reader034/viewer/2022042023/5e7b9f8d4d594206c316b8e3/html5/thumbnails/5.jpg)
Declarative ServicesBeing updated for Enterprise R6
Improved Configuration AdminintegrationIntrospective APIPrototype Service Factory... other smaller improvements ...
5 of 41
![Page 6: OSGi Application Provisioning Deep Dive - QCon New York Provisioning Deep...About me David Bosschaert (davidb@apache.org) 㽋 Works at Adobe R&D Basel 㽋 Co-chair OSGi EEG 㽋 Apache](https://reader034.fdocuments.in/reader034/viewer/2022042023/5e7b9f8d4d594206c316b8e3/html5/thumbnails/6.jpg)
DS Configured Componentiimmppoorrtt javax.servlet.SSeerrvvlleett;
iimmppoorrtt org.osgi.service.component.annotations.*;
iimmppoorrtt org.osgi.service.http.HHttttppSSeerrvviiccee;
@Component
ppuubblliicc ccllaassss DDeevviicceeMMoonniittoorr {
pprriivvaattee HHttttppSSeerrvviiccee httpService;
@Reference
ppuubblliicc vvooiidd setHttpService(HHttttppSSeerrvviiccee svc) {
httpService = svc;
}
@Activate
ppuubblliicc vvooiidd activate(MMoonniittoorrCCoonnffiigg cfg) {
SSttrriinngg rootCtx = cfg.ctxPrefix();
iiff (!rootCtx.endsWith("/"))
rootCtx = rootCtx + "/";
registerServlet(rootCtx + "dmon", nneeww MMoonniittoorrSSeerrvvlleett());
registerServlet(rootCtx + "device", nneeww DDeevviicceeSSeerrvvlleett());
}
pprriivvaattee vvooiidd registerServlet(SSttrriinngg ctx, SSeerrvvlleett servlet) {
httpService.registerServlet(ctx, servlet, nnuullll, nnuullll);
}
}
6 of 41
![Page 7: OSGi Application Provisioning Deep Dive - QCon New York Provisioning Deep...About me David Bosschaert (davidb@apache.org) 㽋 Works at Adobe R&D Basel 㽋 Co-chair OSGi EEG 㽋 Apache](https://reader034.fdocuments.in/reader034/viewer/2022042023/5e7b9f8d4d594206c316b8e3/html5/thumbnails/7.jpg)
Configuration usingAnnotationsppuubblliicc @interface MMoonniittoorrCCoonnffiigg {
SSttrriinngg ctxPrefix() ddeeffaauulltt "/";
bboooolleeaann autoRefresh() ddeeffaauulltt ffaallssee;
iinntt interval() ddeeffaauulltt 30;
}
annotation used as an ordinary interface,with added defaults
... weird but works great ...
7 of 41
![Page 8: OSGi Application Provisioning Deep Dive - QCon New York Provisioning Deep...About me David Bosschaert (davidb@apache.org) 㽋 Works at Adobe R&D Basel 㽋 Co-chair OSGi EEG 㽋 Apache](https://reader034.fdocuments.in/reader034/viewer/2022042023/5e7b9f8d4d594206c316b8e3/html5/thumbnails/8.jpg)
Example Bundle ManifestBBuunnddllee-MMaanniiffeessttVVeerrssiioonn: 2
BBuunnddllee-SSyymmbboolliiccNNaammee: devicemon-ds
BBuunnddllee-VVeerrssiioonn: 0.0.1
SSeerrvviiccee-CCoommppoonneenntt: OSGI-INF/component.xml
IImmppoorrtt-PPaacckkaaggee: javax.servlet;version="[2.5,3)",
org.coderthoughts.devicemon.ssh;version="[1.0,2)",
org.osgi.service.http;version="[1.2,2)"
RReeqquuiirree-CCaappaabbiilliittyy:
osgi.extender;filter:="(&(osgi.extender=osgi.component)
(version>=1.2.0)(!(version>=2.0.0)))",
osgi.whiteboard;filter:="(osgi.whiteboard=osgi.http)"
Note that the javax.servlet import should really use
contracts!
8 of 41
![Page 9: OSGi Application Provisioning Deep Dive - QCon New York Provisioning Deep...About me David Bosschaert (davidb@apache.org) 㽋 Works at Adobe R&D Basel 㽋 Co-chair OSGi EEG 㽋 Apache](https://reader034.fdocuments.in/reader034/viewer/2022042023/5e7b9f8d4d594206c316b8e3/html5/thumbnails/9.jpg)
Finished app...2 Bundles
devicemon.jardepends on DS and HTTP Service
devicemon-ssh.jardepends on Apache Mina SSHD
9 of 41
![Page 10: OSGi Application Provisioning Deep Dive - QCon New York Provisioning Deep...About me David Bosschaert (davidb@apache.org) 㽋 Works at Adobe R&D Basel 㽋 Co-chair OSGi EEG 㽋 Apache](https://reader034.fdocuments.in/reader034/viewer/2022042023/5e7b9f8d4d594206c316b8e3/html5/thumbnails/10.jpg)
Deploy it...Now I want to easily deploy my app
⟱create a Subsystem of it!
10 of 41
![Page 11: OSGi Application Provisioning Deep Dive - QCon New York Provisioning Deep...About me David Bosschaert (davidb@apache.org) 㽋 Works at Adobe R&D Basel 㽋 Co-chair OSGi EEG 㽋 Apache](https://reader034.fdocuments.in/reader034/viewer/2022042023/5e7b9f8d4d594206c316b8e3/html5/thumbnails/11.jpg)
SubsystemsOSGi Enterprise spec 134
A subsystem...collection of bundles put together
feature - everything sharedapplication - isolated, nothing shared outcomposite - configurable in-between
a zip file with .esa extensioncan be nestedcan depend on bundles or othersubsystems
Subsystems can use OSGi Repositories toresolve dependencies
11 of 41
![Page 12: OSGi Application Provisioning Deep Dive - QCon New York Provisioning Deep...About me David Bosschaert (davidb@apache.org) 㽋 Works at Adobe R&D Basel 㽋 Co-chair OSGi EEG 㽋 Apache](https://reader034.fdocuments.in/reader034/viewer/2022042023/5e7b9f8d4d594206c316b8e3/html5/thumbnails/12.jpg)
devicemon-ds.esaJust a zip file...$ tar tvf devicemon-ds.esa
-rwxrwxrwx 99 8 JJaann 15:40 OSGI-INF/SUBSYSTEM.MF
-rwxrwxrwx 18184 8 JJaann 16:01 devicemon-ds.jar
-rwxrwxrwx 5968 8 JJaann 16:02 devicemon-ssh.jar
Subsystem Manifest$ cat OSGI-INF/SUBSYSTEM.MF
SSuubbssyysstteemm-SSyymmbboolliiccNNaammee: devicemon-ds
SSuubbssyysstteemm-VVeerrssiioonn: 0.0.1
SSuubbssyysstteemm-TTyyppee: osgi.subsystem.feature
note, I didn't put my dependencies in the .esa file
12 of 41
![Page 13: OSGi Application Provisioning Deep Dive - QCon New York Provisioning Deep...About me David Bosschaert (davidb@apache.org) 㽋 Works at Adobe R&D Basel 㽋 Co-chair OSGi EEG 㽋 Apache](https://reader034.fdocuments.in/reader034/viewer/2022042023/5e7b9f8d4d594206c316b8e3/html5/thumbnails/13.jpg)
Feature subsystemsdevicemon-ds.esa: a Feature Subsystem
All the bundles inside work just as shared bundlesin OSGiSubsystem installed/started/stopped as 1 unitDependencies pulled in either from .esa or fromrepository
as neededare reference-counted
13 of 41
![Page 14: OSGi Application Provisioning Deep Dive - QCon New York Provisioning Deep...About me David Bosschaert (davidb@apache.org) 㽋 Works at Adobe R&D Basel 㽋 Co-chair OSGi EEG 㽋 Apache](https://reader034.fdocuments.in/reader034/viewer/2022042023/5e7b9f8d4d594206c316b8e3/html5/thumbnails/14.jpg)
Apache Felix + Apache Aries Subsystems
14 of 41
![Page 15: OSGi Application Provisioning Deep Dive - QCon New York Provisioning Deep...About me David Bosschaert (davidb@apache.org) 㽋 Works at Adobe R&D Basel 㽋 Co-chair OSGi EEG 㽋 Apache](https://reader034.fdocuments.in/reader034/viewer/2022042023/5e7b9f8d4d594206c316b8e3/html5/thumbnails/15.jpg)
Add HTTP subsystem
15 of 41
![Page 16: OSGi Application Provisioning Deep Dive - QCon New York Provisioning Deep...About me David Bosschaert (davidb@apache.org) 㽋 Works at Adobe R&D Basel 㽋 Co-chair OSGi EEG 㽋 Apache](https://reader034.fdocuments.in/reader034/viewer/2022042023/5e7b9f8d4d594206c316b8e3/html5/thumbnails/16.jpg)
3 bundles in 1 operation
16 of 41
![Page 17: OSGi Application Provisioning Deep Dive - QCon New York Provisioning Deep...About me David Bosschaert (davidb@apache.org) 㽋 Works at Adobe R&D Basel 㽋 Co-chair OSGi EEG 㽋 Apache](https://reader034.fdocuments.in/reader034/viewer/2022042023/5e7b9f8d4d594206c316b8e3/html5/thumbnails/17.jpg)
Our subsystem doesn't install!
NB: a failed subsystem install doesn'tleave any bundles behind...
17 of 41
![Page 18: OSGi Application Provisioning Deep Dive - QCon New York Provisioning Deep...About me David Bosschaert (davidb@apache.org) 㽋 Works at Adobe R&D Basel 㽋 Co-chair OSGi EEG 㽋 Apache](https://reader034.fdocuments.in/reader034/viewer/2022042023/5e7b9f8d4d594206c316b8e3/html5/thumbnails/18.jpg)
OSGi RepositoryOSGi Enterprise spec 132
Inspired by Felix OBRSimple but powerfulActual repo can be remote or localFind resources
based on their capabilitiesany resourceany capability
OSGi has defined:standard Bundle capabilitiesBundle, Subsystem resource typessome more general capabilities
18 of 41
![Page 19: OSGi Application Provisioning Deep Dive - QCon New York Provisioning Deep...About me David Bosschaert (davidb@apache.org) 㽋 Works at Adobe R&D Basel 㽋 Co-chair OSGi EEG 㽋 Apache](https://reader034.fdocuments.in/reader034/viewer/2022042023/5e7b9f8d4d594206c316b8e3/html5/thumbnails/19.jpg)
Add resources using standard XML
Example<<rreeppoossiittoorryy increment='1389281419631' name='MyRepo' xmlns='http://www.osgi.org/xmlns/repository/v1.0.0'>>
<<rreessoouurrccee>>
<<ccaappaabbiilliittyy namespace='osgi.identity'>>
<<aattttrriibbuuttee name='osgi.identity' value='org.apache.sshd.core'//>>
<<aattttrriibbuuttee name='type' value='osgi.bundle'//>>
<<aattttrriibbuuttee name='version' type='Version' value='0.9.0'//>>
<<//ccaappaabbiilliittyy>>
<<ccaappaabbiilliittyy namespace='osgi.content'>>
<<aattttrriibbuuttee name='osgi.content' value='a1c64578808c38a63cd6563e9936f025638aeaf9de70f36765367db81c0afc38'
<<aattttrriibbuuttee name='url' value='local-repo/sshd-core.jar'//>>
<<aattttrriibbuuttee name='size' type='Long' value='464733'//>>
<<aattttrriibbuuttee name='mime' value='application/vnd.osgi.bundle'//>>
<<//ccaappaabbiilliittyy>>
<<ccaappaabbiilliittyy namespace='osgi.wiring.package'>>
<<aattttrriibbuuttee name='osgi.wiring.package' value='org.apache.sshd'//>>
<<aattttrriibbuuttee name='version' type='Version' value='0.5.0'//>>
<<aattttrriibbuuttee name='bundle-symbolic-name' value='org.apache.sshd.core'//>>
<<aattttrriibbuuttee name='bundle-version' type='Version' value='0.9.0'//>>
<<ddiirreeccttiivvee name='uses' value='org.apache.sshd.client'//>>
<<//ccaappaabbiilliittyy>>
<!-- More capabilities -->
<<rreeqquuiirreemmeenntt namespace='osgi.wiring.package'>>
<<ddiirreeccttiivvee name='filter'
value='(&(osgi.wiring.package=org.slf4j)(version>=1.6.0)(!(version>=2.0.0)))'/>
<<//rreeqquuiirreemmeenntt>>
<!-- More requirements -->
<<//rreessoouurrccee>>
<!-- More resources -->
<<//rreeppoossiittoorryy>>
19 of 41
![Page 20: OSGi Application Provisioning Deep Dive - QCon New York Provisioning Deep...About me David Bosschaert (davidb@apache.org) 㽋 Works at Adobe R&D Basel 㽋 Co-chair OSGi EEG 㽋 Apache](https://reader034.fdocuments.in/reader034/viewer/2022042023/5e7b9f8d4d594206c316b8e3/html5/thumbnails/20.jpg)
Repository XML
Format defined by OSGi Repository SpecStandard way to feed a repository with informationStandard way for repositories to exchange dataGenerate it with the bindex/RepoIndex tool:
https://github.com/osgi/bindex(https://github.com/osgi/bindex)
20 of 41
![Page 21: OSGi Application Provisioning Deep Dive - QCon New York Provisioning Deep...About me David Bosschaert (davidb@apache.org) 㽋 Works at Adobe R&D Basel 㽋 Co-chair OSGi EEG 㽋 Apache](https://reader034.fdocuments.in/reader034/viewer/2022042023/5e7b9f8d4d594206c316b8e3/html5/thumbnails/21.jpg)
Repository ServiceObtain resources from the repositoryFind a bundle...RReeppoossiittoorryy repo = ... // from Service Registry ...
RReeqquuiirreemmeennttBBuuiillddeerr rb = nneeww RReeqquuiirreemmeennttBBuuiillddeerr("osgi.wiring.package");
rb.addDirective("filter",
"(&(osgi.wiring.package=org.apache.ssh)(version=0.5.0))");
RReeqquuiirreemmeenntt req = rb.build();
CCoolllleeccttiioonn<RReessoouurrccee> bundleResources = repo.findProviders(req);
... or find some photo's from the North Pole ...RReeqquuiirreemmeennttBBuuiillddeerr rb = nneeww RReeqquuiirreemmeennttBBuuiillddeerr("com.acme.photo");
rb.addDirective("filter", "(latitude>=66.5622)");
RReeqquuiirreemmeenntt req = rb.build();
CCoolllleeccttiioonn<RReessoouurrccee> photoResources = repo.findProviders(req);
21 of 41
![Page 22: OSGi Application Provisioning Deep Dive - QCon New York Provisioning Deep...About me David Bosschaert (davidb@apache.org) 㽋 Works at Adobe R&D Basel 㽋 Co-chair OSGi EEG 㽋 Apache](https://reader034.fdocuments.in/reader034/viewer/2022042023/5e7b9f8d4d594206c316b8e3/html5/thumbnails/22.jpg)
Add and prime a Repository
22 of 41
![Page 23: OSGi Application Provisioning Deep Dive - QCon New York Provisioning Deep...About me David Bosschaert (davidb@apache.org) 㽋 Works at Adobe R&D Basel 㽋 Co-chair OSGi EEG 㽋 Apache](https://reader034.fdocuments.in/reader034/viewer/2022042023/5e7b9f8d4d594206c316b8e3/html5/thumbnails/23.jpg)
Our subsystem works!
23 of 41
![Page 24: OSGi Application Provisioning Deep Dive - QCon New York Provisioning Deep...About me David Bosschaert (davidb@apache.org) 㽋 Works at Adobe R&D Basel 㽋 Co-chair OSGi EEG 㽋 Apache](https://reader034.fdocuments.in/reader034/viewer/2022042023/5e7b9f8d4d594206c316b8e3/html5/thumbnails/24.jpg)
Descriptor SubsystemsA subsystem can be just a descriptor
... with all resources obtained from a Repository$ jar tvf generated/devicemon-ds-decl.esa
0 TThhuu JJaann 09 12:37:32 GMT 2014 OSGI-INF/
175 WWeedd JJaann 08 15:50:28 GMT 2014 OSGI-INF/SUBSYSTEM.MF
Subsystem Manifest$ cat OSGI-INF/SUBSYSTEM.MF
SSuubbssyysstteemm-SSyymmbboolliiccNNaammee: devicemon-ds-decl
SSuubbssyysstteemm-VVeerrssiioonn: 0.0.1
SSuubbssyysstteemm-TTyyppee: osgi.subsystem.feature
SSuubbssyysstteemm-CCoonntteenntt: devicemon-ds;version=0.0.1,
devicemon-ssh;version=0.0.1
24 of 41
![Page 25: OSGi Application Provisioning Deep Dive - QCon New York Provisioning Deep...About me David Bosschaert (davidb@apache.org) 㽋 Works at Adobe R&D Basel 㽋 Co-chair OSGi EEG 㽋 Apache](https://reader034.fdocuments.in/reader034/viewer/2022042023/5e7b9f8d4d594206c316b8e3/html5/thumbnails/25.jpg)
Start with only
Subsystems + Repository
25 of 41
![Page 26: OSGi Application Provisioning Deep Dive - QCon New York Provisioning Deep...About me David Bosschaert (davidb@apache.org) 㽋 Works at Adobe R&D Basel 㽋 Co-chair OSGi EEG 㽋 Apache](https://reader034.fdocuments.in/reader034/viewer/2022042023/5e7b9f8d4d594206c316b8e3/html5/thumbnails/26.jpg)
Dependencies at work
http.esa pulled in automatically
26 of 41
![Page 27: OSGi Application Provisioning Deep Dive - QCon New York Provisioning Deep...About me David Bosschaert (davidb@apache.org) 㽋 Works at Adobe R&D Basel 㽋 Co-chair OSGi EEG 㽋 Apache](https://reader034.fdocuments.in/reader034/viewer/2022042023/5e7b9f8d4d594206c316b8e3/html5/thumbnails/27.jpg)
Unpredictable dependency
both 0.9.0 and 0.9.1 satisfy requirement
27 of 41
![Page 28: OSGi Application Provisioning Deep Dive - QCon New York Provisioning Deep...About me David Bosschaert (davidb@apache.org) 㽋 Works at Adobe R&D Basel 㽋 Co-chair OSGi EEG 㽋 Apache](https://reader034.fdocuments.in/reader034/viewer/2022042023/5e7b9f8d4d594206c316b8e3/html5/thumbnails/28.jpg)
Subsystem Deployment DescriptorOnce QA-ed, create a DEPLOYMENT.MF to fixdependencies$ jar tvf generated/devicemon-ds-decl-dd.esa
283 WWeedd JJaann 15 16:39:34 GMT 2014 OSGI-INF/DEPLOYMENT.MF
175 WWeedd JJaann 08 15:50:28 GMT 2014 OSGI-INF/SUBSYSTEM.MF
it can freeze deployments$ cat OSGI-INF/DEPLOYMENT.MF
SSuubbssyysstteemm-VVeerrssiioonn: 0.0.1
SSuubbssyysstteemm-TTyyppee: osgi.subsystem.feature
DDeeppllooyyeedd-CCoonntteenntt: devicemon-ds;deployed-version=0.0.1,
devicemon-ssh;deployed-version=0.0.1
PPrroovviissiioonn-RReessoouurrccee: org.apache.sshd.core;deployed-version=0.9.1,
org.apache.felix.scr;deployed-version=1.8.2,
http-subsystem;type=osgi.subsystem.feature;deployed-version=1.2.0
note version 0.9.1 for org.apache.sshd.core
Ensures that the runtime deployment is the same as the QA one.
28 of 41
![Page 29: OSGi Application Provisioning Deep Dive - QCon New York Provisioning Deep...About me David Bosschaert (davidb@apache.org) 㽋 Works at Adobe R&D Basel 㽋 Co-chair OSGi EEG 㽋 Apache](https://reader034.fdocuments.in/reader034/viewer/2022042023/5e7b9f8d4d594206c316b8e3/html5/thumbnails/29.jpg)
SSHD dependency now as predicted
29 of 41
![Page 30: OSGi Application Provisioning Deep Dive - QCon New York Provisioning Deep...About me David Bosschaert (davidb@apache.org) 㽋 Works at Adobe R&D Basel 㽋 Co-chair OSGi EEG 㽋 Apache](https://reader034.fdocuments.in/reader034/viewer/2022042023/5e7b9f8d4d594206c316b8e3/html5/thumbnails/30.jpg)
Portable ContractsOur bundle contains:IImmppoorrtt-PPaacckkaaggee: javax.servlet;version="[2.5,3)",
This API is defined by the JCP.but... spot the problem!
30 of 41
![Page 31: OSGi Application Provisioning Deep Dive - QCon New York Provisioning Deep...About me David Bosschaert (davidb@apache.org) 㽋 Works at Adobe R&D Basel 㽋 Co-chair OSGi EEG 㽋 Apache](https://reader034.fdocuments.in/reader034/viewer/2022042023/5e7b9f8d4d594206c316b8e3/html5/thumbnails/31.jpg)
Semantic Versioning... versioning policy for exported packages.OSGi versions: <major>.<minor>.<micro>.<qualifier>
Updating package versions:fix/patch (no change to API):
update micro
extend API (affects implementers, not clients): update minor
API breakage: update major
Using semantic versioning allows creating components that canwork with future patches and other compatible releases of deps
just Import-Package a range like: [5.3, 6)
31 of 41
![Page 32: OSGi Application Provisioning Deep Dive - QCon New York Provisioning Deep...About me David Bosschaert (davidb@apache.org) 㽋 Works at Adobe R&D Basel 㽋 Co-chair OSGi EEG 㽋 Apache](https://reader034.fdocuments.in/reader034/viewer/2022042023/5e7b9f8d4d594206c316b8e3/html5/thumbnails/32.jpg)
javax.servlet ProblemIImmppoorrtt-PPaacckkaaggee: javax.servlet;version="[2.5,3)",
Servlet 3.0 is actually compatible with 2.5JCP specs don't follow semantic versioning3.0 is more of a marketing versionBut what version to use for javax.servletin OSGi?Different providers made different decisions
Some use 2.6 to export javax.servletfrom Servlet 3 specOthers use 3.0Some even use 0.0.0
This prohibits creating portable bundlesusing these APIs
32 of 41
![Page 33: OSGi Application Provisioning Deep Dive - QCon New York Provisioning Deep...About me David Bosschaert (davidb@apache.org) 㽋 Works at Adobe R&D Basel 㽋 Co-chair OSGi EEG 㽋 Apache](https://reader034.fdocuments.in/reader034/viewer/2022042023/5e7b9f8d4d594206c316b8e3/html5/thumbnails/33.jpg)
Portable Java Contractsosgi.contract capability to the rescue
client bundle requires capabilitywith single 'marketing' or 'spec' version
and also imports the packagewithout version
osgi.contract provider binds thecontract version to package versions
IImmppoorrtt-PPaacckkaaggee: javax.servlet, javax.servlet.http
RReeqquuiirree-CCaappaabbiilliittyy: osgi.contract;
filter:="(&(osgi.contract=JavaServlet)(version=2.5))"
Enables creating portable bundlesimporting non-semantically versionedpackages.
33 of 41
![Page 34: OSGi Application Provisioning Deep Dive - QCon New York Provisioning Deep...About me David Bosschaert (davidb@apache.org) 㽋 Works at Adobe R&D Basel 㽋 Co-chair OSGi EEG 㽋 Apache](https://reader034.fdocuments.in/reader034/viewer/2022042023/5e7b9f8d4d594206c316b8e3/html5/thumbnails/34.jpg)
Our bundle manifest should really beBBuunnddllee-MMaanniiffeessttVVeerrssiioonn: 2
BBuunnddllee-SSyymmbboolliiccNNaammee: devicemon-ds
BBuunnddllee-VVeerrssiioonn: 0.0.1
IImmppoorrtt-PPaacckkaaggee: javax.servlet,
org.coderthoughts.devicemon.ssh;version="[1.0,2)",
org.osgi.service.http;version="[1.2,2)"
RReeqquuiirree-CCaappaabbiilliittyy:
osgi.extender;filter:="(&(osgi.extender=osgi.component)
(version>=1.2)(!(version>=2.0)))",
osgi.whiteboard;filter:="(osgi.whiteboard=osgi.http)
(version>=1.0)(!(version>=2.0)))",
osgi.contract;filter:="(&(osgi.contract=JavaServlet)
(version=2.5))"
34 of 41
![Page 35: OSGi Application Provisioning Deep Dive - QCon New York Provisioning Deep...About me David Bosschaert (davidb@apache.org) 㽋 Works at Adobe R&D Basel 㽋 Co-chair OSGi EEG 㽋 Apache](https://reader034.fdocuments.in/reader034/viewer/2022042023/5e7b9f8d4d594206c316b8e3/html5/thumbnails/35.jpg)
Providing Portable Contracts
The bundle exporting the package shoulddo this:EExxppoorrtt-PPaacckkaaggee: javax.servlet;version=2.6,
javax.servlet.http;version=2.6
PPrroovviiddee-CCaappaabbiilliittyy: osgi.contract;
osgi.contract=JJaavvaaSSeerrvvlleett;version:VVeerrssiioonn=2.5;
uses:="javax.servlet, javax.servlet.http",
osgi.contract;osgi.contract=JJaavvaaSSeerrvvlleett;version:VVeerrssiioonn=3;
uses:="javax.servlet, javax.servlet.http"
as it only knows how the mapping is done.Each marketing version is mapped to a package version.
For more details, see OSGi RFC 180(https://github.com/osgi/design/raw/master
/rfcs/rfc0180/rfc-0180-portable-java-contracts.pdf) .
35 of 41
![Page 36: OSGi Application Provisioning Deep Dive - QCon New York Provisioning Deep...About me David Bosschaert (davidb@apache.org) 㽋 Works at Adobe R&D Basel 㽋 Co-chair OSGi EEG 㽋 Apache](https://reader034.fdocuments.in/reader034/viewer/2022042023/5e7b9f8d4d594206c316b8e3/html5/thumbnails/36.jpg)
For all packages other thanJCP-ones
36 of 41
![Page 37: OSGi Application Provisioning Deep Dive - QCon New York Provisioning Deep...About me David Bosschaert (davidb@apache.org) 㽋 Works at Adobe R&D Basel 㽋 Co-chair OSGi EEG 㽋 Apache](https://reader034.fdocuments.in/reader034/viewer/2022042023/5e7b9f8d4d594206c316b8e3/html5/thumbnails/37.jpg)
http://www.bndtools.org(http://www.bndtools.org)
can help with versionmaintenance!
reallybndtools
Use Semantic Versioning!
37 of 41
![Page 38: OSGi Application Provisioning Deep Dive - QCon New York Provisioning Deep...About me David Bosschaert (davidb@apache.org) 㽋 Works at Adobe R&D Basel 㽋 Co-chair OSGi EEG 㽋 Apache](https://reader034.fdocuments.in/reader034/viewer/2022042023/5e7b9f8d4d594206c316b8e3/html5/thumbnails/38.jpg)
Where can I get it?
Core R6 spec released this week:http://www.osgi.org/Specifications/HomePage
(http://www.osgi.org/Specifications/HomePage)
Enterprise R6 draft released this week:http://www.osgi.org/Specifications/Drafts
(http://www.osgi.org/Specifications/Drafts)
RFCs 189, 190, 208 included in zip
38 of 41
![Page 39: OSGi Application Provisioning Deep Dive - QCon New York Provisioning Deep...About me David Bosschaert (davidb@apache.org) 㽋 Works at Adobe R&D Basel 㽋 Co-chair OSGi EEG 㽋 Apache](https://reader034.fdocuments.in/reader034/viewer/2022042023/5e7b9f8d4d594206c316b8e3/html5/thumbnails/39.jpg)
LinksOSGi specs:http://www.osgi.org/Specifications
(http://www.osgi.org/Specifications)
Apache Felix Project:http://felix.apache.org (http://felix.apache.org)
OSGi RFC 180https://github.com/osgi/design/raw/master
/rfcs/rfc0180/rfc-0180-portable-java-contracts.pdf
(https://github.com/osgi/design/raw/master
/rfcs/rfc0180/rfc-0180-portable-java-contracts.pdf)
devicemon project:https://github.com/bosschaert/devicemon
(https://github.com/bosschaert/devicemon)
Subsystem Gogo commandhttps://github.com/bosschaert/coderthoughts39 of 41
![Page 40: OSGi Application Provisioning Deep Dive - QCon New York Provisioning Deep...About me David Bosschaert (davidb@apache.org) 㽋 Works at Adobe R&D Basel 㽋 Co-chair OSGi EEG 㽋 Apache](https://reader034.fdocuments.in/reader034/viewer/2022042023/5e7b9f8d4d594206c316b8e3/html5/thumbnails/40.jpg)
/tree/master/subsystem-gogo-command
(https://github.com/bosschaert/coderthoughts
/tree/master/subsystem-gogo-command)
40 of 41
![Page 41: OSGi Application Provisioning Deep Dive - QCon New York Provisioning Deep...About me David Bosschaert (davidb@apache.org) 㽋 Works at Adobe R&D Basel 㽋 Co-chair OSGi EEG 㽋 Apache](https://reader034.fdocuments.in/reader034/viewer/2022042023/5e7b9f8d4d594206c316b8e3/html5/thumbnails/41.jpg)
Questions?
41 of 41