Difference between revisions of "Equinox/p2/Helios Migration Guide"

From Eclipsepedia

< Equinox‎ | p2
Jump to: navigation, search
(IUPropertyQuery)
(IUPropertyQuery)
Line 40: Line 40:
 
The above will match all IInstallableUnits with a "foo" property whose value is "true".
 
The above will match all IInstallableUnits with a "foo" property whose value is "true".
  
[[Category:Equinox/p2]]
+
[[Category:Equinox p2]]

Revision as of 10:57, 25 January 2010

In the Helios release p2 graduated much of its provisional API into stable, real API. This page provides some guidance to users of the old provisional p2 API on how to migrate to the mature API in the Helios release.

Contents

Pervasive changes

Switch from global OSGi services to agent-specific services

Metadata changes

IRequiredCapability

IRequiredCapability was limiting in what it could express. For example it could not express negation and or'ing, and it could only described dependencies on something that had a namespace, a name and a version and we are striving to express requirements and capabilities on other things (for example BundleExecutionEnvironment). As such, to ensure for API evolution we have turned the too specific IRequiredCapability into an IRequirement.

Query changes

CapabilityQuery

CapabilityQuery from the provisional API has been deleted in favor of expressions. Thus the former:

 IRequiredCapability cap = ...;
 new CapabilityQuery(cap);

Can be written as:

 IRequirement cap = ...;
 new ExpressionQuery(IInstallableUnit.class, cap.getMatches());

Or, using Java 5 generics:

 IRequirement cap = ...;
 new ExpressionQuery<IInstallableUnit>(IInstallableUnit.class, 

cap.getMatches());

IUPropertyQuery

There is currently no direct API replacement for IUPropertyQuery, but the equivalent query can be performed using an expression query:

 new ExpressionQuery<IInstallableUnit>(IInstallableUnit.class,
    ExpressionUtil.parse("properties[$0] == $1"), "foo", "true");

The above will match all IInstallableUnits with a "foo" property whose value is "true".