diff options
author | Pascal Rapicault (Ericsson) | 2013-02-11 16:25:30 +0000 |
---|---|---|
committer | Pascal Rapicault | 2013-02-11 16:25:30 +0000 |
commit | 825a4fd5a6bb07a479018dd4e082b87dabbe7257 (patch) | |
tree | 17d08a1f82d84286cca0218bd0871f56b47c84da | |
parent | 94a7e2fa8a276e96dd87d283088982a74b56472d (diff) | |
download | rt.equinox.p2-825a4fd5a6bb07a479018dd4e082b87dabbe7257.tar.gz rt.equinox.p2-825a4fd5a6bb07a479018dd4e082b87dabbe7257.tar.xz rt.equinox.p2-825a4fd5a6bb07a479018dd4e082b87dabbe7257.zip |
Bug 399987 - [shared] Installing using the director causes exception but
succeeds
-rw-r--r-- | bundles/org.eclipse.equinox.p2.director.app/src/org/eclipse/equinox/internal/p2/director/app/DirectorApplication.java | 27 |
1 files changed, 22 insertions, 5 deletions
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 69ee1a9a7..df28b5156 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 @@ -276,6 +276,7 @@ public class DirectorApplication implements IApplication, ProvisioningListener { private ILog log = null; private IProvisioningAgent targetAgent; + private boolean targetAgentIsSelfAndUp = false; private boolean noArtifactRepositorySpecified = false; private ProfileChangeRequest buildProvisioningRequest(IProfile profile, Collection<IInstallableUnit> installs, Collection<IInstallableUnit> uninstalls) { @@ -580,9 +581,23 @@ public class DirectorApplication implements IApplication, ProvisioningListener { } else { p2DataArea = null; } - targetAgent = provider.createAgent(p2DataArea); - targetAgent.registerService(IProvisioningAgent.INSTALLER_AGENT, provider.createAgent(null)); - + if (p2DataArea == null) { + final String currentAgentFiler = '(' + IProvisioningAgent.SERVICE_CURRENT + '=' + "true)"; //$NON-NLS-1$ + try { + Collection<ServiceReference<IProvisioningAgent>> refs; + refs = context.getServiceReferences(IProvisioningAgent.class, currentAgentFiler); + if (!refs.isEmpty()) { + targetAgent = context.getService(refs.iterator().next()); + targetAgentIsSelfAndUp = true; + } + } catch (InvalidSyntaxException e) { + //Can't happen the filter never changes + } + } + if (targetAgent == null) { + targetAgent = provider.createAgent(p2DataArea); + targetAgent.registerService(IProvisioningAgent.INSTALLER_AGENT, provider.createAgent(null)); + } context.ungetService(agentProviderRef); if (profileId == null) { if (destination != null) { @@ -647,6 +662,8 @@ public class DirectorApplication implements IApplication, ProvisioningListener { RepositoryEvent event = (RepositoryEvent) o; if (RepositoryEvent.ADDED != event.getKind()) return; + + //TODO BE CAREFUL SINCE WE ARE MODIFYING THE SELF PROFILE int type = event.getRepositoryType(); URI location = event.getRepositoryLocation(); if (IRepository.TYPE_ARTIFACT == type) { @@ -1015,8 +1032,8 @@ public class DirectorApplication implements IApplication, ProvisioningListener { private void cleanupServices() { BundleContext context = Activator.getContext(); - //dispose agent - if (targetAgent != null) { + //dispose agent, only if it is not already up and running + if (targetAgent != null && !targetAgentIsSelfAndUp) { targetAgent.stop(); targetAgent = null; } |