diff options
author | dj | 2011-07-26 20:43:11 +0000 |
---|---|---|
committer | dj | 2011-07-26 20:43:11 +0000 |
commit | c5849e4e4b34eb67b11eba909ef2f61c71d30538 (patch) | |
tree | e627fb707d8a6a2e03fc2c33c6dbb71516219a0c | |
parent | 92cce123a25fe15794948814e080da4f8b22fa6d (diff) | |
download | rt.equinox.p2-bug340971.tar.gz rt.equinox.p2-bug340971.tar.xz rt.equinox.p2-bug340971.zip |
URL
3 files changed, 56 insertions, 2 deletions
diff --git a/bundles/org.eclipse.equinox.p2.core/META-INF/MANIFEST.MF b/bundles/org.eclipse.equinox.p2.core/META-INF/MANIFEST.MF index dc3c9e274..2e227ad9d 100644 --- a/bundles/org.eclipse.equinox.p2.core/META-INF/MANIFEST.MF +++ b/bundles/org.eclipse.equinox.p2.core/META-INF/MANIFEST.MF @@ -59,7 +59,8 @@ Export-Package: org.eclipse.equinox.internal.p2.core;x-friends:="org.eclipse.equ org.eclipse.equinox.p2.ui.admin, org.eclipse.equinox.p2.ui.sdk, org.eclipse.equinox.p2.ui.sdk.scheduler, - org.eclipse.equinox.p2.updatesite", + org.eclipse.equinox.p2.updatesite, + org.eclipse.equinox.p2.director.app", org.eclipse.equinox.p2.core;version="2.0.0", org.eclipse.equinox.p2.core.spi;version="2.0.0" Require-Bundle: org.eclipse.equinox.common;bundle-version="[3.5.0,4.0.0)" diff --git a/bundles/org.eclipse.equinox.p2.director.app/META-INF/MANIFEST.MF b/bundles/org.eclipse.equinox.p2.director.app/META-INF/MANIFEST.MF index 99d0b36e8..ab36a5845 100644 --- a/bundles/org.eclipse.equinox.p2.director.app/META-INF/MANIFEST.MF +++ b/bundles/org.eclipse.equinox.p2.director.app/META-INF/MANIFEST.MF @@ -15,7 +15,9 @@ Bundle-ActivationPolicy: lazy Import-Package: org.eclipse.equinox.app, org.eclipse.equinox.internal.p2.core.helpers, org.eclipse.equinox.internal.p2.director, + org.eclipse.equinox.internal.provisional.p2.core.eventbus, org.eclipse.equinox.internal.provisional.p2.director, + org.eclipse.equinox.internal.provisional.p2.repository, org.eclipse.equinox.p2.core;version="[2.0.0,3.0.0)", org.eclipse.equinox.p2.engine;version="[2.0.0,3.0.0)", org.eclipse.equinox.p2.engine.query;version="[2.0.0,3.0.0)", diff --git a/bundles/org.eclipse.equinox.p2.director.app/src/org/eclipse/equinox/internal/p2/director/app/DirectorApplication.java b/bundles/org.eclipse.equinox.p2.director.app/src/org/eclipse/equinox/internal/p2/director/app/DirectorApplication.java index 654e5d275..03a7569ad 100644 --- a/bundles/org.eclipse.equinox.p2.director.app/src/org/eclipse/equinox/internal/p2/director/app/DirectorApplication.java +++ b/bundles/org.eclipse.equinox.p2.director.app/src/org/eclipse/equinox/internal/p2/director/app/DirectorApplication.java @@ -24,8 +24,11 @@ import org.eclipse.equinox.app.IApplication; import org.eclipse.equinox.app.IApplicationContext; import org.eclipse.equinox.internal.p2.core.helpers.*; import org.eclipse.equinox.internal.p2.director.ProfileChangeRequest; +import org.eclipse.equinox.internal.provisional.p2.core.eventbus.IProvisioningEventBus; +import org.eclipse.equinox.internal.provisional.p2.core.eventbus.ProvisioningListener; import org.eclipse.equinox.internal.provisional.p2.director.IDirector; import org.eclipse.equinox.internal.provisional.p2.director.PlanExecutionHelper; +import org.eclipse.equinox.internal.provisional.p2.repository.RepositoryEvent; import org.eclipse.equinox.p2.core.*; import org.eclipse.equinox.p2.engine.*; import org.eclipse.equinox.p2.engine.query.UserVisibleRootQuery; @@ -34,6 +37,7 @@ import org.eclipse.equinox.p2.metadata.Version; import org.eclipse.equinox.p2.planner.IPlanner; import org.eclipse.equinox.p2.planner.IProfileChangeRequest; import org.eclipse.equinox.p2.query.*; +import org.eclipse.equinox.p2.repository.IRepository; import org.eclipse.equinox.p2.repository.artifact.IArtifactRepositoryManager; import org.eclipse.equinox.p2.repository.metadata.IMetadataRepositoryManager; import org.eclipse.osgi.framework.log.FrameworkLog; @@ -42,7 +46,7 @@ import org.eclipse.osgi.util.NLS; import org.osgi.framework.*; import org.osgi.service.packageadmin.PackageAdmin; -public class DirectorApplication implements IApplication { +public class DirectorApplication implements IApplication, ProvisioningListener { class AvoidTrustPromptService extends UIServices { @Override public AuthenticationInfo getUsernamePassword(String location) { @@ -607,6 +611,50 @@ public class DirectorApplication implements IApplication { throw new ProvisionException(Messages.Missing_Engine); targetAgent.registerService(UIServices.SERVICE_NAME, new AvoidTrustPromptService()); + + // TODO do we only want to do this if we are provisioning to ourself? + IProvisioningEventBus eventBus = (IProvisioningEventBus) targetAgent.getService(IProvisioningEventBus.SERVICE_NAME); + if (eventBus == null) + return; + eventBus.addListener(this); + + } + + /* (non-Javadoc) + * @see org.eclipse.equinox.internal.provisional.p2.core.eventbus.ProvisioningListener#notify(java.util.EventObject) + * + * See bug: https://bugs.eclipse.org/340971 + * Using the event bus to detect whether or not a repository was added in a touchpoint action. + * If it was, then (if it exists) remove it from our list of repos to remove after we complete our install. + */ + public void notify(EventObject o) { + if (!(o instanceof RepositoryEvent)) + return; + RepositoryEvent event = (RepositoryEvent) o; + if (RepositoryEvent.ADDED != event.getKind()) + return; + int type = event.getRepositoryType(); + URI location = event.getRepositoryLocation(); + if (IRepository.TYPE_ARTIFACT == type) { + for (int i = 0; i < artifactReposForRemoval.length; i++) { + if (artifactReposForRemoval[i] != null && URIUtil.sameURI(artifactReposForRemoval[i], (location))) { + artifactReposForRemoval[i] = null; + break; + } + } + // either found or not found. either way, we're done here + return; + } + if (IRepository.TYPE_METADATA == type) { + for (int i = 0; i < metadataReposForRemoval.length; i++) { + if (metadataReposForRemoval[i] != null && URIUtil.sameURI(metadataReposForRemoval[i], (location))) { + metadataReposForRemoval[i] = null; + break; + } + } + // either found or not found. either way, we're done here + return; + } } private void logStatus(IStatus status) { @@ -1217,6 +1265,9 @@ public class DirectorApplication implements IApplication { } public void stop() { + IProvisioningEventBus eventBus = (IProvisioningEventBus) targetAgent.getService(IProvisioningEventBus.SERVICE_NAME); + if (eventBus != null) + eventBus.removeListener(this); if (log != null) log.close(); } |