Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorThomas Hallgren2010-02-05 17:07:01 -0500
committerThomas Hallgren2010-02-05 17:07:01 -0500
commit9faaed06625f31f3e4f26f65c3cffe4e947604fd (patch)
tree162a1267d4429ff85e188de84970455c138abfa6 /bundles/org.eclipse.equinox.p2.console
parente640f35a91169ce4ad67d674ba7b150b42450478 (diff)
downloadrt.equinox.p2-9faaed06625f31f3e4f26f65c3cffe4e947604fd.tar.gz
rt.equinox.p2-9faaed06625f31f3e4f26f65c3cffe4e947604fd.tar.xz
rt.equinox.p2-9faaed06625f31f3e4f26f65c3cffe4e947604fd.zip
299987 : Removal of p2 services in favor of always using an agent.
Diffstat (limited to 'bundles/org.eclipse.equinox.p2.console')
-rw-r--r--bundles/org.eclipse.equinox.p2.console/src/org/eclipse/equinox/internal/p2/console/Activator.java16
-rw-r--r--bundles/org.eclipse.equinox.p2.console/src/org/eclipse/equinox/internal/p2/console/ProvCommandProvider.java57
-rw-r--r--bundles/org.eclipse.equinox.p2.console/src/org/eclipse/equinox/internal/p2/console/ProvisioningHelper.java91
3 files changed, 84 insertions, 80 deletions
diff --git a/bundles/org.eclipse.equinox.p2.console/src/org/eclipse/equinox/internal/p2/console/Activator.java b/bundles/org.eclipse.equinox.p2.console/src/org/eclipse/equinox/internal/p2/console/Activator.java
index 42a465ee1..10304f9de 100644
--- a/bundles/org.eclipse.equinox.p2.console/src/org/eclipse/equinox/internal/p2/console/Activator.java
+++ b/bundles/org.eclipse.equinox.p2.console/src/org/eclipse/equinox/internal/p2/console/Activator.java
@@ -11,7 +11,7 @@
*******************************************************************************/
package org.eclipse.equinox.internal.p2.console;
-import org.eclipse.equinox.p2.engine.IProfileRegistry;
+import org.eclipse.equinox.p2.core.IProvisioningAgent;
import org.osgi.framework.*;
import org.osgi.util.tracker.ServiceTracker;
import org.osgi.util.tracker.ServiceTrackerCustomizer;
@@ -22,7 +22,7 @@ public class Activator implements BundleActivator, ServiceTrackerCustomizer {
private static final String PROVIDER_NAME = "org.eclipse.osgi.framework.console.CommandProvider"; //$NON-NLS-1$
private static BundleContext context;
- private ServiceTracker profileTracker;
+ private ServiceTracker agentTracker;
private ProvCommandProvider provider;
private ServiceRegistration providerRegistration = null;
@@ -44,13 +44,13 @@ public class Activator implements BundleActivator, ServiceTrackerCustomizer {
}
if (registerCommands) {
- profileTracker = new ServiceTracker(context, IProfileRegistry.SERVICE_NAME, this);
- profileTracker.open();
+ agentTracker = new ServiceTracker(context, IProvisioningAgent.SERVICE_NAME, this);
+ agentTracker.open();
}
}
public void stop(BundleContext ctxt) throws Exception {
- profileTracker.close();
+ agentTracker.close();
if (providerRegistration != null)
providerRegistration.unregister();
providerRegistration = null;
@@ -59,10 +59,10 @@ public class Activator implements BundleActivator, ServiceTrackerCustomizer {
public Object addingService(ServiceReference reference) {
BundleContext ctxt = Activator.getContext();
- IProfileRegistry registry = (IProfileRegistry) ctxt.getService(reference);
- provider = new ProvCommandProvider(ctxt.getProperty("eclipse.p2.profile"), registry); //$NON-NLS-1$
+ IProvisioningAgent agent = (IProvisioningAgent) ctxt.getService(reference);
+ provider = new ProvCommandProvider(ctxt.getProperty("eclipse.p2.profile"), agent); //$NON-NLS-1$
providerRegistration = ctxt.registerService(PROVIDER_NAME, provider, null);
- return registry;
+ return agent;
}
public void modifiedService(ServiceReference reference, Object service) {
diff --git a/bundles/org.eclipse.equinox.p2.console/src/org/eclipse/equinox/internal/p2/console/ProvCommandProvider.java b/bundles/org.eclipse.equinox.p2.console/src/org/eclipse/equinox/internal/p2/console/ProvCommandProvider.java
index 172731948..d9e59d664 100644
--- a/bundles/org.eclipse.equinox.p2.console/src/org/eclipse/equinox/internal/p2/console/ProvCommandProvider.java
+++ b/bundles/org.eclipse.equinox.p2.console/src/org/eclipse/equinox/internal/p2/console/ProvCommandProvider.java
@@ -17,7 +17,7 @@ import java.net.URISyntaxException;
import java.util.*;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.NullProgressMonitor;
-import org.eclipse.equinox.internal.p2.core.helpers.ServiceHelper;
+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;
@@ -39,9 +39,12 @@ public class ProvCommandProvider implements CommandProvider {
private static final String WILDCARD_ANY = "*"; //$NON-NLS-1$
public static final String NEW_LINE = System.getProperty("line.separator", "\n"); //$NON-NLS-1$ //$NON-NLS-2$
+ private final IProvisioningAgent agent;
+
// private Profile profile;
- public ProvCommandProvider(String profileId, IProfileRegistry registry) {
+ public ProvCommandProvider(String profileId, IProvisioningAgent agent) {
+ this.agent = agent;
// look up the profile we are currently running and use it as the
// default.
// TODO define a way to spec the default profile to manage
@@ -69,10 +72,10 @@ public class ProvCommandProvider implements CommandProvider {
if (repoURI == null)
return;
// add metadata repo
- if (ProvisioningHelper.addMetadataRepository(repoURI) == null) {
+ if (ProvisioningHelper.addMetadataRepository(agent, repoURI) == null) {
interpreter.println("Unable to add metadata repository: " + repoURI);
} else // add artifact repo at same URL
- if (ProvisioningHelper.addArtifactRepository(repoURI) == null) {
+ if (ProvisioningHelper.addArtifactRepository(agent, repoURI) == null) {
interpreter.println("Unable to add artifact repository: " + repoURI);
}
}
@@ -86,8 +89,8 @@ public class ProvCommandProvider implements CommandProvider {
URI repoURI = toURI(interpreter, urlString);
if (repoURI == null)
return;
- ProvisioningHelper.removeMetadataRepository(repoURI);
- ProvisioningHelper.removeArtifactRepository(repoURI);
+ ProvisioningHelper.removeMetadataRepository(agent, repoURI);
+ ProvisioningHelper.removeArtifactRepository(agent, repoURI);
}
/**
@@ -102,7 +105,7 @@ public class ProvCommandProvider implements CommandProvider {
URI repoURI = toURI(interpreter, urlString);
if (repoURI == null)
return;
- if (ProvisioningHelper.addMetadataRepository(repoURI) == null)
+ if (ProvisioningHelper.addMetadataRepository(agent, repoURI) == null)
interpreter.println("Unable to add repository: " + repoURI);
}
@@ -115,7 +118,7 @@ public class ProvCommandProvider implements CommandProvider {
URI repoURI = toURI(interpreter, urlString);
if (repoURI == null)
return;
- ProvisioningHelper.removeMetadataRepository(repoURI);
+ ProvisioningHelper.removeMetadataRepository(agent, repoURI);
}
public void _provaddartifactrepo(CommandInterpreter interpreter) {
@@ -127,7 +130,7 @@ public class ProvCommandProvider implements CommandProvider {
URI repoURI = toURI(interpreter, urlString);
if (repoURI == null)
return;
- if (ProvisioningHelper.addArtifactRepository(repoURI) == null)
+ if (ProvisioningHelper.addArtifactRepository(agent, repoURI) == null)
interpreter.println("Unable to add repository " + repoURI);
}
@@ -140,7 +143,7 @@ public class ProvCommandProvider implements CommandProvider {
URI repoURI = toURI(interpreter, urlString);
if (repoURI == null)
return;
- ProvisioningHelper.removeArtifactRepository(repoURI);
+ ProvisioningHelper.removeArtifactRepository(agent, repoURI);
}
/**
@@ -158,7 +161,7 @@ public class ProvCommandProvider implements CommandProvider {
}
IStatus s = null;
try {
- s = ProvisioningHelper.install(iu, version, ProvisioningHelper.getProfile(profileId), new NullProgressMonitor());
+ s = ProvisioningHelper.install(agent, iu, version, ProvisioningHelper.getProfile(agent, profileId), new NullProgressMonitor());
} catch (ProvisionException e) {
interpreter.println("Installation failed with ProvisionException for " + iu + " " + version);
interpreter.printStackTrace(e);
@@ -190,7 +193,7 @@ public class ProvCommandProvider implements CommandProvider {
props.put(IProfile.PROP_ENVIRONMENTS, environments);
try {
- ProvisioningHelper.addProfile(profileId, props);
+ ProvisioningHelper.addProfile(agent, profileId, props);
} catch (ProvisionException e) {
interpreter.println("Add profile failed. " + e.getMessage());
interpreter.printStackTrace(e);
@@ -206,7 +209,7 @@ public class ProvCommandProvider implements CommandProvider {
interpreter.println("profileid must be provided");
return;
}
- ProvisioningHelper.removeProfile(profileId);
+ ProvisioningHelper.removeProfile(agent, profileId);
}
/**
@@ -221,7 +224,7 @@ public class ProvCommandProvider implements CommandProvider {
URI repoURL = null;
if (urlString != null && !urlString.equals(WILDCARD_ANY))
repoURL = toURI(interpreter, urlString);
- IInstallableUnit[] units = sort(ProvisioningHelper.getInstallableUnits(repoURL, new InstallableUnitQuery(id, new VersionRange(version)), null));
+ IInstallableUnit[] units = sort(ProvisioningHelper.getInstallableUnits(agent, repoURL, new InstallableUnitQuery(id, new VersionRange(version)), null));
for (int i = 0; i < units.length; i++)
println(interpreter, units[i]);
}
@@ -237,7 +240,7 @@ public class ProvCommandProvider implements CommandProvider {
String id = processArgument(interpreter.nextArgument());
String version = processArgument(interpreter.nextArgument());
if (urlString == null) {
- URI[] repositories = ProvisioningHelper.getMetadataRepositories();
+ URI[] repositories = ProvisioningHelper.getMetadataRepositories(agent);
if (repositories != null)
for (int i = 0; i < repositories.length; i++)
interpreter.println(repositories[i]);
@@ -246,7 +249,7 @@ public class ProvCommandProvider implements CommandProvider {
URI repoLocation = toURI(interpreter, urlString);
if (repoLocation == null)
return;
- IInstallableUnit[] units = sort(ProvisioningHelper.getInstallableUnits(repoLocation, new InstallableUnitQuery(id, new VersionRange(version)), null));
+ IInstallableUnit[] units = sort(ProvisioningHelper.getInstallableUnits(agent, repoLocation, new InstallableUnitQuery(id, new VersionRange(version)), null));
for (int i = 0; i < units.length; i++)
println(interpreter, units[i]);
}
@@ -261,14 +264,14 @@ public class ProvCommandProvider implements CommandProvider {
String urlString = processArgument(interpreter.nextArgument());
IQueryable<IInstallableUnit> queryable = null;
if (urlString == null) {
- queryable = (IMetadataRepositoryManager) ServiceHelper.getService(Activator.getContext(), IMetadataRepositoryManager.SERVICE_NAME);
+ queryable = (IMetadataRepositoryManager) agent.getService(IMetadataRepositoryManager.SERVICE_NAME);
if (queryable == null)
return;
} else {
URI repoURL = toURI(interpreter, urlString);
if (repoURL == null)
return;
- queryable = ProvisioningHelper.getMetadataRepository(repoURL);
+ queryable = ProvisioningHelper.getMetadataRepository(agent, repoURL);
if (queryable == null)
return;
}
@@ -286,7 +289,7 @@ public class ProvCommandProvider implements CommandProvider {
public void _provlar(CommandInterpreter interpreter) {
String urlString = processArgument(interpreter.nextArgument());
if (urlString == null) {
- URI[] repositories = ProvisioningHelper.getArtifactRepositories();
+ URI[] repositories = ProvisioningHelper.getArtifactRepositories(agent);
if (repositories == null)
return;
for (int i = 0; i < repositories.length; i++)
@@ -296,7 +299,7 @@ public class ProvCommandProvider implements CommandProvider {
URI repoURL = toURI(interpreter, urlString);
if (repoURL == null)
return;
- IArtifactRepository repo = ProvisioningHelper.getArtifactRepository(repoURL);
+ IArtifactRepository repo = ProvisioningHelper.getArtifactRepository(agent, repoURL);
IQueryResult<IArtifactKey> keys = null;
try {
keys = (repo != null) ? repo.query(ArtifactKeyQuery.ALL_KEYS, null) : null;
@@ -353,7 +356,7 @@ public class ProvCommandProvider implements CommandProvider {
String id = processArgument(interpreter.nextArgument());
String range = processArgument(interpreter.nextArgument());
if (profileId == null) {
- IProfile[] profiles = ProvisioningHelper.getProfiles();
+ IProfile[] profiles = ProvisioningHelper.getProfiles(agent);
for (int i = 0; i < profiles.length; i++)
interpreter.println(profiles[i].getProfileId());
return;
@@ -362,7 +365,7 @@ public class ProvCommandProvider implements CommandProvider {
IProfile target = null;
if (profileId.equals("this")) //$NON-NLS-1$
profileId = IProfileRegistry.SELF;
- target = ProvisioningHelper.getProfile(profileId);
+ target = ProvisioningHelper.getProfile(agent, profileId);
if (target == null)
return;
@@ -383,7 +386,7 @@ public class ProvCommandProvider implements CommandProvider {
if (profileId == null || profileId.equals("this")) { //$NON-NLS-1$
profileId = IProfileRegistry.SELF;
}
- long[] profileTimestamps = ProvisioningHelper.getProfileTimestamps(profileId);
+ long[] profileTimestamps = ProvisioningHelper.getProfileTimestamps(agent, profileId);
// if no profile timestamps for given id, print that out and done
if (profileTimestamps == null || profileTimestamps.length == 0) {
interpreter.print("No timestamps found for profile ");
@@ -419,14 +422,14 @@ public class ProvCommandProvider implements CommandProvider {
if (profileId == null || profileId.equals("this"))
profileId = IProfileRegistry.SELF;
- IProfile profile = ProvisioningHelper.getProfile(profileId);
+ IProfile profile = ProvisioningHelper.getProfile(agent, profileId);
if (profile == null) {
interpreter.println("Profile " + profileId + " not found");
return;
}
IStatus s = null;
try {
- s = ProvisioningHelper.revertToPreviousState(profile, ts.longValue());
+ s = ProvisioningHelper.revertToPreviousState(agent, profile, ts.longValue());
} catch (ProvisionException e) {
interpreter.println("revert failed ");
interpreter.printStackTrace(e);
@@ -455,7 +458,7 @@ public class ProvCommandProvider implements CommandProvider {
if (profileId == null || profileId.equals("this")) {
profileId = IProfileRegistry.SELF;
}
- IProfile profile = ProvisioningHelper.getProfile(profileId);
+ IProfile profile = ProvisioningHelper.getProfile(agent, profileId);
if (profile == null) {
interpreter.println("Profile " + profileId + " not found");
return;
@@ -482,7 +485,7 @@ public class ProvCommandProvider implements CommandProvider {
}
IStatus s = null;
try {
- s = ProvisioningHelper.uninstall(iu, version, ProvisioningHelper.getProfile(profileId), new NullProgressMonitor());
+ s = ProvisioningHelper.uninstall(agent, iu, version, ProvisioningHelper.getProfile(agent, profileId), new NullProgressMonitor());
} catch (ProvisionException e) {
interpreter.println("Remove failed with ProvisionException for " + iu + " " + version);
interpreter.printStackTrace(e);
diff --git a/bundles/org.eclipse.equinox.p2.console/src/org/eclipse/equinox/internal/p2/console/ProvisioningHelper.java b/bundles/org.eclipse.equinox.p2.console/src/org/eclipse/equinox/internal/p2/console/ProvisioningHelper.java
index a6eac2fff..6552edcea 100644
--- a/bundles/org.eclipse.equinox.p2.console/src/org/eclipse/equinox/internal/p2/console/ProvisioningHelper.java
+++ b/bundles/org.eclipse.equinox.p2.console/src/org/eclipse/equinox/internal/p2/console/ProvisioningHelper.java
@@ -16,6 +16,7 @@ import java.util.Map;
import org.eclipse.core.runtime.*;
import org.eclipse.equinox.internal.p2.core.helpers.ServiceHelper;
import org.eclipse.equinox.internal.provisional.p2.director.*;
+import org.eclipse.equinox.p2.core.IProvisioningAgent;
import org.eclipse.equinox.p2.core.ProvisionException;
import org.eclipse.equinox.p2.engine.*;
import org.eclipse.equinox.p2.metadata.IInstallableUnit;
@@ -31,8 +32,8 @@ import org.eclipse.osgi.service.environment.EnvironmentInfo;
public class ProvisioningHelper {
- public static IMetadataRepository addMetadataRepository(URI location) {
- IMetadataRepositoryManager manager = (IMetadataRepositoryManager) ServiceHelper.getService(Activator.getContext(), IMetadataRepositoryManager.SERVICE_NAME);
+ public static IMetadataRepository addMetadataRepository(IProvisioningAgent agent, URI location) {
+ IMetadataRepositoryManager manager = (IMetadataRepositoryManager) agent.getService(IMetadataRepositoryManager.SERVICE_NAME);
if (manager == null)
throw new IllegalStateException("No metadata repository manager found");
try {
@@ -50,8 +51,8 @@ public class ProvisioningHelper {
}
}
- public static IMetadataRepository getMetadataRepository(URI location) {
- IMetadataRepositoryManager manager = (IMetadataRepositoryManager) ServiceHelper.getService(Activator.getContext(), IMetadataRepositoryManager.SERVICE_NAME);
+ public static IMetadataRepository getMetadataRepository(IProvisioningAgent agent, URI location) {
+ IMetadataRepositoryManager manager = (IMetadataRepositoryManager) agent.getService(IMetadataRepositoryManager.SERVICE_NAME);
if (manager == null)
throw new IllegalStateException("No metadata repository manager found");
try {
@@ -61,15 +62,15 @@ public class ProvisioningHelper {
}
}
- public static void removeMetadataRepository(URI location) {
- IMetadataRepositoryManager manager = (IMetadataRepositoryManager) ServiceHelper.getService(Activator.getContext(), IMetadataRepositoryManager.SERVICE_NAME);
+ public static void removeMetadataRepository(IProvisioningAgent agent, URI location) {
+ IMetadataRepositoryManager manager = (IMetadataRepositoryManager) agent.getService(IMetadataRepositoryManager.SERVICE_NAME);
if (manager == null)
throw new IllegalStateException("No metadata repository manager found");
manager.removeRepository(location);
}
- public static IArtifactRepository addArtifactRepository(URI location) {
- IArtifactRepositoryManager manager = (IArtifactRepositoryManager) ServiceHelper.getService(Activator.getContext(), IArtifactRepositoryManager.SERVICE_NAME);
+ public static IArtifactRepository addArtifactRepository(IProvisioningAgent agent, URI location) {
+ IArtifactRepositoryManager manager = (IArtifactRepositoryManager) agent.getService(IArtifactRepositoryManager.SERVICE_NAME);
if (manager == null)
// TODO log here
return null;
@@ -87,16 +88,16 @@ public class ProvisioningHelper {
}
}
- public static void removeArtifactRepository(URI location) {
- IArtifactRepositoryManager manager = (IArtifactRepositoryManager) ServiceHelper.getService(Activator.getContext(), IArtifactRepositoryManager.SERVICE_NAME);
+ public static void removeArtifactRepository(IProvisioningAgent agent, URI location) {
+ IArtifactRepositoryManager manager = (IArtifactRepositoryManager) agent.getService(IArtifactRepositoryManager.SERVICE_NAME);
if (manager == null)
// TODO log here
return;
manager.removeRepository(location);
}
- public static IProfile addProfile(String profileId, Map<String, String> properties) throws ProvisionException {
- IProfileRegistry profileRegistry = (IProfileRegistry) ServiceHelper.getService(Activator.getContext(), IProfileRegistry.SERVICE_NAME);
+ public static IProfile addProfile(IProvisioningAgent agent, String profileId, Map<String, String> properties) throws ProvisionException {
+ IProfileRegistry profileRegistry = (IProfileRegistry) agent.getService(IProfileRegistry.SERVICE_NAME);
if (profileRegistry == null)
return null;
IProfile profile = profileRegistry.getProfile(profileId);
@@ -115,22 +116,22 @@ public class ProvisioningHelper {
return profileRegistry.addProfile(profileId, profileProperties);
}
- public static void removeProfile(String profileId) {
- IProfileRegistry profileRegistry = (IProfileRegistry) ServiceHelper.getService(Activator.getContext(), IProfileRegistry.SERVICE_NAME);
+ public static void removeProfile(IProvisioningAgent agent, String profileId) {
+ IProfileRegistry profileRegistry = (IProfileRegistry) agent.getService(IProfileRegistry.SERVICE_NAME);
if (profileRegistry == null)
return;
profileRegistry.removeProfile(profileId);
}
- public static IProfile[] getProfiles() {
- IProfileRegistry profileRegistry = (IProfileRegistry) ServiceHelper.getService(Activator.getContext(), IProfileRegistry.SERVICE_NAME);
+ public static IProfile[] getProfiles(IProvisioningAgent agent) {
+ IProfileRegistry profileRegistry = (IProfileRegistry) agent.getService(IProfileRegistry.SERVICE_NAME);
if (profileRegistry == null)
return new IProfile[0];
return profileRegistry.getProfiles();
}
- public static IProfile getProfile(String id) {
- IProfileRegistry profileRegistry = (IProfileRegistry) ServiceHelper.getService(Activator.getContext(), IProfileRegistry.SERVICE_NAME);
+ public static IProfile getProfile(IProvisioningAgent agent, String id) {
+ IProfileRegistry profileRegistry = (IProfileRegistry) agent.getService(IProfileRegistry.SERVICE_NAME);
if (profileRegistry == null)
return null;
return profileRegistry.getProfile(id);
@@ -146,20 +147,20 @@ public class ProvisioningHelper {
* @param monitor A progress monitor, or <code>null</code>
* @return The IUs that match the query
*/
- public static IQueryResult<IInstallableUnit> getInstallableUnits(URI location, IQuery<IInstallableUnit> query, IProgressMonitor monitor) {
+ public static IQueryResult<IInstallableUnit> getInstallableUnits(IProvisioningAgent agent, URI location, IQuery<IInstallableUnit> query, IProgressMonitor monitor) {
IQueryable<IInstallableUnit> queryable = null;
if (location == null) {
- queryable = (IMetadataRepositoryManager) ServiceHelper.getService(Activator.getContext(), IMetadataRepositoryManager.SERVICE_NAME);
+ queryable = (IMetadataRepositoryManager) agent.getService(IMetadataRepositoryManager.SERVICE_NAME);
} else {
- queryable = getMetadataRepository(location);
+ queryable = getMetadataRepository(agent, location);
}
if (queryable != null)
return queryable.query(query, monitor);
return Collector.emptyCollector();
}
- public static URI[] getMetadataRepositories() {
- IMetadataRepositoryManager manager = (IMetadataRepositoryManager) ServiceHelper.getService(Activator.getContext(), IMetadataRepositoryManager.SERVICE_NAME);
+ public static URI[] getMetadataRepositories(IProvisioningAgent agent) {
+ IMetadataRepositoryManager manager = (IMetadataRepositoryManager) agent.getService(IMetadataRepositoryManager.SERVICE_NAME);
if (manager == null)
// TODO log here
return null;
@@ -172,15 +173,15 @@ public class ProvisioningHelper {
/**
* Install the described IU
*/
- public static IStatus install(String unitId, String version, IProfile profile, IProgressMonitor progress) throws ProvisionException {
+ public static IStatus install(IProvisioningAgent agent, String unitId, String version, IProfile profile, IProgressMonitor progress) throws ProvisionException {
if (profile == null)
return null;
- IQueryResult<IInstallableUnit> units = getInstallableUnits((URI) null, new InstallableUnitQuery(unitId, Version.create(version)), progress);
+ IQueryResult<IInstallableUnit> units = getInstallableUnits(agent, (URI) null, new InstallableUnitQuery(unitId, Version.create(version)), progress);
if (units.isEmpty()) {
StringBuffer error = new StringBuffer();
error.append("Installable unit not found: " + unitId + ' ' + version + '\n');
error.append("Repositories searched:\n");
- URI[] repos = getMetadataRepositories();
+ URI[] repos = getMetadataRepositories(agent);
if (repos != null) {
for (int i = 0; i < repos.length; i++)
error.append(repos[i] + "\n");
@@ -188,11 +189,11 @@ public class ProvisioningHelper {
throw new ProvisionException(error.toString());
}
- IPlanner planner = (IPlanner) ServiceHelper.getService(Activator.getContext(), IPlanner.SERVICE_NAME);
+ IPlanner planner = (IPlanner) agent.getService(IPlanner.SERVICE_NAME);
if (planner == null)
throw new ProvisionException("No planner service found.");
- IEngine engine = (IEngine) ServiceHelper.getService(Activator.getContext(), IEngine.SERVICE_NAME);
+ IEngine engine = (IEngine) agent.getService(IEngine.SERVICE_NAME);
if (engine == null)
throw new ProvisionException("No director service found.");
ProvisioningContext context = new ProvisioningContext();
@@ -202,8 +203,8 @@ public class ProvisioningHelper {
return PlanExecutionHelper.executePlan(result, engine, context, progress);
}
- public static URI[] getArtifactRepositories() {
- IArtifactRepositoryManager manager = (IArtifactRepositoryManager) ServiceHelper.getService(Activator.getContext(), IArtifactRepositoryManager.SERVICE_NAME);
+ public static URI[] getArtifactRepositories(IProvisioningAgent agent) {
+ IArtifactRepositoryManager manager = (IArtifactRepositoryManager) agent.getService(IArtifactRepositoryManager.SERVICE_NAME);
if (manager == null)
// TODO log here
return null;
@@ -213,8 +214,8 @@ public class ProvisioningHelper {
return null;
}
- public static IArtifactRepository getArtifactRepository(URI repoURL) {
- IArtifactRepositoryManager manager = (IArtifactRepositoryManager) ServiceHelper.getService(Activator.getContext(), IArtifactRepositoryManager.SERVICE_NAME);
+ public static IArtifactRepository getArtifactRepository(IProvisioningAgent agent, URI repoURL) {
+ IArtifactRepositoryManager manager = (IArtifactRepositoryManager) agent.getService(IArtifactRepositoryManager.SERVICE_NAME);
try {
if (manager != null)
return manager.loadRepository(repoURL, null);
@@ -224,29 +225,29 @@ public class ProvisioningHelper {
return null;
}
- public static long[] getProfileTimestamps(String profileId) {
+ public static long[] getProfileTimestamps(IProvisioningAgent agent, String profileId) {
if (profileId == null) {
profileId = IProfileRegistry.SELF;
}
- IProfileRegistry profileRegistry = (IProfileRegistry) ServiceHelper.getService(Activator.getContext(), IProfileRegistry.SERVICE_NAME);
+ IProfileRegistry profileRegistry = (IProfileRegistry) agent.getService(IProfileRegistry.SERVICE_NAME);
if (profileRegistry == null)
return null;
return profileRegistry.listProfileTimestamps(profileId);
}
- public static IStatus revertToPreviousState(IProfile profile, long revertToPreviousState) throws ProvisionException {
- IEngine engine = (IEngine) ServiceHelper.getService(Activator.getContext(), IEngine.SERVICE_NAME);
+ public static IStatus revertToPreviousState(IProvisioningAgent agent, IProfile profile, long revertToPreviousState) throws ProvisionException {
+ IEngine engine = (IEngine) agent.getService(IEngine.SERVICE_NAME);
if (engine == null)
throw new ProvisionException("No p2 engine found.");
- IPlanner planner = (IPlanner) ServiceHelper.getService(Activator.getContext(), IPlanner.SERVICE_NAME);
+ IPlanner planner = (IPlanner) agent.getService(IPlanner.SERVICE_NAME);
if (planner == null)
throw new ProvisionException("No planner found.");
- IProfileRegistry profileRegistry = (IProfileRegistry) ServiceHelper.getService(Activator.getContext(), IProfileRegistry.SERVICE_NAME);
+ IProfileRegistry profileRegistry = (IProfileRegistry) agent.getService(IProfileRegistry.SERVICE_NAME);
if (profileRegistry == null)
throw new ProvisionException("profile registry cannot be null");
// If given profile is null, then get/use the self profile
if (profile == null) {
- profile = getProfile(IProfileRegistry.SELF);
+ profile = getProfile(agent, IProfileRegistry.SELF);
}
IProfile targetProfile = null;
if (revertToPreviousState == 0) {
@@ -260,8 +261,8 @@ public class ProvisioningHelper {
}
if (targetProfile == null)
throw new ProvisionException("target profile with timestamp=" + revertToPreviousState + " not found");
- URI[] artifactRepos = getArtifactRepositories();
- URI[] metadataRepos = getMetadataRepositories();
+ URI[] artifactRepos = getArtifactRepositories(agent);
+ URI[] metadataRepos = getMetadataRepositories(agent);
IProvisioningPlan plan = planner.getDiffPlan(profile, targetProfile, new NullProgressMonitor());
ProvisioningContext context = new ProvisioningContext(metadataRepos);
context.setArtifactRepositories(artifactRepos);
@@ -271,7 +272,7 @@ public class ProvisioningHelper {
/**
* Install the described IU
*/
- public static IStatus uninstall(String unitId, String version, IProfile profile, IProgressMonitor progress) throws ProvisionException {
+ public static IStatus uninstall(IProvisioningAgent agent, String unitId, String version, IProfile profile, IProgressMonitor progress) throws ProvisionException {
if (profile == null)
return null;
IQueryResult<IInstallableUnit> units = profile.query(new InstallableUnitQuery(unitId, Version.create(version)), progress);
@@ -279,7 +280,7 @@ public class ProvisioningHelper {
StringBuffer error = new StringBuffer();
error.append("Installable unit not found: " + unitId + ' ' + version + '\n');
error.append("Repositories searched:\n");
- URI[] repos = getMetadataRepositories();
+ URI[] repos = getMetadataRepositories(agent);
if (repos != null) {
for (int i = 0; i < repos.length; i++)
error.append(repos[i] + "\n"); //$NON-NLS-1$
@@ -287,11 +288,11 @@ public class ProvisioningHelper {
throw new ProvisionException(error.toString());
}
- IPlanner planner = (IPlanner) ServiceHelper.getService(Activator.getContext(), IPlanner.SERVICE_NAME);
+ IPlanner planner = (IPlanner) agent.getService(IPlanner.SERVICE_NAME);
if (planner == null)
throw new ProvisionException("No planner service found.");
- IEngine engine = (IEngine) ServiceHelper.getService(Activator.getContext(), IEngine.SERVICE_NAME);
+ IEngine engine = (IEngine) agent.getService(IEngine.SERVICE_NAME);
if (engine == null)
throw new ProvisionException("No engine service found.");
ProvisioningContext context = new ProvisioningContext();

Back to the top