Download - Discovery the p2 API (updated to Indigo)
Discovering the p2 API
Pascal Rapicault
Sonatype, p2 Lead
© Sonatype, inc. All right reserved. Made available under Creative Commons Att. Nc Nd 2.5.license 1
Who are the p2 committers?
© Sonatype, inc. All right reserved. Made available under Creative Commons Att. Nc Nd 2.5.license 2
History
• 3.4 / 3.5 provisional API
• 3.6 / Helios - first official release of the API
• 3.7 / Indigo - full backward compatibility
© Sonatype, inc. All right reserved. Made available under Creative Commons Att. Nc Nd 2.5.license 3
What’s new in 3.7?
• API– New features to ease p2 consumption– Simplification for RCP use case– Simpler Headless API for simple cases
• SPI– Pluggable transport
• Code– Memory consumption improvements– Inter-process locking of local repositories– …
© Sonatype, inc. All right reserved. Made available under Creative Commons Att. Nc Nd 2.5.license 4
3 levels of API
• Graphical User Interface
• Headless Operations
• Core APIs + SPIs
© Sonatype, inc. All right reserved. Made available under Creative Commons Att. Nc Nd 2.5.license 5
Graphical User Interface
• GUI is SWT-based and designed to be reused in RCP / Eclipse applications.
• Ease of reuse:– Feature org.eclipse.equinox.p2.rcp.feature
• The p2.ui.sdk bundle provides SDK like UI for reuse in RCP.
– Compose from the p2.ui bundle• Add extensions to hook where you want
org.eclipse.equinox.p2.ui
org.eclipse.equinox.p2.ui.sdk
© Sonatype, inc. All right reserved. Made available under Creative Commons Att. Nc Nd 2.5.license 6
Graphical User Interface
© Sonatype, inc. All right reserved. Made available under Creative Commons Att. Nc Nd 2.5.license 7
Reusing individual UI elements
• Most the pages / wizards can be reused
– Installed dialog
– Repository management
– License manager
– Install/Update/Uninstall wizard
org.eclipse.equinox.p2.ui
o.e.e.p2.ui.InstalledSoftwarePage
o.e.e.p2.ui.RepositoryManipulationPage
o.e.e.p2.ui.AcceptLicensesWizardPage
o.e.e.p2.ui.ProvisioningUtil#open*Wizard
© Sonatype, inc. All right reserved. Made available under Creative Commons Att. Nc Nd 2.5.license 8
Tweaking the existing UI
• The Policy class
– Show / hide repository selection
– Drill down
– Show categories
– Content of the restart dialog
– …
org.eclipse.equinox.p2.ui
org.eclipse.equinox.p2.ui.Policy
© Sonatype, inc. All right reserved. Made available under Creative Commons Att. Nc Nd 2.5.license 9
Tweaking the existing UI
© Sonatype, inc. All right reserved. Made available under Creative Commons Att. Nc Nd 2.5.license 10
Extension / discovery UI
© Sonatype, inc. All right reserved. Made available under Creative Commons Att. Nc Nd 2.5.license 11
- Simpler for the end user- Nice icons
*Not API*
org.eclipse.equinox.p2.discovery
o.e.e.i.p2.disc….RepositoryDiscoveryStrategy
More on UI reuse
• See examples on the p2 wiki
– http://wiki.eclipse.org/Equinox/p2/Examples
• Talk on the p2 UI
– http://www.eclipsecon.org/2010/sessions/?page=sessions&id=1205
© Sonatype, inc. All right reserved. Made available under Creative Commons Att. Nc Nd 2.5.license 12
3 levels of API
• Graphical User Interface
• Headless Operations
• Core APIs + SPIs
© Sonatype, inc. All right reserved. Made available under Creative Commons Att. Nc Nd 2.5.license 13
Minimal headless p2
• A “relatively” minimal headless p2 is available:
– org.eclipse.equinox.p2.core.feature
– Provide enough to install / update / uninstall
• A 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.license 14
Headless operations
• High level operations to install / update / uninstall
• Focused on the Eclipse / OSGi use cases
• Encapsulates:– Dependency resolution
– Download
– Modification of the system
– Restart
org.eclipse.equinox.p2.operations
org.eclipse.equinox.p2.operations
© Sonatype, inc. All right reserved. Made available under Creative Commons Att. Nc Nd 2.5.license 15
Headless operations example
InstallOperation 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.license 16
New 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 API
• Graphical User Interface
• Headless Operations
• Core APIs + SPIs
© Sonatype, inc. All right reserved. Made available under Creative Commons Att. Nc Nd 2.5.license 17
Core concepts
profile registry/profile
repository
installable unit/metadata
agent
planner
engine
query/queryable
© Sonatype, inc. All right reserved. Made available under Creative Commons Att. Nc Nd 2.5.license 18
TransportsHttp/Https
File system
Volume
Repositoriesp2
Update Site
Engine
Eclipse/OSGi
Native/OS
Planner/Director
Profile registryRuntimes
Provisioning operation requested
Metadata fetched and constraints analyzed
IU install, uninstall, update operations
Artifact availability and mirroring
Mirroring
Data transfer
IUs configured into runtimes
Profile updated
Metadata repo Artifact repo
© Sonatype, inc. All right reserved. Made available under Creative Commons Att. Nc Nd 2.5.license 19
Core concepts
How do I get an IU?
• IUs can be obtained from
– Querying the metadata repository
– Querying the profile
– Querying …
– Programmatically createdorg.eclipse.equinox.p2.metadata
org.eclipse.equinox.p2.metadata.MetadataFactory
© Sonatype, inc. All right reserved. Made available under Creative Commons Att. Nc Nd 2.5.license 20
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 language• http://wiki.eclipse.org/Query_Language_for_p2
org.eclipse.equinox.p2.query.IQueryable
org.eclipse.equinox.p2.query.QueryUtil
org.eclipse.equinox.p2.metadata
org.eclipse.equinox.p2.ql© Sonatype, inc. All right reserved. Made available under Creative Commons Att. Nc Nd 2.5.license 21
The repository managerHow do I get a repository?
• Artifact / metadata repository manager• Addition / removal of repositories• Enable / disable repositories• Load
• Artifact / metadata repository• Add• Remove• Query
org.eclipse.equinox.p2.repository
org.eclipse.equinox.p2.repository.IMetadataRepositoryorg.eclipse.equinox.p2.repository.IArtifactRepository
o.e.e.p2.repository.IMetadataRepositoryManagero.e.e.p2.repository.IArtifactRepositoryManager
© Sonatype, inc. All right reserved. Made available under Creative Commons Att. Nc Nd 2.5.license 22
Provisioning agentHow do I get a repository manager or p2 components?
• The agent groups related services together– It 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 registry• Create it using the IProvisioningContext#createAgent(null)
org.eclipse.equinox.p2.core
org.eclipse.equinox.p2.core.IProvisioningAgent
org.eclipse.equinox.p2.core.IProvisioningAgentProvider
© Sonatype, inc. All right reserved. Made available under Creative Commons Att. Nc Nd 2.5.license 23
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 area
org.eclipse.equinox.p2.engine
org.eclipse.equinox.p2.engine.IProfile
org.eclipse.equinox.p2.engine
org.eclipse.equinox.p2.engine.IProfileRegistry
© Sonatype, inc. All right reserved. Made available under Creative Commons Att. Nc Nd 2.5.license 24
What is not API?
• Repository serialized format
• Layout of files on disk under the p2 folder
© Sonatype, inc. All right reserved. Made available under Creative Commons Att. Nc Nd 2.5.license 25
Summary
• 3 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.license 26
Thank you
mailto:[email protected]
http://wiki.eclipse.org/Equinox/p2
© Sonatype, inc. All right reserved. Made available under Creative Commons Att. Nc Nd 2.5.license 27
p2 related talks
• p2 savior or Achilles heel (Tues 4pm)– http://www.eclipsecon.org/2011/sessions?id=2313
• Raising p2 to the cloud (Wed 1:30pm)– http://www.eclipsecon.org/2011/sessions?id=2102
• Updates in the micro space (Thr 2:30pm)– http://www.eclipsecon.org/2011/sessions?id=2196
• Fireside 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.license 28