Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--bundles/org.eclipse.equinox.p2.garbagecollector/META-INF/MANIFEST.MF1
-rw-r--r--bundles/org.eclipse.equinox.p2.garbagecollector/src/org/eclipse/equinox/internal/p2/garbagecollector/Application.java2
-rw-r--r--bundles/org.eclipse.equinox.p2.garbagecollector/src/org/eclipse/equinox/internal/p2/garbagecollector/CoreGarbageCollector.java12
-rw-r--r--bundles/org.eclipse.equinox.p2.garbagecollector/src/org/eclipse/equinox/internal/p2/garbagecollector/GarbageCollector.java12
-rw-r--r--bundles/org.eclipse.equinox.p2.garbagecollector/src/org/eclipse/equinox/internal/p2/garbagecollector/GarbageCollectorHelper.java (renamed from bundles/org.eclipse.equinox.p2.garbagecollector/src/org/eclipse/equinox/internal/p2/garbagecollector/GCActivator.java)21
5 files changed, 13 insertions, 35 deletions
diff --git a/bundles/org.eclipse.equinox.p2.garbagecollector/META-INF/MANIFEST.MF b/bundles/org.eclipse.equinox.p2.garbagecollector/META-INF/MANIFEST.MF
index 749675c25..89e6d2e65 100644
--- a/bundles/org.eclipse.equinox.p2.garbagecollector/META-INF/MANIFEST.MF
+++ b/bundles/org.eclipse.equinox.p2.garbagecollector/META-INF/MANIFEST.MF
@@ -3,7 +3,6 @@ Bundle-ManifestVersion: 2
Bundle-Name: %pluginName
Bundle-SymbolicName: org.eclipse.equinox.p2.garbagecollector;singleton:=true
Bundle-Version: 1.1.400.qualifier
-Bundle-Activator: org.eclipse.equinox.internal.p2.garbagecollector.GCActivator
Bundle-Vendor: %providerName
Bundle-Localization: plugin
Export-Package: org.eclipse.equinox.internal.p2.garbagecollector;x-friends:="org.eclipse.equinox.p2.touchpoint.eclipse,org.eclipse.pde.core,org.eclipse.equinox.p2.ui.sdk.scheduler"
diff --git a/bundles/org.eclipse.equinox.p2.garbagecollector/src/org/eclipse/equinox/internal/p2/garbagecollector/Application.java b/bundles/org.eclipse.equinox.p2.garbagecollector/src/org/eclipse/equinox/internal/p2/garbagecollector/Application.java
index bb1cc4bdf..740f3dc83 100644
--- a/bundles/org.eclipse.equinox.p2.garbagecollector/src/org/eclipse/equinox/internal/p2/garbagecollector/Application.java
+++ b/bundles/org.eclipse.equinox.p2.garbagecollector/src/org/eclipse/equinox/internal/p2/garbagecollector/Application.java
@@ -56,7 +56,7 @@ public class Application implements IApplication {
}
private void initializeServices() throws ProvisionException {
- IProvisioningAgentProvider provider = GCActivator.getService(IProvisioningAgentProvider.class);
+ IProvisioningAgentProvider provider = GarbageCollectorHelper.getService(IProvisioningAgentProvider.class);
agent = provider.createAgent(null);
}
diff --git a/bundles/org.eclipse.equinox.p2.garbagecollector/src/org/eclipse/equinox/internal/p2/garbagecollector/CoreGarbageCollector.java b/bundles/org.eclipse.equinox.p2.garbagecollector/src/org/eclipse/equinox/internal/p2/garbagecollector/CoreGarbageCollector.java
index 172c25e77..eefcb0a55 100644
--- a/bundles/org.eclipse.equinox.p2.garbagecollector/src/org/eclipse/equinox/internal/p2/garbagecollector/CoreGarbageCollector.java
+++ b/bundles/org.eclipse.equinox.p2.garbagecollector/src/org/eclipse/equinox/internal/p2/garbagecollector/CoreGarbageCollector.java
@@ -25,11 +25,10 @@ import org.eclipse.equinox.p2.repository.artifact.IArtifactRepository;
* are not mapped to be an IArtifactKey in the MarkSet.
*/
public class CoreGarbageCollector {
-
/**
* When set to true, information will be logged every time an artifact is removed
*/
- static boolean debugMode = false;
+ private static boolean DEBUG = "true".equalsIgnoreCase(GarbageCollectorHelper.ID + "/debug"); //$NON-NLS-1$ //$NON-NLS-2$
/**
* Given a list of IArtifactKeys and an IArtifactRepository, removes all artifacts
@@ -42,18 +41,11 @@ public class CoreGarbageCollector {
aRepository.executeBatch(monitor -> {
for (IArtifactKey key : aRepository.query(query, null)) {
aRepository.removeDescriptor(key, new NullProgressMonitor());
- if (debugMode) {
+ if (DEBUG) {
Tracing.debug("Key removed:" + key); //$NON-NLS-1$
}
}
}, new NullProgressMonitor());
}
- /*
- * If set to true, debug mode will log information about each artifact deleted by the CoreGarbageCollector
- * @param inDebugMode
- */
- public static void setDebugMode(boolean inDebugMode) {
- debugMode = inDebugMode;
- }
}
diff --git a/bundles/org.eclipse.equinox.p2.garbagecollector/src/org/eclipse/equinox/internal/p2/garbagecollector/GarbageCollector.java b/bundles/org.eclipse.equinox.p2.garbagecollector/src/org/eclipse/equinox/internal/p2/garbagecollector/GarbageCollector.java
index 0487aae50..12b7780fc 100644
--- a/bundles/org.eclipse.equinox.p2.garbagecollector/src/org/eclipse/equinox/internal/p2/garbagecollector/GarbageCollector.java
+++ b/bundles/org.eclipse.equinox.p2.garbagecollector/src/org/eclipse/equinox/internal/p2/garbagecollector/GarbageCollector.java
@@ -61,7 +61,7 @@ public class GarbageCollector implements SynchronousProvisioningListener, IAgent
@Override
public void handleException(Throwable exception) {
- LogHelper.log(new Status(IStatus.ERROR, GCActivator.ID, Messages.Error_in_extension, exception));
+ LogHelper.log(new Status(IStatus.ERROR, GarbageCollectorHelper.ID, Messages.Error_in_extension, exception));
}
@Override
@@ -77,7 +77,7 @@ public class GarbageCollector implements SynchronousProvisioningListener, IAgent
private static final String ATTRIBUTE_CLASS = "class"; //$NON-NLS-1$
- private static final String PT_MARKSET = GCActivator.ID + ".marksetproviders"; //$NON-NLS-1$
+ private static final String PT_MARKSET = GarbageCollectorHelper.ID + ".marksetproviders"; //$NON-NLS-1$
final IProvisioningAgent agent;
//The GC is triggered when an uninstall event occurred during a "transaction" and the transaction is committed.
@@ -122,13 +122,13 @@ public class GarbageCollector implements SynchronousProvisioningListener, IAgent
}
protected boolean getBooleanPreference(String key, boolean defaultValue) {
- IPreferencesService prefService = GCActivator.getService(IPreferencesService.class);
+ IPreferencesService prefService = GarbageCollectorHelper.getService(IPreferencesService.class);
if (prefService == null)
return defaultValue;
List<IEclipsePreferences> nodes = new ArrayList<>();
// todo we should look in the instance scope as well but have to be careful that the instance location has been set
- nodes.add(ConfigurationScope.INSTANCE.getNode(GCActivator.ID));
- nodes.add(DefaultScope.INSTANCE.getNode(GCActivator.ID));
+ nodes.add(ConfigurationScope.INSTANCE.getNode(GarbageCollectorHelper.ID));
+ nodes.add(DefaultScope.INSTANCE.getNode(GarbageCollectorHelper.ID));
return Boolean.parseBoolean(prefService.get(key, Boolean.toString(defaultValue), nodes.toArray(new Preferences[nodes.size()])));
}
@@ -150,7 +150,7 @@ public class GarbageCollector implements SynchronousProvisioningListener, IAgent
} else if (o instanceof CommitOperationEvent) {
if (uninstallEventProfileId != null) {
CommitOperationEvent event = (CommitOperationEvent) o;
- if (uninstallEventProfileId.equals(event.getProfile().getProfileId()) && getBooleanPreference(GCActivator.GC_ENABLED, true))
+ if (uninstallEventProfileId.equals(event.getProfile().getProfileId()) && getBooleanPreference(GarbageCollectorHelper.GC_ENABLED, true))
runGC(event.getProfile());
uninstallEventProfileId = null;
}
diff --git a/bundles/org.eclipse.equinox.p2.garbagecollector/src/org/eclipse/equinox/internal/p2/garbagecollector/GCActivator.java b/bundles/org.eclipse.equinox.p2.garbagecollector/src/org/eclipse/equinox/internal/p2/garbagecollector/GarbageCollectorHelper.java
index f9632021e..130cd6d3e 100644
--- a/bundles/org.eclipse.equinox.p2.garbagecollector/src/org/eclipse/equinox/internal/p2/garbagecollector/GCActivator.java
+++ b/bundles/org.eclipse.equinox.p2.garbagecollector/src/org/eclipse/equinox/internal/p2/garbagecollector/GarbageCollectorHelper.java
@@ -13,18 +13,16 @@
*******************************************************************************/
package org.eclipse.equinox.internal.p2.garbagecollector;
-import org.eclipse.osgi.service.debug.DebugOptions;
import org.osgi.framework.*;
-public class GCActivator implements BundleActivator {
+public class GarbageCollectorHelper {
+
public static final String ID = "org.eclipse.equinox.p2.garbagecollector"; //$NON-NLS-1$
public static final String GC_ENABLED = "gc_enabled"; //$NON-NLS-1$
- private static final String DEBUG_STRING = GCActivator.ID + "/debug"; //$NON-NLS-1$
- private static final boolean DEFAULT_DEBUG = false;
- static BundleContext context;
static <T> T getService(Class<T> clazz) {
+ BundleContext context = FrameworkUtil.getBundle(GarbageCollectorHelper.class).getBundleContext();
ServiceReference<T> reference = context.getServiceReference(clazz);
if (reference == null)
return null;
@@ -33,17 +31,6 @@ public class GCActivator implements BundleActivator {
return result;
}
- @Override
- public void start(BundleContext inContext) throws Exception {
- GCActivator.context = inContext;
- DebugOptions debug = getService(DebugOptions.class);
- if (debug != null) {
- CoreGarbageCollector.setDebugMode(debug.getBooleanOption(DEBUG_STRING, DEFAULT_DEBUG));
- }
- }
- @Override
- public void stop(BundleContext inContext) throws Exception {
- GCActivator.context = null;
- }
+
}

Back to the top