Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPascal Rapicault2009-12-10 15:15:54 +0000
committerPascal Rapicault2009-12-10 15:15:54 +0000
commitc5a9c86654bfc50f0f838944a67f636732abc21f (patch)
treed24aafc040f8fcfaa43ec49af09cbfbf4a1ec1f2
parent2ba559a712c9dedb7ab901b8d2d09582e9ac9038 (diff)
downloadrt.equinox.p2-c5a9c86654bfc50f0f838944a67f636732abc21f.tar.gz
rt.equinox.p2-c5a9c86654bfc50f0f838944a67f636732abc21f.tar.xz
rt.equinox.p2-c5a9c86654bfc50f0f838944a67f636732abc21f.zip
Use ProvisioningAgent instead of acquiring services
-rw-r--r--bundles/org.eclipse.equinox.p2.directorywatcher/META-INF/MANIFEST.MF1
-rw-r--r--bundles/org.eclipse.equinox.p2.directorywatcher/src/org/eclipse/equinox/internal/provisional/p2/directorywatcher/Activator.java5
-rw-r--r--bundles/org.eclipse.equinox.p2.reconciler.dropins/META-INF/MANIFEST.MF1
-rw-r--r--bundles/org.eclipse.equinox.p2.reconciler.dropins/src/org/eclipse/equinox/internal/p2/reconciler/dropins/Activator.java19
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/full/End2EndTest.java32
5 files changed, 30 insertions, 28 deletions
diff --git a/bundles/org.eclipse.equinox.p2.directorywatcher/META-INF/MANIFEST.MF b/bundles/org.eclipse.equinox.p2.directorywatcher/META-INF/MANIFEST.MF
index e18978311..caa1ac7be 100644
--- a/bundles/org.eclipse.equinox.p2.directorywatcher/META-INF/MANIFEST.MF
+++ b/bundles/org.eclipse.equinox.p2.directorywatcher/META-INF/MANIFEST.MF
@@ -12,6 +12,7 @@ Import-Package: org.eclipse.equinox.internal.p2.artifact.repository.simple,
org.eclipse.equinox.internal.provisional.p2.metadata,
org.eclipse.equinox.internal.provisional.p2.metadata.query,
org.eclipse.equinox.internal.provisional.spi.p2.artifact.repository,
+ org.eclipse.equinox.p2.core,
org.eclipse.equinox.p2.metadata,
org.eclipse.equinox.p2.metadata.query,
org.eclipse.equinox.p2.publisher,
diff --git a/bundles/org.eclipse.equinox.p2.directorywatcher/src/org/eclipse/equinox/internal/provisional/p2/directorywatcher/Activator.java b/bundles/org.eclipse.equinox.p2.directorywatcher/src/org/eclipse/equinox/internal/provisional/p2/directorywatcher/Activator.java
index 613918c42..05cd04b94 100644
--- a/bundles/org.eclipse.equinox.p2.directorywatcher/src/org/eclipse/equinox/internal/provisional/p2/directorywatcher/Activator.java
+++ b/bundles/org.eclipse.equinox.p2.directorywatcher/src/org/eclipse/equinox/internal/provisional/p2/directorywatcher/Activator.java
@@ -14,6 +14,7 @@ package org.eclipse.equinox.internal.provisional.p2.directorywatcher;
import java.io.File;
import java.net.URI;
import org.eclipse.equinox.internal.p2.core.helpers.ServiceHelper;
+import org.eclipse.equinox.p2.core.IProvisioningAgent;
import org.eclipse.equinox.p2.repository.artifact.IArtifactRepositoryManager;
import org.eclipse.equinox.p2.repository.metadata.IMetadataRepositoryManager;
import org.osgi.framework.*;
@@ -40,11 +41,11 @@ public class Activator implements BundleActivator {
}
public static IArtifactRepositoryManager getArtifactRepositoryManager() {
- return (IArtifactRepositoryManager) ServiceHelper.getService(context, IArtifactRepositoryManager.SERVICE_NAME);
+ return (IArtifactRepositoryManager) ((IProvisioningAgent) ServiceHelper.getService(context, IProvisioningAgent.SERVICE_NAME)).getService(IArtifactRepositoryManager.SERVICE_NAME);
}
public static IMetadataRepositoryManager getMetadataRepositoryManager() {
- return (IMetadataRepositoryManager) ServiceHelper.getService(context, IMetadataRepositoryManager.SERVICE_NAME);
+ return (IMetadataRepositoryManager) ((IProvisioningAgent) ServiceHelper.getService(context, IProvisioningAgent.SERVICE_NAME)).getService(IMetadataRepositoryManager.SERVICE_NAME);
}
public static URI getDefaultRepositoryLocation(Object object, String repositoryName) {
diff --git a/bundles/org.eclipse.equinox.p2.reconciler.dropins/META-INF/MANIFEST.MF b/bundles/org.eclipse.equinox.p2.reconciler.dropins/META-INF/MANIFEST.MF
index e1ccbb297..b340267aa 100644
--- a/bundles/org.eclipse.equinox.p2.reconciler.dropins/META-INF/MANIFEST.MF
+++ b/bundles/org.eclipse.equinox.p2.reconciler.dropins/META-INF/MANIFEST.MF
@@ -20,6 +20,7 @@ Import-Package: org.eclipse.equinox.app;version="1.0.0",
org.eclipse.equinox.internal.provisional.p2.directorywatcher,
org.eclipse.equinox.internal.provisional.p2.metadata,
org.eclipse.equinox.internal.provisional.p2.metadata.query,
+ org.eclipse.equinox.p2.core,
org.eclipse.equinox.p2.engine,
org.eclipse.equinox.p2.engine.query,
org.eclipse.equinox.p2.metadata,
diff --git a/bundles/org.eclipse.equinox.p2.reconciler.dropins/src/org/eclipse/equinox/internal/p2/reconciler/dropins/Activator.java b/bundles/org.eclipse.equinox.p2.reconciler.dropins/src/org/eclipse/equinox/internal/p2/reconciler/dropins/Activator.java
index 5b9f3fee1..38640166b 100644
--- a/bundles/org.eclipse.equinox.p2.reconciler.dropins/src/org/eclipse/equinox/internal/p2/reconciler/dropins/Activator.java
+++ b/bundles/org.eclipse.equinox.p2.reconciler.dropins/src/org/eclipse/equinox/internal/p2/reconciler/dropins/Activator.java
@@ -22,6 +22,7 @@ import org.eclipse.equinox.internal.p2.update.Configuration;
import org.eclipse.equinox.internal.p2.update.PathUtil;
import org.eclipse.equinox.internal.provisional.p2.core.ProvisionException;
import org.eclipse.equinox.internal.provisional.p2.directorywatcher.DirectoryWatcher;
+import org.eclipse.equinox.p2.core.IProvisioningAgent;
import org.eclipse.equinox.p2.engine.IProfile;
import org.eclipse.equinox.p2.engine.IProfileRegistry;
import org.eclipse.equinox.p2.repository.IRepository;
@@ -64,10 +65,8 @@ public class Activator implements BundleActivator {
* @throws ProvisionException
*/
public static IMetadataRepository createExtensionLocationMetadataRepository(URI location, String name, Map properties) throws ProvisionException {
- BundleContext context = getContext();
- IMetadataRepositoryManager manager = (IMetadataRepositoryManager) ServiceHelper.getService(context, IMetadataRepositoryManager.SERVICE_NAME);
- if (manager == null)
- throw new IllegalStateException("MetadataRepositoryManager not registered."); //$NON-NLS-1$
+ IProvisioningAgent agent = (IProvisioningAgent) ServiceHelper.getService(getContext(), IProvisioningAgent.SERVICE_NAME);
+ IMetadataRepositoryManager manager = (IMetadataRepositoryManager) agent.getService(IMetadataRepositoryManager.SERVICE_NAME);
ExtensionLocationMetadataRepositoryFactory factory = new ExtensionLocationMetadataRepositoryFactory();
IMetadataRepository repository = factory.create(location, name, ExtensionLocationMetadataRepository.TYPE, properties);
//we need to add the concrete repository to the repository manager, or its properties will not be correct
@@ -83,8 +82,8 @@ public class Activator implements BundleActivator {
* @throws ProvisionException
*/
public static IMetadataRepository loadMetadataRepository(URI location, IProgressMonitor monitor) throws ProvisionException {
- BundleContext context = getContext();
- IMetadataRepositoryManager manager = (IMetadataRepositoryManager) ServiceHelper.getService(context, IMetadataRepositoryManager.SERVICE_NAME);
+ IProvisioningAgent agent = (IProvisioningAgent) ServiceHelper.getService(getContext(), IProvisioningAgent.SERVICE_NAME);
+ IMetadataRepositoryManager manager = (IMetadataRepositoryManager) agent.getService(IMetadataRepositoryManager.SERVICE_NAME);
if (manager == null)
throw new IllegalStateException("MetadataRepositoryManager not registered."); //$NON-NLS-1$
IMetadataRepository repository = manager.loadRepository(location, monitor);
@@ -102,8 +101,8 @@ public class Activator implements BundleActivator {
* @throws ProvisionException
*/
public static IArtifactRepository createExtensionLocationArtifactRepository(URI location, String name, Map properties) throws ProvisionException {
- BundleContext context = getContext();
- IArtifactRepositoryManager manager = (IArtifactRepositoryManager) ServiceHelper.getService(context, IArtifactRepositoryManager.SERVICE_NAME);
+ IProvisioningAgent agent = (IProvisioningAgent) ServiceHelper.getService(getContext(), IProvisioningAgent.SERVICE_NAME);
+ IArtifactRepositoryManager manager = (IArtifactRepositoryManager) agent.getService(IArtifactRepositoryManager.SERVICE_NAME);
if (manager == null)
throw new IllegalStateException("ArtifactRepositoryManager not registered."); //$NON-NLS-1$
ExtensionLocationArtifactRepositoryFactory factory = new ExtensionLocationArtifactRepositoryFactory();
@@ -121,8 +120,8 @@ public class Activator implements BundleActivator {
* @throws ProvisionException
*/
public static IArtifactRepository loadArtifactRepository(URI location, IProgressMonitor monitor) throws ProvisionException {
- BundleContext context = getContext();
- IArtifactRepositoryManager manager = (IArtifactRepositoryManager) ServiceHelper.getService(context, IArtifactRepositoryManager.SERVICE_NAME);
+ IProvisioningAgent agent = (IProvisioningAgent) ServiceHelper.getService(getContext(), IProvisioningAgent.SERVICE_NAME);
+ IArtifactRepositoryManager manager = (IArtifactRepositoryManager) agent.getService(IArtifactRepositoryManager.SERVICE_NAME);
if (manager == null)
throw new IllegalStateException("ArtifactRepositoryManager not registered."); //$NON-NLS-1$
IArtifactRepository repository = manager.loadRepository(location, monitor);
diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/full/End2EndTest.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/full/End2EndTest.java
index da4a35b8e..82c183e9d 100644
--- a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/full/End2EndTest.java
+++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/full/End2EndTest.java
@@ -26,6 +26,8 @@ import org.eclipse.equinox.internal.provisional.p2.metadata.Version;
import org.eclipse.equinox.internal.provisional.p2.metadata.MetadataFactory.InstallableUnitDescription;
import org.eclipse.equinox.internal.provisional.p2.metadata.query.Collector;
import org.eclipse.equinox.internal.provisional.p2.metadata.query.InstallableUnitQuery;
+import org.eclipse.equinox.p2.core.IProvisioningAgent;
+import org.eclipse.equinox.p2.core.IProvisioningAgentProvider;
import org.eclipse.equinox.p2.engine.*;
import org.eclipse.equinox.p2.metadata.IInstallableUnit;
import org.eclipse.equinox.p2.repository.artifact.IArtifactRepositoryManager;
@@ -48,25 +50,19 @@ public class End2EndTest extends AbstractProvisioningTest {
private static URI repositoryLocation = URI.create("http://download.eclipse.org/eclipse/updates/3.5");
+ private IProvisioningAgent end2endAgent = null;
+
protected void setUp() throws Exception {
- ServiceReference sr = TestActivator.context.getServiceReference(IDirector.SERVICE_NAME);
- if (sr == null)
- throw new RuntimeException("Director service not available");
- director = createDirector();
- // planner = createPlanner();
- ServiceReference sr2 = TestActivator.context.getServiceReference(IMetadataRepositoryManager.SERVICE_NAME);
- metadataRepoManager = (IMetadataRepositoryManager) TestActivator.context.getService(sr2);
- if (metadataRepoManager == null)
- throw new RuntimeException("Metadata repository manager could not be loaded");
-
- ServiceReference sr3 = TestActivator.context.getServiceReference(IArtifactRepositoryManager.SERVICE_NAME);
- artifactRepoManager = (IArtifactRepositoryManager) TestActivator.context.getService(sr3);
- if (artifactRepoManager == null)
- throw new RuntimeException("Artifact repo manager could not be loaded");
+ ServiceReference sr = TestActivator.context.getServiceReference(IProvisioningAgentProvider.SERVICE_NAME);
+ IProvisioningAgentProvider agentFactory = (IProvisioningAgentProvider) TestActivator.context.getService(sr);
+ end2endAgent = agentFactory.createAgent(getTempFolder().toURI());
+ metadataRepoManager = (IMetadataRepositoryManager) end2endAgent.getService(IMetadataRepositoryManager.SERVICE_NAME);
+ artifactRepoManager = (IArtifactRepositoryManager) end2endAgent.getService(IArtifactRepositoryManager.SERVICE_NAME);
+ director = (IDirector) end2endAgent.getService(IDirector.SERVICE_NAME);
}
protected IProfile createProfile(String profileId, String installFolder) {
- IProfileRegistry profileRegistry = getProfileRegistry();
+ IProfileRegistry profileRegistry = (IProfileRegistry) end2endAgent.getService(IProfileRegistry.SERVICE_NAME);
if (profileRegistry == null) {
throw new RuntimeException("Profile registry service not available");
}
@@ -78,7 +74,11 @@ public class End2EndTest extends AbstractProvisioningTest {
properties.put(IProfile.PROP_ENVIRONMENTS, "osgi.os=" + info.getOS() + ",osgi.ws=" + info.getWS() + ",osgi.arch=" + info.getOSArch());
properties.put("org.eclipse.update.install.features", "true");
properties.put(IProfile.PROP_CACHE, installFolder);
- return createProfile(profileId, properties);
+ try {
+ return profileRegistry.addProfile(profileId, properties);
+ } catch (ProvisionException e) {
+ throw new IllegalArgumentException(e.getMessage());
+ }
}
public void testInstallSDK35() {

Back to the top