Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJohn Arthorne2009-09-22 22:34:29 -0400
committerJohn Arthorne2009-09-22 22:34:29 -0400
commitdda41c7d886f47b5cfabf1b38a089fdef1fcca51 (patch)
tree51f248b7fbb36d7d9a05006a7281b3f5984e47bd /bundles/org.eclipse.equinox.p2.artifact.repository
parent77b258a29011d589a1c2107185f1ba6c3197c2b4 (diff)
downloadrt.equinox.p2-dda41c7d886f47b5cfabf1b38a089fdef1fcca51.tar.gz
rt.equinox.p2-dda41c7d886f47b5cfabf1b38a089fdef1fcca51.tar.xz
rt.equinox.p2-dda41c7d886f47b5cfabf1b38a089fdef1fcca51.zip
Bug 290206 - Inject event bus into repository managers
Diffstat (limited to 'bundles/org.eclipse.equinox.p2.artifact.repository')
-rw-r--r--bundles/org.eclipse.equinox.p2.artifact.repository/META-INF/MANIFEST.MF2
-rw-r--r--bundles/org.eclipse.equinox.p2.artifact.repository/src/org/eclipse/equinox/internal/p2/artifact/repository/Activator.java29
2 files changed, 30 insertions, 1 deletions
diff --git a/bundles/org.eclipse.equinox.p2.artifact.repository/META-INF/MANIFEST.MF b/bundles/org.eclipse.equinox.p2.artifact.repository/META-INF/MANIFEST.MF
index 86959eb86..47a52bd07 100644
--- a/bundles/org.eclipse.equinox.p2.artifact.repository/META-INF/MANIFEST.MF
+++ b/bundles/org.eclipse.equinox.p2.artifact.repository/META-INF/MANIFEST.MF
@@ -56,6 +56,7 @@ Import-Package: javax.xml.parsers,
org.eclipse.equinox.internal.p2.repository,
org.eclipse.equinox.internal.p2.repository.helpers,
org.eclipse.equinox.internal.provisional.p2.core,
+ org.eclipse.equinox.internal.provisional.p2.core.eventbus,
org.eclipse.equinox.internal.provisional.p2.core.location,
org.eclipse.equinox.internal.provisional.p2.metadata,
org.eclipse.equinox.internal.provisional.p2.repository,
@@ -65,6 +66,7 @@ Import-Package: javax.xml.parsers,
org.eclipse.osgi.signedcontent;version="1.0.0",
org.eclipse.osgi.util;version="1.1.0",
org.osgi.framework;version="1.3.0",
+ org.osgi.util.tracker;version="1.4.0",
org.w3c.dom,
org.xml.sax;resolution:=optional
Bundle-Activator: org.eclipse.equinox.internal.p2.artifact.repository.Activator
diff --git a/bundles/org.eclipse.equinox.p2.artifact.repository/src/org/eclipse/equinox/internal/p2/artifact/repository/Activator.java b/bundles/org.eclipse.equinox.p2.artifact.repository/src/org/eclipse/equinox/internal/p2/artifact/repository/Activator.java
index 6343fb202..ee7fcd4a3 100644
--- a/bundles/org.eclipse.equinox.p2.artifact.repository/src/org/eclipse/equinox/internal/p2/artifact/repository/Activator.java
+++ b/bundles/org.eclipse.equinox.p2.artifact.repository/src/org/eclipse/equinox/internal/p2/artifact/repository/Activator.java
@@ -11,15 +11,19 @@
package org.eclipse.equinox.internal.p2.artifact.repository;
import org.eclipse.equinox.internal.provisional.p2.artifact.repository.IArtifactRepositoryManager;
+import org.eclipse.equinox.internal.provisional.p2.core.eventbus.IProvisioningEventBus;
import org.osgi.framework.*;
+import org.osgi.util.tracker.ServiceTracker;
+import org.osgi.util.tracker.ServiceTrackerCustomizer;
-public class Activator implements BundleActivator {
+public class Activator implements BundleActivator, ServiceTrackerCustomizer {
public static final String ID = "org.eclipse.equinox.p2.artifact.repository"; //$NON-NLS-1$
public static final String REPO_PROVIDER_XPT = ID + '.' + "artifactRepositories"; //$NON-NLS-1$
private static BundleContext context;
private ServiceRegistration repositoryManagerRegistration;
private ArtifactRepositoryManager repositoryManager;
+ private ServiceTracker busTracker;
public static BundleContext getContext() {
return Activator.context;
@@ -29,6 +33,11 @@ public class Activator implements BundleActivator {
Activator.context = aContext;
repositoryManager = new ArtifactRepositoryManager();
repositoryManagerRegistration = aContext.registerService(IArtifactRepositoryManager.class.getName(), repositoryManager, null);
+
+ // need to track event bus coming and going to make sure cache gets cleaned on
+ // repository removals
+ busTracker = new ServiceTracker(context, IProvisioningEventBus.SERVICE_NAME, this);
+ busTracker.open();
}
public void stop(BundleContext aContext) throws Exception {
@@ -40,6 +49,24 @@ public class Activator implements BundleActivator {
repositoryManager.shutdown();
repositoryManager = null;
}
+ busTracker.close();
+ }
+
+ public Object addingService(ServiceReference reference) {
+ IProvisioningEventBus bus = (IProvisioningEventBus) context.getService(reference);
+ if (repositoryManager != null)
+ repositoryManager.setEventBus(bus);
+ return bus;
+ }
+
+ public void modifiedService(ServiceReference reference, Object service) {
+ // ignored
+
+ }
+
+ public void removedService(ServiceReference reference, Object service) {
+ if (repositoryManager != null)
+ repositoryManager.unsetEventBus((IProvisioningEventBus) service);
}
}

Back to the top