Discovering the p2 API
Upcoming SlideShare
Loading in...5
×
 

Discovering the p2 API

on

  • 7,461 views

This presentation goes over the main concepts of the p2 API and provide some

This presentation goes over the main concepts of the p2 API and provide some

Statistics

Views

Total Views
7,461
Views on SlideShare
7,348
Embed Views
113

Actions

Likes
6
Downloads
93
Comments
0

6 Embeds 113

http://www.slideshare.net 79
http://www.developpez.net 27
http://www.linkedin.com 3
http://kane-mx.blogspot.com 2
http://www.lmodules.com 1
http://translate.googleusercontent.com 1

Accessibility

Categories

Upload Details

Uploaded via as Microsoft PowerPoint

Usage Rights

© All Rights Reserved

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Processing…
Post Comment
Edit your comment

Discovering the p2 API Discovering the p2 API Presentation Transcript

  • 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 is the first official release of the API
    © Sonatype, inc. All right reserved. Made available under Creative Commons Att. Nc Nd 2.5.license
    3
  • 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
    4
  • Graphical User Interface
    GUI is SWT-based and designed to be reused in RCP / Eclipse applications.
    Ease of reuse:
    Add the p2.ui.sdk bundle, done (if you use IDE) .
    Add the p2.ui bundle, write a few extensions, done.
    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
    5
  • Graphical User Interface
    © Sonatype, inc. All right reserved. Made available under Creative Commons Att. Nc Nd 2.5.license
    6
  • Reusing individual UI elements
    Most the pages / wizards can be reused
    Installed dialog
    Repository management
    License manager
    Install/Update/Uninstall wizard
    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
    org.eclipse.equinox.p2.ui
    © Sonatype, inc. All right reserved. Made available under Creative Commons Att. Nc Nd 2.5.license
    7
  • 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.Policy
    org.eclipse.equinox.p2.ui
    © Sonatype, inc. All right reserved. Made available under Creative Commons Att. Nc Nd 2.5.license
    8
  • Tweaking the existing UI
    © Sonatype, inc. All right reserved. Made available under Creative Commons Att. Nc Nd 2.5.license
    9
  • More on UI reuse
    See examples on the p2 wiki
    http://wiki.eclipse.org/Equinox/p2/Examples
    Susan’s and Steffen’s talk
    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
    10
  • 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
    11
  • 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
    12
  • Headless operations example
    InstallOperation op = newInstallOperation(session, iusToInstall);
    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
    13
  • 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
    14
  • Core concepts
    installable unit/metadata
    query/
    queryable
    planner
    repository
    agent
    engine
    profile registry/
    profile
    © Sonatype, inc. All right reserved. Made available under Creative Commons Att. Nc Nd 2.5.license
    15
  • Repositories
    p2
    Update Site
    Engine
    Eclipse/OSGi
    Native/OS
    Core concepts
    Metadata repo
    Artifact repo
    Data transfer
    Metadata fetched and constraints analyzed
    Transports
    Planner/Director
    Http/Https
    File system
    Volume
    Mirroring
    Provisioning operation requested
    IU install, uninstall, update operations
    Artifact availability and mirroring
    IUs configured into runtimes
    Profile updated
    Profile registry
    Runtimes
    © Sonatype, inc. All right reserved. Made available under Creative Commons Att. Nc Nd 2.5.license
    16
  • How do I get an IU?
    IUs can be obtained from
    Querying the metadata repository
    Querying the profile
    Querying …
    Programmatically created
    org.eclipse.equinox.p2.metadata.MetadataFactory
    org.eclipse.equinox.p2.metadata
    © Sonatype, inc. All right reserved. Made available under Creative Commons Att. Nc Nd 2.5.license
    17
  • 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
    18
  • 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.IMetadataRepository
    org.eclipse.equinox.p2.repository.IArtifactRepository
    o.e.e.p2.repository.IMetadataRepositoryManager
    o.e.e.p2.repository.IArtifactRepositoryManager
    org.eclipse.equinox.p2.repository
    © Sonatype, inc. All right reserved. Made available under Creative Commons Att. Nc Nd 2.5.license
    19
  • 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.IProvisioningAgent
    org.eclipse.equinox.p2.core.IProvisioningAgentProvider
    org.eclipse.equinox.p2.core
    © Sonatype, inc. All right reserved. Made available under Creative Commons Att. Nc Nd 2.5.license
    20
  • 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.IProfile
    org.eclipse.equinox.p2.engine.IProfileRegistry
    org.eclipse.equinox.p2.engine
    org.eclipse.equinox.p2.engine
    © Sonatype, inc. All right reserved. Made available under Creative Commons Att. Nc Nd 2.5.license
    21
  • 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
    22
  • 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
    23
  • Thank you
    mailto:p2-dev@eclipse.org
    http://wiki.eclipse.org/Equinox/p2
    © Sonatype, inc. All right reserved. Made available under Creative Commons Att. Nc Nd 2.5.license
    24
  • Code snippet to install
    © Sonatype, inc. All right reserved. Made available under Creative Commons Att. Nc Nd 2.5.license
    25
    ProvisioningSession session = null;
    //get the agent
    ServiceReferencesr = Activator.sContext.getServiceReference(IProvisioningAgentProvider.SERVICE_NAME);
    IProvisioningAgentProvideragentProvider = null;
    if (sr == null)
    return;
    agentProvider = (IProvisioningAgentProvider) Activator.sContext.getService(sr);
    IProvisioningAgent agent = agentProvider.createAgent(new URI("file:/Applications/eclipse63/p2"));
    //get the repo managers
    IMetadataRepositoryManager manager = (IMetadataRepositoryManager) agent.getService(IMetadataRepositoryManager.SERVICE_NAME);
    IArtifactRepositoryManagerartifactManager = (IArtifactRepositoryManager) agent.getService(IArtifactRepositoryManager.SERVICE_NAME);
    //Loading reppos
    IMetadataRepositorymetadataRepo = manager.loadRepository(newURI("file:/Users/Pascal/tmp/demo/"), new NullProgressMonitor());
    IArtifactRepositoryartifactRepo = artifactManager.loadRepository(newURI("file:/Users/Pascal/tmp/demo/"), new NullProgressMonitor());
    //Querying
    Collection toInstall = metadataRepo.query(QueryUtil.createIUQuery("org.eclipse.equinox.p2.demo.feature.group"), new NullProgressMonitor()).toUnmodifiableSet();
    InstallOperationinstallOperation = new InstallOperation(session, toInstall);
    if (installOperation.resolveModal(newNullProgressMonitor()).isOK())
    installOperation.getProvisioningJob(newNullProgressMonitor()).schedule();
    agent.close()