Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'bundles/org.eclipse.equinox.p2.metadata.repository/src/org/eclipse/equinox/internal/p2/metadata/repository/Activator.java')
-rw-r--r--bundles/org.eclipse.equinox.p2.metadata.repository/src/org/eclipse/equinox/internal/p2/metadata/repository/Activator.java78
1 files changed, 29 insertions, 49 deletions
diff --git a/bundles/org.eclipse.equinox.p2.metadata.repository/src/org/eclipse/equinox/internal/p2/metadata/repository/Activator.java b/bundles/org.eclipse.equinox.p2.metadata.repository/src/org/eclipse/equinox/internal/p2/metadata/repository/Activator.java
index 0706b2556..59e004922 100644
--- a/bundles/org.eclipse.equinox.p2.metadata.repository/src/org/eclipse/equinox/internal/p2/metadata/repository/Activator.java
+++ b/bundles/org.eclipse.equinox.p2.metadata.repository/src/org/eclipse/equinox/internal/p2/metadata/repository/Activator.java
@@ -11,10 +11,8 @@
*******************************************************************************/
package org.eclipse.equinox.internal.p2.metadata.repository;
-import org.eclipse.equinox.internal.p2.core.helpers.ServiceHelper;
-import org.eclipse.equinox.internal.provisional.p2.core.eventbus.IProvisioningEventBus;
-import org.eclipse.equinox.internal.provisional.p2.core.location.AgentLocation;
-import org.eclipse.equinox.internal.provisional.p2.metadata.repository.IMetadataRepositoryManager;
+import org.eclipse.equinox.p2.core.IProvisioningAgent;
+import org.eclipse.equinox.p2.repository.metadata.IMetadataRepositoryManager;
import org.osgi.framework.*;
import org.osgi.util.tracker.ServiceTracker;
import org.osgi.util.tracker.ServiceTrackerCustomizer;
@@ -25,66 +23,48 @@ public class Activator implements BundleActivator, ServiceTrackerCustomizer {
public static final String REPO_PROVIDER_XPT = ID + '.' + "metadataRepositories"; //$NON-NLS-1$
private static BundleContext bundleContext;
- private static CacheManager cacheManager;
private ServiceRegistration repositoryManagerRegistration;
- private MetadataRepositoryManager repositoryManager;
- private ServiceTracker busTracker;
+ private ServiceTracker tracker;
public static BundleContext getContext() {
return bundleContext;
}
- public static CacheManager getCacheManager() {
- return cacheManager;
+ public Object addingService(ServiceReference reference) {
+ if (repositoryManagerRegistration == null) {
+ //TODO: eventually we shouldn't register a singleton manager automatically
+ IProvisioningAgent agent = (IProvisioningAgent) bundleContext.getService(reference);
+ IMetadataRepositoryManager manager = (MetadataRepositoryManager) agent.getService(IMetadataRepositoryManager.SERVICE_NAME);
+ repositoryManagerRegistration = bundleContext.registerService(IMetadataRepositoryManager.SERVICE_NAME, manager, null);
+ return agent;
+ }
+ return null;
}
- public void start(BundleContext context) throws Exception {
- //TODO eventually there should be no singleton repository manager registered
- Activator.bundleContext = context;
- cacheManager = new CacheManager((AgentLocation) ServiceHelper.getService(context, AgentLocation.SERVICE_NAME));
- repositoryManager = new MetadataRepositoryManager();
- repositoryManagerRegistration = context.registerService(IMetadataRepositoryManager.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 modifiedService(ServiceReference reference, Object service) {
+ // nothing to do
}
- public void stop(BundleContext context) throws Exception {
- IProvisioningEventBus bus = (IProvisioningEventBus) busTracker.getService();
- if (cacheManager != null) {
- cacheManager.unsetEventBus(bus);
- cacheManager = null;
- }
- Activator.bundleContext = null;
- if (repositoryManagerRegistration != null)
+ public void removedService(ServiceReference reference, Object service) {
+ if (repositoryManagerRegistration != null) {
repositoryManagerRegistration.unregister();
- repositoryManagerRegistration = null;
- if (repositoryManager != null) {
- repositoryManager.shutdown();
- repositoryManager = null;
+ repositoryManagerRegistration = null;
}
}
- public Object addingService(ServiceReference reference) {
- IProvisioningEventBus bus = (IProvisioningEventBus) bundleContext.getService(reference);
- if (repositoryManager != null)
- repositoryManager.setEventBus(bus);
- if (cacheManager != null)
- cacheManager.setEventBus(bus);
- return bus;
+ public void start(BundleContext aContext) throws Exception {
+ bundleContext = aContext;
+ //only want to register a service for the agent of the currently running system
+ String filter = "(&(objectClass=" + IProvisioningAgent.SERVICE_NAME + ")(agent.current=true))"; //$NON-NLS-1$ //$NON-NLS-2$
+ tracker = new ServiceTracker(aContext, aContext.createFilter(filter), this);
+ tracker.open();
}
- public void modifiedService(ServiceReference reference, Object service) {
- // ignored
-
- }
-
- public void removedService(ServiceReference reference, Object service) {
- final IProvisioningEventBus bus = (IProvisioningEventBus) service;
- if (repositoryManager != null)
- repositoryManager.unsetEventBus(bus);
- if (cacheManager != null)
- cacheManager.unsetEventBus(bus);
+ public void stop(BundleContext aContext) throws Exception {
+ if (tracker != null) {
+ tracker.close();
+ tracker = null;
+ }
+ bundleContext = null;
}
}

Back to the top