Bug 269496 - [fwkAdmin] Provide provisional BundleInfo and SimpleConfiguratorManipulator as official API
Summary: [fwkAdmin] Provide provisional BundleInfo and SimpleConfiguratorManipulator a...
Status: RESOLVED FIXED
Alias: None
Product: Equinox
Classification: Eclipse Project
Component: p2 (show other bugs)
Version: 3.5   Edit
Hardware: All All
: P3 enhancement (vote)
Target Milestone: 3.6 M6   Edit
Assignee: Andrew Niefer CLA
QA Contact:
URL:
Whiteboard:
Keywords: api
Depends on: 243242 304573
Blocks: 297663
  Show dependency tree
 
Reported: 2009-03-20 06:53 EDT by Dani Megert CLA
Modified: 2010-03-04 12:29 EST (History)
13 users (show)

See Also:


Attachments
current patch (167.18 KB, patch)
2010-03-01 18:34 EST, Andrew Niefer CLA
no flags Details | Diff
patch to p2 & pde.build (136.96 KB, patch)
2010-03-02 18:11 EST, Andrew Niefer CLA
no flags Details | Diff
patch to jdt junit (8.12 KB, patch)
2010-03-02 18:12 EST, Andrew Niefer CLA
no flags Details | Diff
patch to pde (20.20 KB, patch)
2010-03-02 18:12 EST, Andrew Niefer CLA
no flags Details | Diff
update jdt patch (8.93 KB, text/plain)
2010-03-04 11:47 EST, Andrew Niefer CLA
no flags Details
updated p2 & build (306.13 KB, patch)
2010-03-04 11:48 EST, Andrew Niefer CLA
no flags Details | Diff
updated pde (22.75 KB, patch)
2010-03-04 11:49 EST, Andrew Niefer CLA
no flags Details | Diff
api tools manifest patch (935 bytes, patch)
2010-03-04 11:54 EST, Andrew Niefer CLA
no flags Details | Diff
Updated JDT (8.92 KB, patch)
2010-03-04 12:04 EST, Andrew Niefer CLA
no flags Details | Diff
update p2 / build (297.68 KB, patch)
2010-03-04 12:06 EST, Andrew Niefer CLA
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Dani Megert CLA 2009-03-20 06:53:26 EDT
In order to find out about installed bundles JDT uses provisional p2 API. We would like to request that those parts become official API for 3.6 or that we get something along these lines:


	/**
	 * Finds the bundle info for the given arguments.
	 * <p>
	 * The first match will be returned if more than one bundle matches the arguments.
	 * </p>
	 * 
	 * @param symbolicName the symbolic name
	 * @param versionRange the version range for the bundle version
	 * @param isSourceBundle <code>true</code> if it is a source bundle <code>false</code> otherwise
	 * @return the bundle info or <code>null</code> if not found
	 */
	public static BundleInfo findBundle(String symbolicName, VersionRange versionRange, boolean isSourceBundle) {
Comment 1 Chris Aniszczyk CLA 2009-07-09 13:16:05 EDT
*poke*

Can we look at this one early in 3.6 guys?

This has been causing some strain in the PDE and JDT teams (see bug 283011)
Comment 2 DJ Houghton CLA 2009-07-09 13:47:33 EDT
Marking as 3.6 so it remains on the radar.
Comment 3 Dani Megert CLA 2009-08-13 06:56:07 EDT
Can we get this early in the cycle to make sure it fits our needs?
Comment 4 Andrew Niefer CLA 2009-08-13 11:52:04 EDT
Bug 243242 was where the original changes for SimpleConfiguratorManipulator were defined.  I have marked that bug fixed as the patch there was released in 3.5.

One outstanding question that was left there was the use of URL (and to a lesser extent File) in the method signature.  p2 has moved to URIs, perhaps this URL needs to be changed.

Comment 5 Dani Megert CLA 2009-08-14 02:27:02 EDT
Andrew, I'm not quite sure how to interpret your previous comment. Are you saying this is already possible via API? If so, can you point us there? The patch you mentioned adds internal/provisional API and not API.
Comment 6 Andrew Niefer CLA 2009-08-14 11:53:18 EDT
There is no official API yet.  That patch just created the provisional API that we are proposing to make real.  Before that patch there wasn't anything even close to API.


Though, re-reading comment #0, is that provisional SimpleConfiguratorManipulator enough?  You would need to find the bundles.info yourself and search the resulting BundleInfo[].
Comment 7 Dani Megert CLA 2009-08-17 05:09:02 EDT
Yes, for us it would be enough. You can take a look at 

Plug-in: org.eclipse.jdt.junit
    org.eclipse.jdt.internal.junit.buildpath.P2Utils
    org.eclipse.jdt.internal.junit.buildpath.BuildPathSupport

to see which provisional code we use.
Comment 8 Markus Keller CLA 2009-10-02 04:39:21 EDT
This is the API request from JDT/UI, as asked for in
http://dev.eclipse.org/mhonarc/lists/cross-project-issues-dev/msg03703.html .
Comment 9 Markus Keller CLA 2009-12-15 06:58:05 EST
Any progress here? I don't want to waste time reviewing and testing patches like bug 297663.
Comment 10 Andrew Niefer CLA 2009-12-15 13:24:54 EST
I'll start looking at this.

Some initial comments,
1) re bug 297663, the "launcherLocation" for SimpleConfiguratorManipulator#loadConfiguration is the location to resolve relative URIs against, I don't see how P2Utils.readBundle with useConfigArea==true can ever be the right thing to do.  When would we ever expect there to be bundles located in eclipse/configuration/plugins/* ?

2) BundleInfo
  - We should remove some of those constructors
  - BundleInfo#get/setManifest : what are these for? 
  - I wonder if we should add a get/set User Object (like BundleDescription)
  - get/setVersion - should this remain as a string?  Is it better as a org.osgi.framework.Version ?

3) SimpleConfiguratorManipulator
- should this be named ISimpleConfiguratorManipulator ?
- load/saveConfiguration: URL url & File outputFile refer to the bundles.info file we are loading/saving.    Maybe these should both perhaps be replaced by InputStream/OutputStream?

- loadConfiguration: "launcherLocation" doesn't seem like a good name here.  This should also be a URI instead of a file.
- saveConfiguration: base should be a URI

- extends ConfiguratorManipulator, this will pull in 
Manipulator
BundlesState
ConfigData
LauncherData
FrameworkAdminRuntimeException

Do we really want all of this as API?  Perhaps some should be spi instead, it all needs reviewing.  If we remove the extends ConfiguratorManipulator we can graduate SimpleConfiguratorManipulator without the rest.
Comment 11 Patrick Higgins CLA 2009-12-15 16:12:20 EST
(In reply to comment #10)
> 1) re bug 297663, the "launcherLocation" for
> SimpleConfiguratorManipulator#loadConfiguration is the location to resolve
> relative URIs against, I don't see how P2Utils.readBundle with
> useConfigArea==true can ever be the right thing to do.  When would we ever
> expect there to be bundles located in eclipse/configuration/plugins/* ?

For me at least, calling P2Utils.readBundle with useConfigArea==true has the following behavior, which seems reasonable to me:

1. Reads ~/.eclipse/155965261/configuration/org.eclipse.equinox.simpleconfigurator/bundles.info

2. Resolves relative URLs from above bundles.info to a base of ~/.eclipse/155965261, which does contain plugins I have installed that are not a part of the shared install.

The problem I am trying to address with bug 297663 is that reading bundles.info from the configuration area should not be strictly tied to resolving relative URLs to the configuration area. It should still be possible to resolve them to the shared install area.
Comment 12 Dani Megert CLA 2009-12-16 02:07:56 EST
>Do we really want all of this as API? 
See comment 0 for what JDT UI needs (can't speak for others). This should find the bundle no matter whether it is in the official install, dropins or other location. Optionally you could add a parameter to tell to restrict the search to dropins and/or install and/or other locations, but we (JDT UI) don't need this.

Regarding bug 297663: we have to backport the fix to 3.5.2 so it would be appreciated if you can tell us the correct way to fix the current code so we can achieve the functionality requested in comment 0 based on 3.5. Of course best would be to backport your new API ;-).
Comment 13 Andrew Niefer CLA 2009-12-16 10:56:58 EST
(In reply to comment #11)
> 1. Reads
> ~/.eclipse/155965261/configuration/org.eclipse.equinox.simpleconfigurator/bundles.info
> 
> 2. Resolves relative URLs from above bundles.info to a base of
> ~/.eclipse/155965261, which does contain plugins I have installed that are not
> a part of the shared install.

Looking at P2Utils.readBundles, I don't see how we get this.  I'm not sure how a shared install changes things, I will need to talk to some of the others.
I don't believe there are 2 cases (useConfigArea) for base, as far as I can see, the code that is loading the bundles.info to actually start eclipse is resolving against osgi.install.area (Location.INSTALL_FILTER).

(In reply to comment #12)
> >Do we really want all of this as API? 
> See comment 0 for what JDT UI needs (can't speak for others). This should find
> the bundle no matter whether it is in the official install, dropins or other
> location. Optionally you could add a parameter to tell to restrict the search
> to dropins and/or install and/or other locations, but we (JDT UI) don't need
> this.

I was looking more at comment #6 & 7.  A find method that can deal with source bundles is a much higher level thing and doesn't go here.  I think it goes somewhere around the EclipseTouchpoint
Comment 14 Patrick Higgins CLA 2009-12-16 17:15:28 EST
(In reply to comment #13)
> Looking at P2Utils.readBundles, I don't see how we get this.  I'm not sure how
> a shared install changes things, I will need to talk to some of the others.
> I don't believe there are 2 cases (useConfigArea) for base, as far as I can
> see, the code that is loading the bundles.info to actually start eclipse is
> resolving against osgi.install.area (Location.INSTALL_FILTER).

You may be right about this. I have only tried to resolve plugins that are installed in osgi.install.area with the P2Utils code.

However, when I install plugins into my personal area using the software update feature, they go into ~/.eclipse/155965261/plugins

I have created another version of my patch for bug 297663 that fixes this problem and gets rid of useConfigArea. I've also attached the modified version of P2Utils.java so that you can review the change directly.

I hope it can be of some use in creating the official API for this.
Comment 15 Patrick Higgins CLA 2009-12-16 18:55:42 EST
(In reply to comment #14)
> I have created another version of my patch for bug 297663 that fixes this
> problem and gets rid of useConfigArea. I've also attached the modified version
> of P2Utils.java so that you can review the change directly.

I updated my patch for bug 297663 again because the previous version did not check the install location for plugins.

I think this version is easier to understand and more correct than the original P2Utils as shipped in version 3.5.1.
Comment 16 Andrew Niefer CLA 2010-03-01 18:34:47 EST
Created attachment 160555 [details]
current patch
Comment 17 Andrew Niefer CLA 2010-03-02 18:11:56 EST
Created attachment 160707 [details]
patch to p2 & pde.build
Comment 18 Andrew Niefer CLA 2010-03-02 18:12:26 EST
Created attachment 160708 [details]
patch to jdt junit
Comment 19 Andrew Niefer CLA 2010-03-02 18:12:48 EST
Created attachment 160710 [details]
patch to pde
Comment 20 Andrew Niefer CLA 2010-03-02 18:14:12 EST
Curtis, Dani, Markus, can you please take a look at the JDT & PDE sides of this change.

It would be nice to get this in Wednesday if possible.
Comment 21 Curtis Windatt CLA 2010-03-03 15:30:33 EST
The PDE patch is fine, ready to commit.  Are we putting in the changes today?
Comment 22 Andrew Niefer CLA 2010-03-03 15:46:47 EST
(In reply to comment #21)
> The PDE patch is fine, ready to commit.  Are we putting in the changes today?

We need a response from JDT first.
Comment 23 Markus Keller CLA 2010-03-04 09:13:07 EST
Looks good, but I could not really test it in the wild due to bug 304669.

API problems:
- The new BundleInfo needs Javadoc. E.g. the format of getVersion must be specified (a valid argument for the org.osgi.framework.Version.Version(String)). You also have to specify which properties can be null (and make sure the others are never null).
- The Javadoc of SimpleConfiguratorManipulator has bugs and is incomplete. Please enable more checks in Java Compiler > Javadoc. E.g. "@param bundleInfoPath:" is wrong (there must be a space after the parameter name, and the colon should be removed).
The loadConfiguration methods are missing @return descriptions. The API should specify that the returned BundleInfo objects are fully resolved, so e.g. their getVersion() methods always return a version.

Compile errors with the patches:

- org.eclipse.pde.build's manifest misses update of Import-Package:
org.eclipse.equinox.internal.simpleconfigurator.manipulator ('provisional' removed)

- org.eclipse.pde.api.tools.ui also declares
Require-Bundle: org.eclipse.equinox.frameworkadmin;bundle-version="[1.0.100,2.0.0)"
=> version also needs to be increased in that plug-in

I'm ready to release the JUnit patch for N20100304-2000.
Comment 24 Markus Keller CLA 2010-03-04 09:28:33 EST
Looking closer at the patch, I realized that we're still missing API that tells us the location of the source.info and bundles.info files in 
org.eclipse.jdt.internal.junit.buildpath.P2Utils: SRC_INFO_PATH, BUNDLE_INFO_PATH.
Comment 25 Andrew Niefer CLA 2010-03-04 11:47:37 EST
Created attachment 160958 [details]
update jdt patch

Updated JDT patch.  Note in particular passing null to loadConfiguration(BundleContext, String) to get the bundles.info for the running system
Comment 26 Andrew Niefer CLA 2010-03-04 11:48:58 EST
Created attachment 160959 [details]
updated p2 & build

Updated patch with javadoc and small changes to BundleInfo
Comment 27 Andrew Niefer CLA 2010-03-04 11:49:57 EST
Created attachment 160960 [details]
updated pde

Updated PDE patch
Comment 28 Andrew Niefer CLA 2010-03-04 11:54:29 EST
Created attachment 160963 [details]
api tools manifest patch

Patch to update api.tools.ui manifest with new version range
Comment 29 Andrew Niefer CLA 2010-03-04 12:04:51 EST
Created attachment 160970 [details]
Updated JDT

Updated jdt patch with suggestion from Markus to define a SOURCE_INFO, if loadConfiguration(BundleContext, String) has string == SOURCE_INFO, we load the default source info, which today is just SOURCE_INFO_PATH but could conceivably change in the future.
Comment 30 Andrew Niefer CLA 2010-03-04 12:06:10 EST
Created attachment 160971 [details]
update p2 / build

change for the SOURCE_INFO
Comment 31 Olivier Thomann CLA 2010-03-04 12:07:57 EST
(In reply to comment #28)
> Created an attachment (id=160963) [details]
> api tools manifest patch
> Patch to update api.tools.ui manifest with new version range
Committed.
Comment 32 Andrew Niefer CLA 2010-03-04 12:29:56 EST
p2 & PDE/Build changes are released.  Olivier released the api tools patch.
Markus is doing JDT & Curtis is doing PDE.
We will be tagging this for the warmup build.