Discovering the p2 APIPascal RapicaultSonatype, p2 LeadŠ Sonatype, inc. All right reserved. Made available under Creative Commons Att. Nc Nd 2.5.license1
Who are the p2 committers?Š Sonatype, inc. All right reserved. Made available under Creative Commons Att. Nc Nd 2.5.license2
History3.4 / 3.5 provisional API3.6 / Helios - first official release of the API3.7 / Indigo - full backward compatibilityŠ Sonatype, inc. All right reserved. Made available under Creative Commons Att. Nc Nd 2.5.license3
What’s new in 3.7?APINew features to ease p2 consumptionSimplification for RCP use caseSimpler Headless API for simple casesSPIPluggable transportCodeMemory consumption improvementsInter-process locking of local repositories…© Sonatype, inc. All right reserved. Made available under Creative Commons Att. Nc Nd 2.5.license4
3 levels of APIGraphical User InterfaceHeadless OperationsCore APIs + SPIsŠ Sonatype, inc. All right reserved. Made available under Creative Commons Att. Nc Nd 2.5.license5
Graphical User InterfaceGUI is SWT-based and designed to be reused in RCP / Eclipse applications. Ease of reuse:Feature org.eclipse.equinox.p2.rcp.featureThe p2.ui.sdk bundle provides SDK like UI for reuse in RCP.Compose from the p2.ui bundleAdd extensions to hook where you wantorg.eclipse.equinox.p2.uiorg.eclipse.equinox.p2.ui.sdkŠ Sonatype, inc. All right reserved. Made available under Creative Commons Att. Nc Nd 2.5.license6
Graphical User InterfaceŠ Sonatype, inc. All right reserved. Made available under Creative Commons Att. Nc Nd 2.5.license7
Reusing individual UI elements	Most the pages / wizards can be reusedInstalled dialog   Repository managementLicense managerInstall/Update/Uninstall wizardo.e.e.p2.ui.InstalledSoftwarePageo.e.e.p2.ui.RepositoryManipulationPageo.e.e.p2.ui.AcceptLicensesWizardPageo.e.e.p2.ui.ProvisioningUtil#open*Wizardorg.eclipse.equinox.p2.uiŠ Sonatype, inc. All right reserved. Made available under Creative Commons Att. Nc Nd 2.5.license8
Tweaking the existing UIThe Policy classShow / hide repository selectionDrill downShow categoriesContent of the restart dialog …org.eclipse.equinox.p2.ui.Policyorg.eclipse.equinox.p2.ui© Sonatype, inc. All right reserved. Made available under Creative Commons Att. Nc Nd 2.5.license9
Tweaking the existing UIŠ Sonatype, inc. All right reserved. Made available under Creative Commons Att. Nc Nd 2.5.license10
Extension / discovery UI© Sonatype, inc. All right reserved. Made available under Creative Commons Att. Nc Nd 2.5.license11- Simpler for the end user Nice icons*Not API*o.e.e.i.p2.disc….RepositoryDiscoveryStrategyorg.eclipse.equinox.p2.discovery
More on UI reuseSee examples on the p2 wikihttp://wiki.eclipse.org/Equinox/p2/ExamplesTalk on the p2 UIhttp://www.eclipsecon.org/2010/sessions/?page=sessions&id=1205Š Sonatype, inc. All right reserved. Made available under Creative Commons Att. Nc Nd 2.5.license12
3 levels of APIGraphical User InterfaceHeadless OperationsCore APIs + SPIsŠ Sonatype, inc. All right reserved. Made available under Creative Commons Att. Nc Nd 2.5.license13
Minimal headless p2A “relatively” minimal headless p2 is available:org.eclipse.equinox.p2.core.featureProvide enough to install / update / uninstallA smaller subset can be created, but it is too specific (e.g. w/o ECF, w/o http client, w/o operations, etc.)© Sonatype, inc. All right reserved. Made available under Creative Commons Att. Nc Nd 2.5.license14
Headless operationsHigh level operations to install / update / uninstallFocused on the Eclipse / OSGi use casesEncapsulates:Dependency resolutionDownloadModification of the systemRestartorg.eclipse.equinox.p2.operationsorg.eclipse.equinox.p2.operationsŠ Sonatype, inc. All right reserved. Made available under Creative Commons Att. Nc Nd 2.5.license15
Headless operations exampleInstallOperation op = OperationHelper.create***Operation(iusToInstall, repoList, new NullProgressMonitor());if (op.resolveModal(newNullProgressMonitor()).isOK())op.getProvisioningJob(newNullProgressMonitor()).schedule();Š Sonatype, inc. All right reserved. Made available under Creative Commons Att. Nc Nd 2.5.license16New in 3.7. This API only works for the running instance (which is the case most of the time).To modify another instance, you need to use the InstallOperation directly.
3 levels of APIGraphical User InterfaceHeadless OperationsCore APIs + SPIsŠ Sonatype, inc. All right reserved. Made available under Creative Commons Att. Nc Nd 2.5.license17
Core conceptsinstallable unit/metadataquery/queryableplannerrepositoryagentengineprofile registry/profileŠ Sonatype, inc. All right reserved. Made available under Creative Commons Att. Nc Nd 2.5.license18
Repositoriesp2Update SiteEngineEclipse/OSGiNative/OSCore conceptsMetadata repoArtifact repoData transferMetadata fetched and constraints analyzedTransportsPlanner/DirectorHttp/HttpsFile systemVolumeMirroringProvisioning operation requestedIU install, uninstall, update operationsArtifact availability and mirroringIUs configured into runtimesProfile updatedProfile registryRuntimesŠ Sonatype, inc. All right reserved. Made available under Creative Commons Att. Nc Nd 2.5.license19
How do I get an IU?IUs can be obtained fromQuerying the metadata repository Querying the profileQuerying …Programmatically createdorg.eclipse.equinox.p2.metadata.MetadataFactoryorg.eclipse.equinox.p2.metadata© Sonatype, inc. All right reserved. Made available under Creative Commons Att. Nc Nd 2.5.license20
Queries / QueryableHow do I query?What is queryable?Almost everything is queryable (repository, repository manager, profile, …)How do I create a query?QueryUtil.create*Domain specific queries (e.g. in eclipse.touchpoint)p2 QL, p2-specific query languagehttp://wiki.eclipse.org/Query_Language_for_p2org.eclipse.equinox.p2.query.IQueryableorg.eclipse.equinox.p2.query.QueryUtilorg.eclipse.equinox.p2.metadataorg.eclipse.equinox.p2.ql© Sonatype, inc. All right reserved. Made available under Creative Commons Att. Nc Nd 2.5.license21
The repository managerHow do I get a repository?Artifact / metadata repository managerAddition / removal of repositoriesEnable / disable repositoriesLoadArtifact / metadata repositoryAddRemoveQueryorg.eclipse.equinox.p2.repository.IMetadataRepositoryorg.eclipse.equinox.p2.repository.IArtifactRepositoryo.e.e.p2.repository.IMetadataRepositoryManagero.e.e.p2.repository.IArtifactRepositoryManagerorg.eclipse.equinox.p2.repositoryŠ Sonatype, inc. All right reserved. Made available under Creative Commons Att. Nc Nd 2.5.license22
Provisioning agentHow do I get a repository manager or p2 components?The agent groups related services togetherIt is the starting point of everything.It is the executable version of the p2 area (e.g the p2 folder in the eclipse install)Several agents can run at once in one VM. Groups the services together. Allows to change some services (see implementations of IAgentServiceFactory)If you are only dealing with the running instance:Obtain the IProvisioningAgent service from the OSGi registryCreate it using the IProvisioningContext#createAgent(null)org.eclipse.equinox.p2.core.IProvisioningAgentorg.eclipse.equinox.p2.core.IProvisioningAgentProviderorg.eclipse.equinox.p2.coreŠ Sonatype, inc. All right reserved. Made available under Creative Commons Att. Nc Nd 2.5.license23
Profile / profile registryHow do I know what is installed?A profile is the complete description in terms of IUs of what is installed.The profile registry knows about all the profiles in a given p2 areaorg.eclipse.equinox.p2.engine.IProfileorg.eclipse.equinox.p2.engine.IProfileRegistryorg.eclipse.equinox.p2.engineorg.eclipse.equinox.p2.engineŠ Sonatype, inc. All right reserved. Made available under Creative Commons Att. Nc Nd 2.5.license24
What is not API?Repository serialized formatLayout of files on disk under the p2 folderŠ Sonatype, inc. All right reserved. Made available under Creative Commons Att. Nc Nd 2.5.license25
Summary3 levels of API tailored for different needs           Simple things should be simple        Complex things should be possible	  This API is for YOU! Tell us what you think.Š Sonatype, inc. All right reserved. Made available under Creative Commons Att. Nc Nd 2.5.license26
Thank youmailto:p2-dev@eclipse.orghttp://wiki.eclipse.org/Equinox/p2Š Sonatype, inc. All right reserved. Made available under Creative Commons Att. Nc Nd 2.5.license27
p2 related talksp2 savior or Achilles heel (Tues 4pm)http://www.eclipsecon.org/2011/sessions?id=2313Raising p2 to the cloud (Wed 1:30pm)http://www.eclipsecon.org/2011/sessions?id=2102Updates in the micro space (Thr 2:30pm)http://www.eclipsecon.org/2011/sessions?id=2196Fireside chat on p2 (Wed 8:30pm)http://www.eclipsecon.org/2011/sessions?id=2473Š Sonatype, inc. All right reserved. Made available under Creative Commons Att. Nc Nd 2.5.license28

Discovery the p2 API (updated to Indigo)

  • 1.
    Discovering the p2APIPascal RapicaultSonatype, p2 LeadŠ Sonatype, inc. All right reserved. Made available under Creative Commons Att. Nc Nd 2.5.license1
  • 2.
    Who are thep2 committers?Š Sonatype, inc. All right reserved. Made available under Creative Commons Att. Nc Nd 2.5.license2
  • 3.
    History3.4 / 3.5provisional API3.6 / Helios - first official release of the API3.7 / Indigo - full backward compatibilityŠ Sonatype, inc. All right reserved. Made available under Creative Commons Att. Nc Nd 2.5.license3
  • 4.
    What’s new in3.7?APINew features to ease p2 consumptionSimplification for RCP use caseSimpler Headless API for simple casesSPIPluggable transportCodeMemory consumption improvementsInter-process locking of local repositories…© Sonatype, inc. All right reserved. Made available under Creative Commons Att. Nc Nd 2.5.license4
  • 5.
    3 levels ofAPIGraphical User InterfaceHeadless OperationsCore APIs + SPIsŠ Sonatype, inc. All right reserved. Made available under Creative Commons Att. Nc Nd 2.5.license5
  • 6.
    Graphical User InterfaceGUIis SWT-based and designed to be reused in RCP / Eclipse applications. Ease of reuse:Feature org.eclipse.equinox.p2.rcp.featureThe p2.ui.sdk bundle provides SDK like UI for reuse in RCP.Compose from the p2.ui bundleAdd extensions to hook where you wantorg.eclipse.equinox.p2.uiorg.eclipse.equinox.p2.ui.sdkŠ Sonatype, inc. All right reserved. Made available under Creative Commons Att. Nc Nd 2.5.license6
  • 7.
    Graphical User InterfaceŠSonatype, inc. All right reserved. Made available under Creative Commons Att. Nc Nd 2.5.license7
  • 8.
    Reusing individual UIelements Most the pages / wizards can be reusedInstalled dialog Repository managementLicense managerInstall/Update/Uninstall wizardo.e.e.p2.ui.InstalledSoftwarePageo.e.e.p2.ui.RepositoryManipulationPageo.e.e.p2.ui.AcceptLicensesWizardPageo.e.e.p2.ui.ProvisioningUtil#open*Wizardorg.eclipse.equinox.p2.uiŠ Sonatype, inc. All right reserved. Made available under Creative Commons Att. Nc Nd 2.5.license8
  • 9.
    Tweaking the existingUIThe Policy classShow / hide repository selectionDrill downShow categoriesContent of the restart dialog …org.eclipse.equinox.p2.ui.Policyorg.eclipse.equinox.p2.ui© Sonatype, inc. All right reserved. Made available under Creative Commons Att. Nc Nd 2.5.license9
  • 10.
    Tweaking the existingUIŠ Sonatype, inc. All right reserved. Made available under Creative Commons Att. Nc Nd 2.5.license10
  • 11.
    Extension / discoveryUI© Sonatype, inc. All right reserved. Made available under Creative Commons Att. Nc Nd 2.5.license11- Simpler for the end user Nice icons*Not API*o.e.e.i.p2.disc….RepositoryDiscoveryStrategyorg.eclipse.equinox.p2.discovery
  • 12.
    More on UIreuseSee examples on the p2 wikihttp://wiki.eclipse.org/Equinox/p2/ExamplesTalk on the p2 UIhttp://www.eclipsecon.org/2010/sessions/?page=sessions&id=1205Š Sonatype, inc. All right reserved. Made available under Creative Commons Att. Nc Nd 2.5.license12
  • 13.
    3 levels ofAPIGraphical User InterfaceHeadless OperationsCore APIs + SPIsŠ Sonatype, inc. All right reserved. Made available under Creative Commons Att. Nc Nd 2.5.license13
  • 14.
    Minimal headless p2A“relatively” minimal headless p2 is available:org.eclipse.equinox.p2.core.featureProvide enough to install / update / uninstallA smaller subset can be created, but it is too specific (e.g. w/o ECF, w/o http client, w/o operations, etc.)© Sonatype, inc. All right reserved. Made available under Creative Commons Att. Nc Nd 2.5.license14
  • 15.
    Headless operationsHigh leveloperations to install / update / uninstallFocused on the Eclipse / OSGi use casesEncapsulates:Dependency resolutionDownloadModification of the systemRestartorg.eclipse.equinox.p2.operationsorg.eclipse.equinox.p2.operationsŠ Sonatype, inc. All right reserved. Made available under Creative Commons Att. Nc Nd 2.5.license15
  • 16.
    Headless operations exampleInstallOperationop = OperationHelper.create***Operation(iusToInstall, repoList, new NullProgressMonitor());if (op.resolveModal(newNullProgressMonitor()).isOK())op.getProvisioningJob(newNullProgressMonitor()).schedule();Š Sonatype, inc. All right reserved. Made available under Creative Commons Att. Nc Nd 2.5.license16New in 3.7. This API only works for the running instance (which is the case most of the time).To modify another instance, you need to use the InstallOperation directly.
  • 17.
    3 levels ofAPIGraphical User InterfaceHeadless OperationsCore APIs + SPIsŠ Sonatype, inc. All right reserved. Made available under Creative Commons Att. Nc Nd 2.5.license17
  • 18.
    Core conceptsinstallable unit/metadataquery/queryableplannerrepositoryagentengineprofileregistry/profileŠ Sonatype, inc. All right reserved. Made available under Creative Commons Att. Nc Nd 2.5.license18
  • 19.
    Repositoriesp2Update SiteEngineEclipse/OSGiNative/OSCore conceptsMetadatarepoArtifact repoData transferMetadata fetched and constraints analyzedTransportsPlanner/DirectorHttp/HttpsFile systemVolumeMirroringProvisioning operation requestedIU install, uninstall, update operationsArtifact availability and mirroringIUs configured into runtimesProfile updatedProfile registryRuntimesŠ Sonatype, inc. All right reserved. Made available under Creative Commons Att. Nc Nd 2.5.license19
  • 20.
    How do Iget an IU?IUs can be obtained fromQuerying the metadata repository Querying the profileQuerying …Programmatically createdorg.eclipse.equinox.p2.metadata.MetadataFactoryorg.eclipse.equinox.p2.metadata© Sonatype, inc. All right reserved. Made available under Creative Commons Att. Nc Nd 2.5.license20
  • 21.
    Queries / QueryableHowdo I query?What is queryable?Almost everything is queryable (repository, repository manager, profile, …)How do I create a query?QueryUtil.create*Domain specific queries (e.g. in eclipse.touchpoint)p2 QL, p2-specific query languagehttp://wiki.eclipse.org/Query_Language_for_p2org.eclipse.equinox.p2.query.IQueryableorg.eclipse.equinox.p2.query.QueryUtilorg.eclipse.equinox.p2.metadataorg.eclipse.equinox.p2.ql© Sonatype, inc. All right reserved. Made available under Creative Commons Att. Nc Nd 2.5.license21
  • 22.
    The repository managerHowdo I get a repository?Artifact / metadata repository managerAddition / removal of repositoriesEnable / disable repositoriesLoadArtifact / metadata repositoryAddRemoveQueryorg.eclipse.equinox.p2.repository.IMetadataRepositoryorg.eclipse.equinox.p2.repository.IArtifactRepositoryo.e.e.p2.repository.IMetadataRepositoryManagero.e.e.p2.repository.IArtifactRepositoryManagerorg.eclipse.equinox.p2.repositoryŠ Sonatype, inc. All right reserved. Made available under Creative Commons Att. Nc Nd 2.5.license22
  • 23.
    Provisioning agentHow doI get a repository manager or p2 components?The agent groups related services togetherIt is the starting point of everything.It is the executable version of the p2 area (e.g the p2 folder in the eclipse install)Several agents can run at once in one VM. Groups the services together. Allows to change some services (see implementations of IAgentServiceFactory)If you are only dealing with the running instance:Obtain the IProvisioningAgent service from the OSGi registryCreate it using the IProvisioningContext#createAgent(null)org.eclipse.equinox.p2.core.IProvisioningAgentorg.eclipse.equinox.p2.core.IProvisioningAgentProviderorg.eclipse.equinox.p2.coreŠ Sonatype, inc. All right reserved. Made available under Creative Commons Att. Nc Nd 2.5.license23
  • 24.
    Profile / profileregistryHow do I know what is installed?A profile is the complete description in terms of IUs of what is installed.The profile registry knows about all the profiles in a given p2 areaorg.eclipse.equinox.p2.engine.IProfileorg.eclipse.equinox.p2.engine.IProfileRegistryorg.eclipse.equinox.p2.engineorg.eclipse.equinox.p2.engineŠ Sonatype, inc. All right reserved. Made available under Creative Commons Att. Nc Nd 2.5.license24
  • 25.
    What is notAPI?Repository serialized formatLayout of files on disk under the p2 folderŠ Sonatype, inc. All right reserved. Made available under Creative Commons Att. Nc Nd 2.5.license25
  • 26.
    Summary3 levels ofAPI tailored for different needs Simple things should be simple Complex things should be possible This API is for YOU! Tell us what you think.Š Sonatype, inc. All right reserved. Made available under Creative Commons Att. Nc Nd 2.5.license26
  • 27.
    Thank youmailto:p2-dev@eclipse.orghttp://wiki.eclipse.org/Equinox/p2Š Sonatype,inc. All right reserved. Made available under Creative Commons Att. Nc Nd 2.5.license27
  • 28.
    p2 related talksp2savior or Achilles heel (Tues 4pm)http://www.eclipsecon.org/2011/sessions?id=2313Raising p2 to the cloud (Wed 1:30pm)http://www.eclipsecon.org/2011/sessions?id=2102Updates in the micro space (Thr 2:30pm)http://www.eclipsecon.org/2011/sessions?id=2196Fireside chat on p2 (Wed 8:30pm)http://www.eclipsecon.org/2011/sessions?id=2473Š Sonatype, inc. All right reserved. Made available under Creative Commons Att. Nc Nd 2.5.license28