Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorThomas Hallgren2010-02-22 01:10:11 +0000
committerThomas Hallgren2010-02-22 01:10:11 +0000
commit8aa5a700fd1df2f75541c1329747668a0eb1716e (patch)
tree85a71b311400712ede104e6ebc524662633f745f /bundles/org.eclipse.equinox.p2.ui.sdk.scheduler
parent9dc753efb1afeb1c6778b8338f01c80919e8b143 (diff)
downloadrt.equinox.p2-8aa5a700fd1df2f75541c1329747668a0eb1716e.tar.gz
rt.equinox.p2-8aa5a700fd1df2f75541c1329747668a0eb1716e.tar.xz
rt.equinox.p2-8aa5a700fd1df2f75541c1329747668a0eb1716e.zip
302201 : Unify the two query approaches used in p2, step 3.
Diffstat (limited to 'bundles/org.eclipse.equinox.p2.ui.sdk.scheduler')
-rw-r--r--bundles/org.eclipse.equinox.p2.ui.sdk.scheduler/META-INF/MANIFEST.MF1
-rw-r--r--bundles/org.eclipse.equinox.p2.ui.sdk.scheduler/src/org/eclipse/equinox/internal/p2/ui/sdk/scheduler/AutomaticUpdateScheduler.java45
2 files changed, 3 insertions, 43 deletions
diff --git a/bundles/org.eclipse.equinox.p2.ui.sdk.scheduler/META-INF/MANIFEST.MF b/bundles/org.eclipse.equinox.p2.ui.sdk.scheduler/META-INF/MANIFEST.MF
index 743825dcf..cbca47dcd 100644
--- a/bundles/org.eclipse.equinox.p2.ui.sdk.scheduler/META-INF/MANIFEST.MF
+++ b/bundles/org.eclipse.equinox.p2.ui.sdk.scheduler/META-INF/MANIFEST.MF
@@ -21,6 +21,7 @@ Import-Package: com.ibm.icu.util;version="4.0.1",
org.eclipse.equinox.internal.provisional.p2.updatechecker,
org.eclipse.equinox.p2.core,
org.eclipse.equinox.p2.engine,
+ org.eclipse.equinox.p2.engine.query,
org.eclipse.equinox.p2.metadata,
org.eclipse.equinox.p2.metadata.query,
org.eclipse.equinox.p2.operations,
diff --git a/bundles/org.eclipse.equinox.p2.ui.sdk.scheduler/src/org/eclipse/equinox/internal/p2/ui/sdk/scheduler/AutomaticUpdateScheduler.java b/bundles/org.eclipse.equinox.p2.ui.sdk.scheduler/src/org/eclipse/equinox/internal/p2/ui/sdk/scheduler/AutomaticUpdateScheduler.java
index b422333d7..cfb42f3cc 100644
--- a/bundles/org.eclipse.equinox.p2.ui.sdk.scheduler/src/org/eclipse/equinox/internal/p2/ui/sdk/scheduler/AutomaticUpdateScheduler.java
+++ b/bundles/org.eclipse.equinox.p2.ui.sdk.scheduler/src/org/eclipse/equinox/internal/p2/ui/sdk/scheduler/AutomaticUpdateScheduler.java
@@ -18,9 +18,9 @@ import org.eclipse.equinox.internal.provisional.p2.updatechecker.*;
import org.eclipse.equinox.p2.core.IProvisioningAgent;
import org.eclipse.equinox.p2.engine.IProfile;
import org.eclipse.equinox.p2.engine.IProfileRegistry;
+import org.eclipse.equinox.p2.engine.query.IUProfilePropertyQuery;
import org.eclipse.equinox.p2.metadata.IInstallableUnit;
import org.eclipse.equinox.p2.query.IQuery;
-import org.eclipse.equinox.p2.query.MatchQuery;
import org.eclipse.jface.preference.IPreferenceStore;
import org.eclipse.ui.IStartup;
import org.eclipse.ui.statushandlers.StatusManager;
@@ -61,47 +61,6 @@ public class AutomaticUpdateScheduler implements IStartup {
}
/**
- * A query that searches for {@link IInstallableUnit} instances that have
- * a property associated with the specified profile, whose value matches the provided value.
- * Uses the profile id instead of the profile to reference the profile.
- * The profile instance is cached only during the duration of the query.
- * This query is used instead of IUProfilePropertyQuery because we pass
- * this query to the automatic update checker and it will be referenced during
- * the life of the platform.
- */
- private class IUProfilePropertyByIdQuery extends MatchQuery<IInstallableUnit> {
- private final String propertyName;
- private IProfile cachedProfile;
-
- /**
- * Creates a new query on the given property name and value.
- */
- public IUProfilePropertyByIdQuery(String propertyName) {
- this.propertyName = propertyName;
- }
-
- private IProfile getProfile() {
- if (cachedProfile == null) {
- IProvisioningAgent agent = (IProvisioningAgent) ServiceHelper.getService(AutomaticUpdatePlugin.getContext(), IProvisioningAgent.SERVICE_NAME);
- IProfileRegistry profileRegistry = (IProfileRegistry) agent.getService(IProfileRegistry.SERVICE_NAME);
- if (profileRegistry != null)
- cachedProfile = profileRegistry.getProfile(profileId);
- }
- return cachedProfile;
- }
-
- // overridden to release profile cache
- public void postPerform() {
- cachedProfile = null;
- }
-
- public boolean isMatch(IInstallableUnit candidate) {
- IProfile profile = getProfile();
- return profile != null && Boolean.valueOf(profile.getInstallableUnitProperty(candidate, propertyName)).booleanValue();
- }
- }
-
- /**
* The constructor.
*/
public AutomaticUpdateScheduler() {
@@ -170,7 +129,7 @@ public class AutomaticUpdateScheduler implements IStartup {
private IQuery<IInstallableUnit> getProfileQuery() {
// We specifically avoid using the default policy's root property so that we don't load all the
// p2 UI classes in doing so.
- return new IUProfilePropertyByIdQuery(IProfile.PROP_PROFILE_ROOT_IU);
+ return new IUProfilePropertyQuery(IProfile.PROP_PROFILE_ROOT_IU, Boolean.TRUE.toString());
}
private int getDay(IPreferenceStore pref) {

Back to the top