diff options
author | John Arthorne | 2010-01-25 19:21:18 +0000 |
---|---|---|
committer | John Arthorne | 2010-01-25 19:21:18 +0000 |
commit | f33b10ba91cde00bec16fefb97b303912bf80d4e (patch) | |
tree | 7e198733795750023ddfd5584e1ca7581bebf607 /bundles/org.eclipse.equinox.p2.installer | |
parent | a347364dc7d78e2b77251c8d9fba8e05bbf8444a (diff) | |
download | rt.equinox.p2-f33b10ba91cde00bec16fefb97b303912bf80d4e.tar.gz rt.equinox.p2-f33b10ba91cde00bec16fefb97b303912bf80d4e.tar.xz rt.equinox.p2-f33b10ba91cde00bec16fefb97b303912bf80d4e.zip |
Bug 300719 - Installer doesn't do agent service lookups
Diffstat (limited to 'bundles/org.eclipse.equinox.p2.installer')
2 files changed, 19 insertions, 44 deletions
diff --git a/bundles/org.eclipse.equinox.p2.installer/src/org/eclipse/equinox/internal/p2/installer/InstallApplication.java b/bundles/org.eclipse.equinox.p2.installer/src/org/eclipse/equinox/internal/p2/installer/InstallApplication.java index f928dca6c..5c376a731 100644 --- a/bundles/org.eclipse.equinox.p2.installer/src/org/eclipse/equinox/internal/p2/installer/InstallApplication.java +++ b/bundles/org.eclipse.equinox.p2.installer/src/org/eclipse/equinox/internal/p2/installer/InstallApplication.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2007, 2009 IBM Corporation and others. + * Copyright (c) 2007, 2010 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -21,7 +21,9 @@ import org.eclipse.equinox.internal.p2.core.helpers.LogHelper; import org.eclipse.equinox.internal.p2.installer.ui.SWTInstallAdvisor; import org.eclipse.equinox.internal.provisional.p2.installer.InstallAdvisor; import org.eclipse.equinox.internal.provisional.p2.installer.InstallDescription; -import org.osgi.framework.*; +import org.eclipse.equinox.p2.core.*; +import org.osgi.framework.BundleContext; +import org.osgi.framework.ServiceReference; /** * This is a simple installer application built using P2. The application must be given @@ -137,9 +139,9 @@ public class InstallApplication implements IApplication { InstallDescription description = null; try { description = computeInstallDescription(); - startRequiredBundles(description); + IProvisioningAgent agent = startAgent(description); //perform long running install operation - InstallUpdateProductOperation operation = new InstallUpdateProductOperation(InstallerActivator.getDefault().getContext(), description); + InstallUpdateProductOperation operation = new InstallUpdateProductOperation(agent, description); IStatus result = advisor.performInstall(operation); if (!result.isOK()) { LogHelper.log(result); @@ -156,6 +158,7 @@ public class InstallApplication implements IApplication { //TODO present the user an option to immediately start the product advisor.setResult(result); } + agent.stop(); } catch (OperationCanceledException e) { advisor.setResult(Status.CANCEL_STATUS); } catch (Exception e) { @@ -194,30 +197,16 @@ public class InstallApplication implements IApplication { /** * Starts the p2 bundles needed to continue with the install. */ - private void startRequiredBundles(InstallDescription description) throws CoreException { + private IProvisioningAgent startAgent(InstallDescription description) throws CoreException { IPath installLocation = description.getInstallLocation(); if (installLocation == null) throw fail(Messages.App_NoInstallLocation, null); //set agent location if specified IPath agentLocation = description.getAgentLocation(); - if (agentLocation != null) { - String agentArea = System.getProperty("eclipse.p2.data.area"); //$NON-NLS-1$ - // TODO a bit of a hack here. If the value is already set and it is set to @config/p2 then - // it may well be the default value put in by PDE. Overwrite it. - // Its kind of unclear why we would NOT overwrite. At this point the user set their choice - // of shared or standalone and those dicate where the agent should put its info... - if (agentArea == null || agentArea.length() == 0 || agentArea.startsWith("@config")) //$NON-NLS-1$ - System.setProperty("eclipse.p2.data.area", agentLocation.toOSString()); //$NON-NLS-1$ - } - //start up p2 try { - if (agentLocation != null) { - // reset the agent location - InstallerActivator.getDefault().getBundle("org.eclipse.equinox.p2.core").stop(Bundle.STOP_TRANSIENT); //$NON-NLS-1$ - InstallerActivator.getDefault().getBundle("org.eclipse.equinox.p2.core").start(Bundle.START_TRANSIENT); //$NON-NLS-1$ - } - InstallerActivator.getDefault().getBundle("org.eclipse.equinox.p2.exemplarysetup").start(Bundle.START_TRANSIENT); //$NON-NLS-1$ - } catch (BundleException e) { + IProvisioningAgentProvider provider = (IProvisioningAgentProvider) getService(InstallerActivator.getDefault().getContext(), IProvisioningAgentProvider.SERVICE_NAME); + return provider.createAgent(agentLocation == null ? null : agentLocation.toFile().toURI()); + } catch (ProvisionException e) { throw fail(Messages.App_FailedStart, e); } } diff --git a/bundles/org.eclipse.equinox.p2.installer/src/org/eclipse/equinox/internal/p2/installer/InstallUpdateProductOperation.java b/bundles/org.eclipse.equinox.p2.installer/src/org/eclipse/equinox/internal/p2/installer/InstallUpdateProductOperation.java index 7461f5bd2..202fe7462 100644 --- a/bundles/org.eclipse.equinox.p2.installer/src/org/eclipse/equinox/internal/p2/installer/InstallUpdateProductOperation.java +++ b/bundles/org.eclipse.equinox.p2.installer/src/org/eclipse/equinox/internal/p2/installer/InstallUpdateProductOperation.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2007, 2008 IBM Corporation and others. + * Copyright (c) 2007, 2010 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -11,9 +11,6 @@ *******************************************************************************/ package org.eclipse.equinox.internal.p2.installer; -import org.eclipse.equinox.p2.metadata.Version; -import org.eclipse.equinox.p2.metadata.VersionRange; - import java.net.URI; import java.util.*; import org.eclipse.core.runtime.*; @@ -22,11 +19,11 @@ import org.eclipse.equinox.internal.provisional.p2.director.IDirector; import org.eclipse.equinox.internal.provisional.p2.director.ProfileChangeRequest; import org.eclipse.equinox.internal.provisional.p2.installer.IInstallOperation; import org.eclipse.equinox.internal.provisional.p2.installer.InstallDescription; +import org.eclipse.equinox.p2.core.IProvisioningAgent; import org.eclipse.equinox.p2.core.ProvisionException; import org.eclipse.equinox.p2.engine.IProfile; import org.eclipse.equinox.p2.engine.IProfileRegistry; -import org.eclipse.equinox.p2.metadata.IInstallableUnit; -import org.eclipse.equinox.p2.metadata.IVersionedId; +import org.eclipse.equinox.p2.metadata.*; import org.eclipse.equinox.p2.metadata.query.InstallableUnitQuery; import org.eclipse.equinox.p2.query.IQuery; import org.eclipse.equinox.p2.query.IQueryResult; @@ -34,8 +31,6 @@ import org.eclipse.equinox.p2.repository.artifact.IArtifactRepositoryManager; import org.eclipse.equinox.p2.repository.metadata.IMetadataRepositoryManager; import org.eclipse.osgi.service.environment.EnvironmentInfo; import org.eclipse.osgi.util.NLS; -import org.osgi.framework.BundleContext; -import org.osgi.framework.ServiceReference; /** * This operation performs installation or update of an Eclipse-based product. @@ -43,7 +38,7 @@ import org.osgi.framework.ServiceReference; public class InstallUpdateProductOperation implements IInstallOperation { private IArtifactRepositoryManager artifactRepoMan; - private BundleContext bundleContext; + private IProvisioningAgent agent; private IDirector director; private final InstallDescription installDescription; private boolean isInstall = true; @@ -51,10 +46,8 @@ public class InstallUpdateProductOperation implements IInstallOperation { private IProfileRegistry profileRegistry; private IStatus result; - private ArrayList<ServiceReference> serviceReferences = new ArrayList<ServiceReference>(); - - public InstallUpdateProductOperation(BundleContext context, InstallDescription description) { - this.bundleContext = context; + public InstallUpdateProductOperation(IProvisioningAgent agent, InstallDescription description) { + this.agent = agent; this.installDescription = description; } @@ -194,13 +187,9 @@ public class InstallUpdateProductOperation implements IInstallOperation { } private Object getService(String name) throws CoreException { - ServiceReference ref = bundleContext.getServiceReference(name); - if (ref == null) - throw fail(Messages.Op_NoService + name); - Object service = bundleContext.getService(ref); + Object service = agent.getService(name); if (service == null) throw fail(Messages.Op_NoServiceImpl + name); - serviceReferences.add(ref); return service; } @@ -236,14 +225,11 @@ public class InstallUpdateProductOperation implements IInstallOperation { } private void postInstall() { - for (ServiceReference sr : serviceReferences) - bundleContext.ungetService(sr); - serviceReferences.clear(); + //nothing to do } private void preInstall() throws CoreException { //obtain required services - serviceReferences.clear(); director = (IDirector) getService(IDirector.SERVICE_NAME); metadataRepoMan = (IMetadataRepositoryManager) getService(IMetadataRepositoryManager.SERVICE_NAME); artifactRepoMan = (IArtifactRepositoryManager) getService(IArtifactRepositoryManager.SERVICE_NAME); |