[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[p2-dev] Questions about Queries

HI all again,

it looks like my trouble with the prestartupdate has been a timing problem. one needs to start the p2.engine and give the service time to be registered. maybe you could fix that in the example.

But now I have the next questions. I have a client-server scenario where client and server must match. so the client asks the server for his version at startup and then looks for updates.

I try that by providing a Policy that goes like this: (Is a little bit ugly as Ive reads that I have to register the Policy early, but the server version can be queried only after login time). I guess I could use the default policy and onle set the query, but for now this should be my first hops with this.

public class VersionPolicy extends Policy {

private String serverVersion;

public void setServerVersion(String serverVersion) {
this.serverVersion = serverVersion;

public IQuery<IInstallableUnit> getVisibleAvailableIUQuery() {
if (serverVersion == null) {
throw new IllegalStateException("Policy not initialized yet");
String[] version = serverVersion.split("\\.");
int major = Integer.parseInt(version[0]);
int minor = Integer.parseInt(version[1]);
int micro = Integer.parseInt(version[2]);

IQuery<IInstallableUnit> query = QueryUtil.createIUQuery("de.eiswind.mango.client.core.mango", new VersionRange(Version.createOSGi(major,
minor, micro), true, Version.createOSGi(major, minor, micro + 1), false));
return query;


I register the policy as shown in the cloud example in my core Activator.

I guessed the IU form the director output:

 [p2.director] Installing de.eiswind.mango.client.core.mango

Is this already my mistake ?

when I upload a new build with a new qualifier the UpdateOperation still says

!ENTRY de.eiswind.mango.client.core 1 0 2010-05-16 12:01:54.641
!MESSAGE Checking for updates

!ENTRY de.eiswind.mango.client.core 1 0 2010-05-16 12:01:55.438
!MESSAGE Done.10000

!ENTRY org.eclipse.equinox.p2.operations 1 10000 2010-05-16 12:01:55.439
!MESSAGE No updates were found.

And if I get this to work the next question would be how I could query for "any" iu (i.e. other features installed by the user) that has the same versionrange.

Any hints would be really appreciated.