Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJohn Arthorne2011-07-20 20:11:45 +0000
committerJohn Arthorne2011-07-20 20:11:45 +0000
commit8e18cfac75439f05e28030ebfcb5f92bb9ae073e (patch)
tree3692fe549e7014f4eef9fe2f534ea3a4d5ab77d2 /bundles/org.eclipse.equinox.p2.ui.sdk.scheduler/src/org/eclipse/equinox/internal/p2
parentba8353183f59fd31f14b177968763af636edbb8a (diff)
downloadrt.equinox.p2-8e18cfac75439f05e28030ebfcb5f92bb9ae073e.tar.gz
rt.equinox.p2-8e18cfac75439f05e28030ebfcb5f92bb9ae073e.tar.xz
rt.equinox.p2-8e18cfac75439f05e28030ebfcb5f92bb9ae073e.zip
Bug 232356 - [GC] Option to remove the plugins automatically when
uninstall feature
Diffstat (limited to 'bundles/org.eclipse.equinox.p2.ui.sdk.scheduler/src/org/eclipse/equinox/internal/p2')
-rw-r--r--bundles/org.eclipse.equinox.p2.ui.sdk.scheduler/src/org/eclipse/equinox/internal/p2/ui/sdk/scheduler/AutomaticUpdatePlugin.java7
-rw-r--r--bundles/org.eclipse.equinox.p2.ui.sdk.scheduler/src/org/eclipse/equinox/internal/p2/ui/sdk/scheduler/AutomaticUpdateScheduler.java29
-rw-r--r--bundles/org.eclipse.equinox.p2.ui.sdk.scheduler/src/org/eclipse/equinox/internal/p2/ui/sdk/scheduler/PreferenceConstants.java3
3 files changed, 35 insertions, 4 deletions
diff --git a/bundles/org.eclipse.equinox.p2.ui.sdk.scheduler/src/org/eclipse/equinox/internal/p2/ui/sdk/scheduler/AutomaticUpdatePlugin.java b/bundles/org.eclipse.equinox.p2.ui.sdk.scheduler/src/org/eclipse/equinox/internal/p2/ui/sdk/scheduler/AutomaticUpdatePlugin.java
index 25bd314e6..a4dac61fd 100644
--- a/bundles/org.eclipse.equinox.p2.ui.sdk.scheduler/src/org/eclipse/equinox/internal/p2/ui/sdk/scheduler/AutomaticUpdatePlugin.java
+++ b/bundles/org.eclipse.equinox.p2.ui.sdk.scheduler/src/org/eclipse/equinox/internal/p2/ui/sdk/scheduler/AutomaticUpdatePlugin.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2008, 2010 IBM Corporation and others.
+ * Copyright (c) 2008, 2011 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -30,7 +30,10 @@ import org.osgi.framework.BundleContext;
import org.osgi.framework.ServiceReference;
/**
- * Activator class for the automatic updates plugin
+ * Activator class for the automatic updates plugin. The automatic updates plugin
+ * is responsible for scheduling background update checks, based on update settings
+ * specified by end user settings. The implementation of update checking is provided
+ * by another plugin that provides an IUpdateChecker implementation.
*/
public class AutomaticUpdatePlugin extends AbstractUIPlugin {
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 cfb42f3cc..785a01845 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
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2008, 2010 IBM Corporation and others.
+ * Copyright (c) 2008, 2011 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -14,6 +14,7 @@ import com.ibm.icu.util.Calendar;
import com.ibm.icu.util.ULocale;
import org.eclipse.core.runtime.*;
import org.eclipse.equinox.internal.p2.core.helpers.ServiceHelper;
+import org.eclipse.equinox.internal.p2.garbagecollector.GarbageCollector;
import org.eclipse.equinox.internal.provisional.p2.updatechecker.*;
import org.eclipse.equinox.p2.core.IProvisioningAgent;
import org.eclipse.equinox.p2.engine.IProfile;
@@ -77,9 +78,35 @@ public class AutomaticUpdateScheduler implements IStartup {
}
public void earlyStartup() {
+ garbageCollect();
scheduleUpdate();
}
+ /**
+ * Invokes the garbage collector to discard unused plugins, if specified by a
+ * corresponding preference.
+ */
+ private void garbageCollect() {
+ // Nothing to do if we don't know what profile we are checking
+ if (profileId == null)
+ return;
+ //check if gc is enabled
+ IPreferenceStore pref = AutomaticUpdatePlugin.getDefault().getPreferenceStore();
+ if (!pref.getBoolean(PreferenceConstants.PREF_GC_ON_STARTUP))
+ return;
+ IProvisioningAgent agent = (IProvisioningAgent) ServiceHelper.getService(AutomaticUpdatePlugin.getContext(), IProvisioningAgent.SERVICE_NAME);
+ GarbageCollector collector = (GarbageCollector) agent.getService(GarbageCollector.SERVICE_NAME);
+ if (collector == null)
+ return;
+ IProfileRegistry registry = (IProfileRegistry) agent.getService(IProfileRegistry.SERVICE_NAME);
+ if (registry == null)
+ return;
+ IProfile profile = registry.getProfile(profileId);
+ if (profile == null)
+ return;
+ collector.runGC(profile);
+ }
+
public void shutdown() {
removeUpdateListener();
}
diff --git a/bundles/org.eclipse.equinox.p2.ui.sdk.scheduler/src/org/eclipse/equinox/internal/p2/ui/sdk/scheduler/PreferenceConstants.java b/bundles/org.eclipse.equinox.p2.ui.sdk.scheduler/src/org/eclipse/equinox/internal/p2/ui/sdk/scheduler/PreferenceConstants.java
index 6f2de2be3..398c7da78 100644
--- a/bundles/org.eclipse.equinox.p2.ui.sdk.scheduler/src/org/eclipse/equinox/internal/p2/ui/sdk/scheduler/PreferenceConstants.java
+++ b/bundles/org.eclipse.equinox.p2.ui.sdk.scheduler/src/org/eclipse/equinox/internal/p2/ui/sdk/scheduler/PreferenceConstants.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2008, 2010 IBM Corporation and others.
+ * Copyright (c) 2008, 2011 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -28,4 +28,5 @@ public class PreferenceConstants {
public static final String PREF_REMIND_240Minutes = "4 Hours";//$NON-NLS-1$
public static final String PREF_AUTO_UPDATE_INIT = "autoUpdateInit"; //$NON-NLS-1$
public static final String PREF_MIGRATED_34 = "migrated34Prefs"; //$NON-NLS-1$
+ public static final String PREF_GC_ON_STARTUP = "gcOnStartup"; //$NON-NLS-1$
}

Back to the top