Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJohn Arthorne2009-10-20 14:17:33 -0400
committerJohn Arthorne2009-10-20 14:17:33 -0400
commitd80ba2d81fc220ab5862e72c05e93e403542efb1 (patch)
tree2d49008e3573a51df96b2e55304607dcff8fdf1d
parent0f37c767a9e304c0b15c4eaa08f833bd5f454831 (diff)
downloadrt.equinox.p2-d80ba2d81fc220ab5862e72c05e93e403542efb1.tar.gz
rt.equinox.p2-d80ba2d81fc220ab5862e72c05e93e403542efb1.tar.xz
rt.equinox.p2-d80ba2d81fc220ab5862e72c05e93e403542efb1.zip
Bug 290207 - Support multiple p2 instances in a single VM
-rw-r--r--bundles/org.eclipse.equinox.p2.artifact.repository/.project5
-rw-r--r--bundles/org.eclipse.equinox.p2.artifact.repository/META-INF/MANIFEST.MF3
-rw-r--r--bundles/org.eclipse.equinox.p2.artifact.repository/OSGI-INF/repositoryManager.xml8
-rw-r--r--bundles/org.eclipse.equinox.p2.artifact.repository/build.properties23
-rw-r--r--bundles/org.eclipse.equinox.p2.artifact.repository/src/org/eclipse/equinox/internal/p2/artifact/repository/ArtifactRepositoryComponent.java26
-rw-r--r--bundles/org.eclipse.equinox.p2.director.app/.settings/org.eclipse.jdt.core.prefs4
-rw-r--r--bundles/org.eclipse.equinox.p2.director.app/.settings/org.eclipse.jdt.launching.prefs3
-rw-r--r--bundles/org.eclipse.equinox.p2.director.app/META-INF/MANIFEST.MF1
-rw-r--r--bundles/org.eclipse.equinox.p2.director.app/src/org/eclipse/equinox/internal/p2/director/app/DirectorApplication.java225
-rw-r--r--bundles/org.eclipse.equinox.p2.director.app/src/org/eclipse/equinox/internal/p2/director/app/Messages.java2
-rw-r--r--bundles/org.eclipse.equinox.p2.director.app/src/org/eclipse/equinox/internal/p2/director/app/messages.properties3
-rw-r--r--bundles/org.eclipse.equinox.p2.director/.project5
-rw-r--r--bundles/org.eclipse.equinox.p2.director/META-INF/MANIFEST.MF3
-rw-r--r--bundles/org.eclipse.equinox.p2.director/OSGI-INF/director.xml8
-rw-r--r--bundles/org.eclipse.equinox.p2.director/OSGI-INF/planner.xml8
-rw-r--r--bundles/org.eclipse.equinox.p2.director/build.properties5
-rw-r--r--bundles/org.eclipse.equinox.p2.director/src/org/eclipse/equinox/internal/p2/director/DirectorComponent.java30
-rw-r--r--bundles/org.eclipse.equinox.p2.director/src/org/eclipse/equinox/internal/p2/director/PlannerComponent.java28
-rw-r--r--bundles/org.eclipse.equinox.p2.director/src/org/eclipse/equinox/internal/p2/director/SimpleDirector.java7
-rw-r--r--bundles/org.eclipse.equinox.p2.director/src/org/eclipse/equinox/internal/p2/director/SimplePlanner.java29
-rw-r--r--bundles/org.eclipse.equinox.p2.director/src/org/eclipse/equinox/internal/provisional/p2/director/IDirector.java5
-rw-r--r--bundles/org.eclipse.equinox.p2.director/src/org/eclipse/equinox/internal/provisional/p2/director/IPlanner.java5
-rw-r--r--bundles/org.eclipse.equinox.p2.engine/META-INF/MANIFEST.MF2
-rw-r--r--bundles/org.eclipse.equinox.p2.engine/OSGI-INF/engine.xml8
-rw-r--r--bundles/org.eclipse.equinox.p2.engine/OSGI-INF/profileRegistry.xml4
-rw-r--r--bundles/org.eclipse.equinox.p2.engine/build.properties2
-rw-r--r--bundles/org.eclipse.equinox.p2.engine/src/org/eclipse/equinox/internal/p2/engine/EngineComponent.java33
-rw-r--r--bundles/org.eclipse.equinox.p2.engine/src/org/eclipse/equinox/internal/p2/engine/ProfileRegistryComponent.java2
-rw-r--r--bundles/org.eclipse.equinox.p2.engine/src/org/eclipse/equinox/internal/provisional/p2/engine/Engine.java40
-rw-r--r--bundles/org.eclipse.equinox.p2.engine/src/org/eclipse/equinox/internal/provisional/p2/engine/IProfileRegistry.java4
-rw-r--r--bundles/org.eclipse.equinox.p2.exemplarysetup/src/org/eclipse/equinox/internal/p2/exemplarysetup/Activator.java24
-rw-r--r--bundles/org.eclipse.equinox.p2.metadata.repository/.project5
-rw-r--r--bundles/org.eclipse.equinox.p2.metadata.repository/META-INF/MANIFEST.MF3
-rw-r--r--bundles/org.eclipse.equinox.p2.metadata.repository/OSGI-INF/repositoryManager.xml8
-rw-r--r--bundles/org.eclipse.equinox.p2.metadata.repository/build.properties3
-rw-r--r--bundles/org.eclipse.equinox.p2.metadata.repository/src/org/eclipse/equinox/internal/p2/metadata/repository/Activator.java21
-rw-r--r--bundles/org.eclipse.equinox.p2.metadata.repository/src/org/eclipse/equinox/internal/p2/metadata/repository/CacheManager.java34
-rw-r--r--bundles/org.eclipse.equinox.p2.metadata.repository/src/org/eclipse/equinox/internal/p2/metadata/repository/MetadataRepositoryComponent.java33
-rw-r--r--bundles/org.eclipse.equinox.p2.repository/src/org/eclipse/equinox/internal/p2/repository/CacheManager.java34
39 files changed, 457 insertions, 239 deletions
diff --git a/bundles/org.eclipse.equinox.p2.artifact.repository/.project b/bundles/org.eclipse.equinox.p2.artifact.repository/.project
index 529f56491..ad19a3475 100644
--- a/bundles/org.eclipse.equinox.p2.artifact.repository/.project
+++ b/bundles/org.eclipse.equinox.p2.artifact.repository/.project
@@ -35,6 +35,11 @@
<arguments>
</arguments>
</buildCommand>
+ <buildCommand>
+ <name>org.eclipse.pde.ds.core.builder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.pde.PluginNature</nature>
diff --git a/bundles/org.eclipse.equinox.p2.artifact.repository/META-INF/MANIFEST.MF b/bundles/org.eclipse.equinox.p2.artifact.repository/META-INF/MANIFEST.MF
index ac38803c9..0f87eab08 100644
--- a/bundles/org.eclipse.equinox.p2.artifact.repository/META-INF/MANIFEST.MF
+++ b/bundles/org.eclipse.equinox.p2.artifact.repository/META-INF/MANIFEST.MF
@@ -61,6 +61,8 @@ Import-Package: javax.xml.parsers,
org.eclipse.equinox.internal.provisional.p2.metadata,
org.eclipse.equinox.internal.provisional.p2.repository,
org.eclipse.equinox.internal.provisional.spi.p2.repository,
+ org.eclipse.equinox.p2.core,
+ org.eclipse.equinox.p2.core.spi,
org.eclipse.internal.provisional.equinox.p2.jarprocessor;resolution:=optional,
org.eclipse.osgi.framework.log;version="1.0.0",
org.eclipse.osgi.signedcontent;version="1.0.0",
@@ -75,3 +77,4 @@ Bundle-RequiredExecutionEnvironment: J2SE-1.4,
CDC-1.1/Foundation-1.1
Require-Bundle: org.eclipse.equinox.common;bundle-version="[3.5.0,4.0.0)",
org.eclipse.equinox.registry
+Service-Component: OSGI-INF/repositoryManager.xml
diff --git a/bundles/org.eclipse.equinox.p2.artifact.repository/OSGI-INF/repositoryManager.xml b/bundles/org.eclipse.equinox.p2.artifact.repository/OSGI-INF/repositoryManager.xml
new file mode 100644
index 000000000..c85058f8c
--- /dev/null
+++ b/bundles/org.eclipse.equinox.p2.artifact.repository/OSGI-INF/repositoryManager.xml
@@ -0,0 +1,8 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<scr:component xmlns:scr="http://www.osgi.org/xmlns/scr/v1.1.0" name="org.eclipse.equinox.p2.artifact.repository">
+ <implementation class="org.eclipse.equinox.internal.p2.artifact.repository.ArtifactRepositoryComponent"/>
+ <service>
+ <provide interface="org.eclipse.equinox.p2.core.spi.IAgentServiceFactory"/>
+ </service>
+ <property name="p2.agent.servicename" type="String" value="org.eclipse.equinox.internal.provisional.p2.artifact.repository.IArtifactRepositoryManager"/>
+</scr:component> \ No newline at end of file
diff --git a/bundles/org.eclipse.equinox.p2.artifact.repository/build.properties b/bundles/org.eclipse.equinox.p2.artifact.repository/build.properties
index f00d7fb2b..6a66d4e05 100644
--- a/bundles/org.eclipse.equinox.p2.artifact.repository/build.properties
+++ b/bundles/org.eclipse.equinox.p2.artifact.repository/build.properties
@@ -1,25 +1,16 @@
-###############################################################################
-# Copyright (c) 2007, 2009 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
-# http://www.eclipse.org/legal/epl-v10.html
-#
-# Contributors:
-# IBM Corporation - initial API and implementation
-###############################################################################
-source.. = src/
output.. = bin/
bin.includes = META-INF/,\
.,\
plugin.xml,\
about.html,\
plugin.properties,\
- ant_tasks/artifactRepository-ant.jar
-src.includes = about.html,\
- schema/
-jars.extra.classpath = platform:/plugin/org.apache.ant/lib/ant.jar
+ ant_tasks/artifactRepository-ant.jar,\
+ OSGI-INF/
jars.compile.order = .,\
ant_tasks/artifactRepository-ant.jar
-source.ant_tasks/artifactRepository-ant.jar = src_ant/
output.ant_tasks/artifactRepository-ant.jar = bin_ant/
+src.includes = about.html,\
+ schema/
+source.. = src/
+source.ant_tasks/artifactRepository-ant.jar = src_ant/
+jars.extra.classpath = platform:/plugin/org.apache.ant/lib/ant.jar
diff --git a/bundles/org.eclipse.equinox.p2.artifact.repository/src/org/eclipse/equinox/internal/p2/artifact/repository/ArtifactRepositoryComponent.java b/bundles/org.eclipse.equinox.p2.artifact.repository/src/org/eclipse/equinox/internal/p2/artifact/repository/ArtifactRepositoryComponent.java
new file mode 100644
index 000000000..39f807b30
--- /dev/null
+++ b/bundles/org.eclipse.equinox.p2.artifact.repository/src/org/eclipse/equinox/internal/p2/artifact/repository/ArtifactRepositoryComponent.java
@@ -0,0 +1,26 @@
+/*******************************************************************************
+ * Copyright (c) 2009 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
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.equinox.internal.p2.artifact.repository;
+
+import org.eclipse.equinox.internal.provisional.p2.artifact.repository.IArtifactRepositoryManager;
+import org.eclipse.equinox.p2.core.IProvisioningAgent;
+import org.eclipse.equinox.p2.core.spi.IAgentServiceFactory;
+
+/**
+ * Service factory providing {@link IArtifactRepositoryManager} instances.
+ */
+public class ArtifactRepositoryComponent implements IAgentServiceFactory {
+
+ public Object createService(IProvisioningAgent agent) {
+ return new ArtifactRepositoryManager();
+ }
+
+}
diff --git a/bundles/org.eclipse.equinox.p2.director.app/.settings/org.eclipse.jdt.core.prefs b/bundles/org.eclipse.equinox.p2.director.app/.settings/org.eclipse.jdt.core.prefs
index 05a85c1c8..802d3818a 100644
--- a/bundles/org.eclipse.equinox.p2.director.app/.settings/org.eclipse.jdt.core.prefs
+++ b/bundles/org.eclipse.equinox.p2.director.app/.settings/org.eclipse.jdt.core.prefs
@@ -1,8 +1,9 @@
-#Fri Apr 24 11:01:33 EDT 2009
+#Wed Oct 07 15:35:11 EDT 2009
eclipse.preferences.version=1
org.eclipse.jdt.core.builder.cleanOutputFolder=clean
org.eclipse.jdt.core.builder.duplicateResourceTask=warning
org.eclipse.jdt.core.builder.invalidClasspath=abort
+org.eclipse.jdt.core.builder.recreateModifiedClassFileInOutputFolder=ignore
org.eclipse.jdt.core.builder.resourceCopyExclusionFilter=*.launch
org.eclipse.jdt.core.circularClasspath=error
org.eclipse.jdt.core.classpath.exclusionPatterns=enabled
@@ -50,6 +51,7 @@ org.eclipse.jdt.core.compiler.problem.missingJavadocTags=ignore
org.eclipse.jdt.core.compiler.problem.missingJavadocTagsOverriding=enabled
org.eclipse.jdt.core.compiler.problem.missingJavadocTagsVisibility=public
org.eclipse.jdt.core.compiler.problem.missingOverrideAnnotation=ignore
+org.eclipse.jdt.core.compiler.problem.missingOverrideAnnotationForInterfaceMethodImplementation=enabled
org.eclipse.jdt.core.compiler.problem.missingSerialVersion=warning
org.eclipse.jdt.core.compiler.problem.missingSynchronizedOnInheritedMethod=ignore
org.eclipse.jdt.core.compiler.problem.noEffectAssignment=warning
diff --git a/bundles/org.eclipse.equinox.p2.director.app/.settings/org.eclipse.jdt.launching.prefs b/bundles/org.eclipse.equinox.p2.director.app/.settings/org.eclipse.jdt.launching.prefs
new file mode 100644
index 000000000..233758b1b
--- /dev/null
+++ b/bundles/org.eclipse.equinox.p2.director.app/.settings/org.eclipse.jdt.launching.prefs
@@ -0,0 +1,3 @@
+#Wed Oct 07 15:35:11 EDT 2009
+eclipse.preferences.version=1
+org.eclipse.jdt.launching.PREF_STRICTLY_COMPATIBLE_JRE_NOT_AVAILABLE=warning
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 dbfaa1c9a..d11686979 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
@@ -16,6 +16,7 @@ Import-Package: org.eclipse.equinox.app,
org.eclipse.equinox.internal.provisional.p2.metadata.query,
org.eclipse.equinox.internal.provisional.p2.metadata.repository,
org.eclipse.equinox.internal.provisional.p2.repository,
+ org.eclipse.equinox.p2.core,
org.eclipse.osgi.framework.log,
org.eclipse.osgi.service.environment,
org.eclipse.osgi.util,
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 f2c0a15ed..91b4bdcdc 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
@@ -12,8 +12,6 @@
*******************************************************************************/
package org.eclipse.equinox.internal.p2.director.app;
-import org.eclipse.equinox.internal.provisional.p2.metadata.IVersionedId;
-
import java.io.*;
import java.net.URI;
import java.net.URISyntaxException;
@@ -21,7 +19,6 @@ import java.util.*;
import org.eclipse.core.runtime.*;
import org.eclipse.equinox.app.IApplication;
import org.eclipse.equinox.app.IApplicationContext;
-import org.eclipse.equinox.internal.p2.console.ProvisioningHelper;
import org.eclipse.equinox.internal.p2.core.helpers.*;
import org.eclipse.equinox.internal.provisional.p2.artifact.repository.IArtifactRepositoryManager;
import org.eclipse.equinox.internal.provisional.p2.core.ProvisionException;
@@ -31,6 +28,8 @@ import org.eclipse.equinox.internal.provisional.p2.metadata.*;
import org.eclipse.equinox.internal.provisional.p2.metadata.Version;
import org.eclipse.equinox.internal.provisional.p2.metadata.query.*;
import org.eclipse.equinox.internal.provisional.p2.metadata.repository.IMetadataRepositoryManager;
+import org.eclipse.equinox.p2.core.IProvisioningAgent;
+import org.eclipse.equinox.p2.core.IProvisioningAgentProvider;
import org.eclipse.osgi.framework.log.FrameworkLog;
import org.eclipse.osgi.service.environment.EnvironmentInfo;
import org.eclipse.osgi.util.NLS;
@@ -49,10 +48,11 @@ public class DirectorApplication implements IApplication {
public LocationQueryable(URI location) {
this.location = location;
+ Assert.isNotNull(location);
}
public Collector query(Query query, Collector collector, IProgressMonitor monitor) {
- return ProvisioningHelper.getInstallableUnits(location, query, collector, monitor);
+ return getInstallableUnits(location, query, collector, monitor);
}
}
@@ -112,15 +112,8 @@ public class DirectorApplication implements IApplication {
private static final CommandLineOption OPTION_P2_ARCH = new CommandLineOption(new String[] {"-p2.arch"}, null, Messages.Help_The_ARCH_when_profile_is_created); //$NON-NLS-1$
private static final CommandLineOption OPTION_P2_NL = new CommandLineOption(new String[] {"-p2.nl"}, null, Messages.Help_The_NL_when_profile_is_created); //$NON-NLS-1$
- static private final String BUNDLE_CORE = "org.eclipse.equinox.p2.core"; //$NON-NLS-1$
- static private final String BUNDLE_ENGINE = "org.eclipse.equinox.p2.engine"; //$NON-NLS-1$
- static private final String BUNDLE_EXEMPLARY_SETUP = "org.eclipse.equinox.p2.exemplarysetup"; //$NON-NLS-1$
- static private final String BUNDLE_FRAMEWORKADMIN_EQUINOX = "org.eclipse.equinox.frameworkadmin.equinox"; //$NON-NLS-1$
- static private final String BUNDLE_SIMPLE_CONFIGURATOR_MANIPULATOR = "org.eclipse.equinox.simpleconfigurator.manipulator"; //$NON-NLS-1$
private static final Integer EXIT_ERROR = new Integer(13);
static private final String FLAVOR_DEFAULT = "tooling"; //$NON-NLS-1$
- static private final String PROP_P2_DATA_AREA = "eclipse.p2.data.area"; //$NON-NLS-1$
-
static private final String PROP_P2_PROFILE = "eclipse.p2.profile"; //$NON-NLS-1$
public static final String LINE_SEPARATOR = System.getProperty("line.separator"); //$NON-NLS-1$
@@ -164,16 +157,16 @@ public class DirectorApplication implements IApplication {
vnames.add(VersionedId.parse(roots[i]));
}
- private static String processFileArgument(String arg) {
+ private static File processFileArgument(String arg) {
if (arg.startsWith("file:")) //$NON-NLS-1$
arg = arg.substring(5);
// we create a path object here to handle ../ entries in the middle of paths
- return Path.fromOSString(arg).toOSString();
+ return Path.fromOSString(arg).toFile();
}
private IArtifactRepositoryManager artifactManager;
- private IMetadataRepositoryManager metadataManager;
+ IMetadataRepositoryManager metadataManager;
private URI[] artifactReposForRemoval;
private URI[] metadataReposForRemoval;
@@ -184,9 +177,9 @@ public class DirectorApplication implements IApplication {
private final List rootsToUninstall = new ArrayList();
private final List rootsToList = new ArrayList();
- private String bundlePool = null;
- private String destination;
- private String sharedLocation;
+ private File bundlePool = null;
+ private File destination;
+ private File sharedLocation;
private String flavor;
private boolean printHelpInfo = false;
private boolean printIUList = false;
@@ -205,13 +198,10 @@ public class DirectorApplication implements IApplication {
private boolean noProfileId = false;
private PackageAdmin packageAdmin;
private ServiceReference packageAdminRef;
+ private ServiceReference agentProviderRef;
private IPlanner planner;
- private String preservedDataArea;
- private String preservedProfile;
- private boolean restartCore;
- private boolean restartEngine;
- private boolean restartExemplarySetup;
+ private IProvisioningAgent agent;
private ProfileChangeRequest buildProvisioningRequest(IProfile profile, IInstallableUnit[] installs, IInstallableUnit[] uninstalls) {
ProfileChangeRequest request = new ProfileChangeRequest(profile);
@@ -240,7 +230,7 @@ public class DirectorApplication implements IApplication {
int top = metadataRepositoryLocations.size();
if (top == 0)
- return ProvisioningHelper.getInstallableUnits(null, query, collector, nullMonitor);
+ return getInstallableUnits(null, query, collector, nullMonitor);
Collector result = collector != null ? collector : new Collector();
IQueryable[] locationQueryables = new IQueryable[top];
@@ -301,11 +291,12 @@ public class DirectorApplication implements IApplication {
}
private IProfile initializeProfile() throws CoreException {
+ IProfileRegistry profileRegistry = (IProfileRegistry) agent.getService(IProfileRegistry.class.getName());
if (profileId == null) {
profileId = IProfileRegistry.SELF;
noProfileId = true;
}
- IProfile profile = ProvisioningHelper.getProfile(profileId);
+ IProfile profile = profileRegistry.getProfile(profileId);
if (profile == null) {
if (destination == null)
missingArgument("destination"); //$NON-NLS-1$
@@ -313,12 +304,12 @@ public class DirectorApplication implements IApplication {
flavor = System.getProperty("eclipse.p2.configurationFlavor", FLAVOR_DEFAULT); //$NON-NLS-1$
Properties props = new Properties();
- props.setProperty(IProfile.PROP_INSTALL_FOLDER, destination);
+ props.setProperty(IProfile.PROP_INSTALL_FOLDER, destination.toString());
props.setProperty(IProfile.PROP_FLAVOR, flavor);
if (bundlePool == null)
- props.setProperty(IProfile.PROP_CACHE, sharedLocation == null ? destination : sharedLocation);
+ props.setProperty(IProfile.PROP_CACHE, sharedLocation == null ? destination.getAbsolutePath() : sharedLocation.getAbsolutePath());
else
- props.setProperty(IProfile.PROP_CACHE, bundlePool);
+ props.setProperty(IProfile.PROP_CACHE, bundlePool.getAbsolutePath());
if (roamingProfile)
props.setProperty(IProfile.PROP_ROAMING, Boolean.TRUE.toString());
@@ -327,7 +318,7 @@ public class DirectorApplication implements IApplication {
props.setProperty(IProfile.PROP_ENVIRONMENTS, env);
if (profileProperties != null)
putProperties(profileProperties, props);
- profile = ProvisioningHelper.addProfile(profileId, props);
+ profile = profileRegistry.addProfile(profileId, props);
String currentFlavor = profile.getProperty(IProfile.PROP_FLAVOR);
if (currentFlavor != null && !currentFlavor.endsWith(flavor))
throw new RuntimeException(NLS.bind(Messages.flavor_0_inconsistent_with_flavor_1, flavor, currentFlavor));
@@ -343,7 +334,7 @@ public class DirectorApplication implements IApplication {
if (artifactRepositoryLocations == null)
missingArgument("-artifactRepository"); //$NON-NLS-1$
- artifactManager = (IArtifactRepositoryManager) ServiceHelper.getService(Activator.getContext(), IArtifactRepositoryManager.class.getName());
+ artifactManager = (IArtifactRepositoryManager) agent.getService(IArtifactRepositoryManager.SERVICE_NAME);
if (artifactManager == null)
throw new ProvisionException(Messages.Application_NoManager);
@@ -370,7 +361,7 @@ public class DirectorApplication implements IApplication {
if (metadataRepositoryLocations == null)
missingArgument("metadataRepository"); //$NON-NLS-1$
- metadataManager = (IMetadataRepositoryManager) ServiceHelper.getService(Activator.getContext(), IMetadataRepositoryManager.class.getName());
+ metadataManager = (IMetadataRepositoryManager) agent.getService(IMetadataRepositoryManager.SERVICE_NAME);
if (metadataManager == null)
throw new ProvisionException(Messages.Application_NoManager);
@@ -400,63 +391,52 @@ public class DirectorApplication implements IApplication {
BundleContext context = Activator.getContext();
packageAdminRef = context.getServiceReference(PackageAdmin.class.getName());
packageAdmin = (PackageAdmin) context.getService(packageAdminRef);
+ agentProviderRef = context.getServiceReference(IProvisioningAgentProvider.SERVICE_NAME);
+ IProvisioningAgentProvider provider = (IProvisioningAgentProvider) context.getService(agentProviderRef);
+ File p2DataArea;
if (destination != null || sharedLocation != null) {
- restartExemplarySetup = stopTransient(BUNDLE_EXEMPLARY_SETUP);
- restartEngine = stopTransient(BUNDLE_ENGINE); // Since it uses the agent data location
- restartCore = stopTransient(BUNDLE_CORE); // Since it manages the agent data location
-
- // Set/Clear properties that we don't want to inherit from the caller
- String p2DataArea = sharedLocation == null ? new File(destination, "p2").getAbsolutePath() : sharedLocation; //$NON-NLS-1$
- preservedDataArea = System.setProperty(PROP_P2_DATA_AREA, p2DataArea);
- if (profileId == null) {
- if (destination != null) {
- File configIni = new File(destination, "configuration/config.ini"); //$NON-NLS-1$
- InputStream in = null;
- try {
- Properties ciProps = new Properties();
- in = new BufferedInputStream(new FileInputStream(configIni));
- ciProps.load(in);
- profileId = ciProps.getProperty(PROP_P2_PROFILE);
- } catch (IOException e) {
- // Ignore
- } finally {
- if (in != null)
- try {
- in.close();
- } catch (IOException e) {
- // Ignore;
- }
- }
- if (profileId == null)
- profileId = destination;
+ p2DataArea = sharedLocation == null ? new File(destination, "p2") : sharedLocation;//$NON-NLS-1$
+ } else {
+ p2DataArea = null;
+ }
+ agent = provider.createAgent(p2DataArea.toURI());
+ if (profileId == null) {
+ if (destination != null) {
+ File configIni = new File(destination, "configuration/config.ini"); //$NON-NLS-1$
+ InputStream in = null;
+ try {
+ Properties ciProps = new Properties();
+ in = new BufferedInputStream(new FileInputStream(configIni));
+ ciProps.load(in);
+ profileId = ciProps.getProperty(PROP_P2_PROFILE);
+ } catch (IOException e) {
+ // Ignore
+ } finally {
+ if (in != null)
+ try {
+ in.close();
+ } catch (IOException e) {
+ // Ignore;
+ }
}
+ if (profileId == null)
+ profileId = destination.toString();
}
- if (profileId != null)
- preservedProfile = System.setProperty(PROP_P2_PROFILE, profileId);
- else
- preservedProfile = (String) System.getProperties().remove(PROP_P2_PROFILE);
}
+ if (profileId != null)
+ agent.registerService(PROP_P2_PROFILE, profileId);
+ else
+ agent.unregisterService(PROP_P2_PROFILE, null);
- if (!startTransient(BUNDLE_SIMPLE_CONFIGURATOR_MANIPULATOR))
- throw new ProvisionException(NLS.bind(Messages.Missing_bundle, BUNDLE_SIMPLE_CONFIGURATOR_MANIPULATOR));
- if (!startTransient(BUNDLE_FRAMEWORKADMIN_EQUINOX))
- throw new ProvisionException(NLS.bind(Messages.Missing_bundle, BUNDLE_FRAMEWORKADMIN_EQUINOX));
- if (!startTransient(BUNDLE_CORE))
- throw new ProvisionException(NLS.bind(Messages.Missing_bundle, BUNDLE_CORE));
- if (!startTransient(BUNDLE_ENGINE))
- throw new ProvisionException(NLS.bind(Messages.Missing_bundle, BUNDLE_ENGINE));
- if (!startTransient(BUNDLE_EXEMPLARY_SETUP))
- throw new ProvisionException(NLS.bind(Messages.Missing_bundle, BUNDLE_EXEMPLARY_SETUP));
-
- IDirector director = (IDirector) ServiceHelper.getService(context, IDirector.class.getName());
+ IDirector director = (IDirector) agent.getService(IDirector.SERVICE_NAME);
if (director == null)
throw new ProvisionException(Messages.Missing_director);
- planner = (IPlanner) ServiceHelper.getService(context, IPlanner.class.getName());
+ planner = (IPlanner) agent.getService(IPlanner.SERVICE_NAME);
if (planner == null)
throw new ProvisionException(Messages.Missing_planner);
- engine = (IEngine) ServiceHelper.getService(context, IEngine.SERVICE_NAME);
+ engine = (IEngine) agent.getService(IEngine.SERVICE_NAME);
if (engine == null)
throw new ProvisionException(Messages.Missing_Engine);
}
@@ -618,7 +598,7 @@ public class DirectorApplication implements IApplication {
}
if (sharedLocation == null)
// -shared without an argument means "Use default shared area"
- sharedLocation = Path.fromOSString(System.getProperty("user.home")).append(".p2/").toOSString(); //$NON-NLS-1$ //$NON-NLS-2$
+ sharedLocation = Path.fromOSString(System.getProperty("user.home")).append(".p2/").toFile(); //$NON-NLS-1$ //$NON-NLS-2$
continue;
}
@@ -712,34 +692,13 @@ public class DirectorApplication implements IApplication {
}
}
- private void restoreServices() throws CoreException {
+ private void cleanupServices() {
BundleContext context = Activator.getContext();
- try {
- if (destination == null && sharedLocation == null)
- return;
-
- stopTransient(BUNDLE_EXEMPLARY_SETUP);
- stopTransient(BUNDLE_CORE); // Since it manages the agent data location
-
- if (preservedDataArea != null)
- System.setProperty(PROP_P2_DATA_AREA, preservedDataArea);
- else
- System.getProperties().remove(PROP_P2_DATA_AREA);
-
- if (preservedProfile != null)
- System.setProperty(PROP_P2_PROFILE, preservedProfile);
- else
- System.getProperties().remove(PROP_P2_PROFILE);
-
- if (restartCore)
- startTransient(BUNDLE_CORE);
- if (restartEngine)
- startTransient(BUNDLE_ENGINE);
- if (restartExemplarySetup)
- startTransient(BUNDLE_EXEMPLARY_SETUP);
- } finally {
+ //dispose agent
+ if (agentProviderRef != null)
+ context.ungetService(agentProviderRef);
+ if (packageAdminRef != null)
context.ungetService(packageAdminRef);
- }
}
public Object run(String[] args) throws CoreException {
@@ -770,14 +729,14 @@ public class DirectorApplication implements IApplication {
} finally {
if (packageAdminRef != null) {
cleanupRepositories();
- restoreServices();
+ cleanupServices();
}
}
}
private void revertToPreviousState() throws CoreException {
IProfile profile = initializeProfile();
- IProfileRegistry profileRegistry = (IProfileRegistry) ServiceHelper.getService(Activator.getContext(), IProfileRegistry.class.getName());
+ IProfileRegistry profileRegistry = (IProfileRegistry) agent.getService(IProfileRegistry.class.getName());
IProfile targetProfile = null;
if (revertToPreviousState == 0) {
long[] profiles = profileRegistry.listProfileTimestamps(profile.getProfileId());
@@ -813,6 +772,22 @@ public class DirectorApplication implements IApplication {
strm.print(' ');
}
+ Collector getInstallableUnits(URI location, Query query, Collector collector, IProgressMonitor monitor) {
+ IQueryable queryable = null;
+ if (location == null) {
+ queryable = metadataManager;
+ } else {
+ try {
+ queryable = metadataManager.loadRepository(location, monitor);
+ } catch (ProvisionException e) {
+ //repository is not available - just return empty result
+ }
+ }
+ if (queryable != null)
+ return queryable.query(query, collector, monitor);
+ return collector;
+ }
+
private void deeplyPrint(CoreException ce, PrintStream strm, int level) {
appendLevelPrefix(strm, level);
if (stackTrace)
@@ -879,37 +854,6 @@ public class DirectorApplication implements IApplication {
return run((String[]) context.getArguments().get("application.args")); //$NON-NLS-1$
}
- private boolean startTransient(String bundleName) throws CoreException {
- Bundle bundle = getBundle(bundleName);
- if (bundle == null)
- return false;
- try {
- bundle.start(Bundle.START_TRANSIENT);
- } catch (BundleException e) {
- throw new ProvisionException(NLS.bind(Messages.unable_to_start_bundle_0, bundleName));
- }
- return true;
- }
-
- public void stop() {
- // Nothing left to do here
- }
-
- private boolean stopTransient(String bundleName) throws CoreException {
- Bundle bundle = getBundle(bundleName);
- boolean wasActive = false;
- if (bundle != null) {
- wasActive = (bundle.getState() & (Bundle.ACTIVE | Bundle.STARTING)) != 0;
- if (wasActive)
- try {
- bundle.stop(Bundle.STOP_TRANSIENT);
- } catch (BundleException e) {
- throw new ProvisionException(NLS.bind(Messages.unable_to_stop_bundle_0, bundleName));
- }
- }
- return wasActive;
- }
-
private String toString(Map context) {
StringBuffer result = new StringBuffer();
Iterator entries = context.entrySet().iterator();
@@ -941,10 +885,9 @@ public class DirectorApplication implements IApplication {
return;
ProfileChangeRequest request = new ProfileChangeRequest(profile);
- File destinationFile = new File(destination);
- if (!destinationFile.equals(new File(profile.getProperty(IProfile.PROP_INSTALL_FOLDER))))
+ if (!destination.equals(new File(profile.getProperty(IProfile.PROP_INSTALL_FOLDER))))
request.setProfileProperty(IProfile.PROP_INSTALL_FOLDER, destination);
- if (!destinationFile.equals(new File(profile.getProperty(IProfile.PROP_CACHE))))
+ if (!destination.equals(new File(profile.getProperty(IProfile.PROP_CACHE))))
request.setProfileProperty(IProfile.PROP_CACHE, destination);
if (request.getProfileProperties().size() == 0)
return;
@@ -961,4 +904,8 @@ public class DirectorApplication implements IApplication {
if (!status.isOK())
throw new CoreException(new MultiStatus(org.eclipse.equinox.internal.p2.director.app.Activator.ID, IStatus.ERROR, new IStatus[] {status}, NLS.bind(Messages.Cant_change_roaming, profile.getProfileId()), null));
}
+
+ public void stop() {
+ // Nothing left to do here
+ }
} \ No newline at end of file
diff --git a/bundles/org.eclipse.equinox.p2.director.app/src/org/eclipse/equinox/internal/p2/director/app/Messages.java b/bundles/org.eclipse.equinox.p2.director.app/src/org/eclipse/equinox/internal/p2/director/app/Messages.java
index 365375426..18a6ea678 100644
--- a/bundles/org.eclipse.equinox.p2.director.app/src/org/eclipse/equinox/internal/p2/director/app/Messages.java
+++ b/bundles/org.eclipse.equinox.p2.director.app/src/org/eclipse/equinox/internal/p2/director/app/Messages.java
@@ -62,6 +62,8 @@ public class Messages extends NLS {
public static String Missing_profileid;
public static String Missing_Required_Argument;
public static String Missing_profile;
+
+ public static String Missing_registry;
public static String Operation_complete;
public static String Operation_failed;
public static String option_0_requires_an_argument;
diff --git a/bundles/org.eclipse.equinox.p2.director.app/src/org/eclipse/equinox/internal/p2/director/app/messages.properties b/bundles/org.eclipse.equinox.p2.director.app/src/org/eclipse/equinox/internal/p2/director/app/messages.properties
index 7f6e14438..30795ebff 100644
--- a/bundles/org.eclipse.equinox.p2.director.app/src/org/eclipse/equinox/internal/p2/director/app/messages.properties
+++ b/bundles/org.eclipse.equinox.p2.director.app/src/org/eclipse/equinox/internal/p2/director/app/messages.properties
@@ -60,4 +60,5 @@ unable_to_start_bundle_0=Unable to start bundle {0}.
unable_to_stop_bundle_0=Unable to stop bundle {0}.
unknown_option_0=Unknown option {0}. Use -help for a list of known options.
Help_Missing_argument=The argument specifying what to install or uninstall is missing.
-Missing_profile = The profile to revert to is not being found. \ No newline at end of file
+Missing_profile = The profile to revert to is not being found.
+Missing_registry=The profile registry could not be loaded
diff --git a/bundles/org.eclipse.equinox.p2.director/.project b/bundles/org.eclipse.equinox.p2.director/.project
index 4cb0b36f1..9b9c15e76 100644
--- a/bundles/org.eclipse.equinox.p2.director/.project
+++ b/bundles/org.eclipse.equinox.p2.director/.project
@@ -25,6 +25,11 @@
<arguments>
</arguments>
</buildCommand>
+ <buildCommand>
+ <name>org.eclipse.pde.ds.core.builder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.pde.PluginNature</nature>
diff --git a/bundles/org.eclipse.equinox.p2.director/META-INF/MANIFEST.MF b/bundles/org.eclipse.equinox.p2.director/META-INF/MANIFEST.MF
index 1f6e8a56c..b78fefec8 100644
--- a/bundles/org.eclipse.equinox.p2.director/META-INF/MANIFEST.MF
+++ b/bundles/org.eclipse.equinox.p2.director/META-INF/MANIFEST.MF
@@ -13,6 +13,8 @@ Import-Package: org.eclipse.equinox.internal.p2.core.helpers,
org.eclipse.equinox.internal.provisional.p2.metadata.query,
org.eclipse.equinox.internal.provisional.p2.metadata.repository,
org.eclipse.equinox.internal.provisional.p2.repository,
+ org.eclipse.equinox.p2.core,
+ org.eclipse.equinox.p2.core.spi,
org.eclipse.osgi.util;version="1.0.0",
org.osgi.framework;version="1.3.0"
Export-Package: org.eclipse.equinox.internal.p2.director;x-friends:="org.eclipse.equinox.p2.exemplarysetup,org.eclipse.pde.core",
@@ -39,3 +41,4 @@ Require-Bundle: org.eclipse.equinox.common;bundle-version="[3.5.0,4.0.0)",
org.sat4j.pb;bundle-version="2.1.0",
org.eclipse.core.jobs;bundle-version="3.4.100",
org.eclipse.equinox.p2.metadata
+Service-Component: OSGI-INF/director.xml, OSGI-INF/planner.xml
diff --git a/bundles/org.eclipse.equinox.p2.director/OSGI-INF/director.xml b/bundles/org.eclipse.equinox.p2.director/OSGI-INF/director.xml
new file mode 100644
index 000000000..d4b248761
--- /dev/null
+++ b/bundles/org.eclipse.equinox.p2.director/OSGI-INF/director.xml
@@ -0,0 +1,8 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<scr:component xmlns:scr="http://www.osgi.org/xmlns/scr/v1.1.0" name="org.eclipse.equinox.p2.director">
+ <implementation class="org.eclipse.equinox.internal.p2.director.DirectorComponent"/>
+ <service>
+ <provide interface="org.eclipse.equinox.p2.core.spi.IAgentServiceFactory"/>
+ </service>
+ <property name="p2.agent.servicename" type="String" value="org.eclipse.equinox.internal.provisional.p2.director.IDirector"/>
+</scr:component> \ No newline at end of file
diff --git a/bundles/org.eclipse.equinox.p2.director/OSGI-INF/planner.xml b/bundles/org.eclipse.equinox.p2.director/OSGI-INF/planner.xml
new file mode 100644
index 000000000..6d4b48d45
--- /dev/null
+++ b/bundles/org.eclipse.equinox.p2.director/OSGI-INF/planner.xml
@@ -0,0 +1,8 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<scr:component xmlns:scr="http://www.osgi.org/xmlns/scr/v1.1.0" name="org.eclipse.equinox.p2.planner">
+ <implementation class="org.eclipse.equinox.internal.p2.director.PlannerComponent"/>
+ <service>
+ <provide interface="org.eclipse.equinox.p2.core.spi.IAgentServiceFactory"/>
+ </service>
+ <property name="p2.agent.servicename" type="String" value="org.eclipse.equinox.internal.provisional.p2.director.IPlanner"/>
+</scr:component> \ No newline at end of file
diff --git a/bundles/org.eclipse.equinox.p2.director/build.properties b/bundles/org.eclipse.equinox.p2.director/build.properties
index a6b8330d2..255712635 100644
--- a/bundles/org.eclipse.equinox.p2.director/build.properties
+++ b/bundles/org.eclipse.equinox.p2.director/build.properties
@@ -8,10 +8,11 @@
# Contributors:
# IBM Corporation - initial API and implementation
###############################################################################
-source.. = src/
output.. = bin/
bin.includes = META-INF/,\
+ OSGI-INF/,\
.,\
about.html,\
- plugin.properties
+ plugin.properties,\
src.includes = about.html
+source.. = src/
diff --git a/bundles/org.eclipse.equinox.p2.director/src/org/eclipse/equinox/internal/p2/director/DirectorComponent.java b/bundles/org.eclipse.equinox.p2.director/src/org/eclipse/equinox/internal/p2/director/DirectorComponent.java
new file mode 100644
index 000000000..b4f2a3044
--- /dev/null
+++ b/bundles/org.eclipse.equinox.p2.director/src/org/eclipse/equinox/internal/p2/director/DirectorComponent.java
@@ -0,0 +1,30 @@
+package org.eclipse.equinox.internal.p2.director;
+
+import org.eclipse.equinox.internal.provisional.p2.director.IPlanner;
+import org.eclipse.equinox.internal.provisional.p2.engine.IEngine;
+import org.eclipse.equinox.p2.core.IProvisioningAgent;
+import org.eclipse.equinox.p2.core.spi.IAgentServiceFactory;
+
+/*******************************************************************************
+ * Copyright (c) 2009 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
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+
+/**
+ *
+ */
+public class DirectorComponent implements IAgentServiceFactory {
+
+ public Object createService(IProvisioningAgent agent) {
+ IEngine engine = (IEngine) agent.getService(IEngine.SERVICE_NAME);
+ IPlanner planner = (IPlanner) agent.getService(IPlanner.SERVICE_NAME);
+ return new SimpleDirector(engine, planner);
+ }
+
+}
diff --git a/bundles/org.eclipse.equinox.p2.director/src/org/eclipse/equinox/internal/p2/director/PlannerComponent.java b/bundles/org.eclipse.equinox.p2.director/src/org/eclipse/equinox/internal/p2/director/PlannerComponent.java
new file mode 100644
index 000000000..e363ea236
--- /dev/null
+++ b/bundles/org.eclipse.equinox.p2.director/src/org/eclipse/equinox/internal/p2/director/PlannerComponent.java
@@ -0,0 +1,28 @@
+/*******************************************************************************
+ * Copyright (c) 2009 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
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.equinox.internal.p2.director;
+
+import org.eclipse.equinox.internal.provisional.p2.engine.IProfileRegistry;
+import org.eclipse.equinox.internal.provisional.p2.metadata.repository.IMetadataRepositoryManager;
+import org.eclipse.equinox.p2.core.IProvisioningAgent;
+import org.eclipse.equinox.p2.core.spi.IAgentServiceFactory;
+
+/**
+ * A service factory that provides planner implementations
+ */
+public class PlannerComponent implements IAgentServiceFactory {
+
+ public Object createService(IProvisioningAgent agent) {
+ IProfileRegistry profileRegistry = (IProfileRegistry) agent.getService(IProfileRegistry.SERVICE_NAME);
+ IMetadataRepositoryManager repoManager = (IMetadataRepositoryManager) agent.getService(IMetadataRepositoryManager.SERVICE_NAME);
+ return new SimplePlanner(profileRegistry, repoManager);
+ }
+}
diff --git a/bundles/org.eclipse.equinox.p2.director/src/org/eclipse/equinox/internal/p2/director/SimpleDirector.java b/bundles/org.eclipse.equinox.p2.director/src/org/eclipse/equinox/internal/p2/director/SimpleDirector.java
index 6a14da356..884c422f7 100644
--- a/bundles/org.eclipse.equinox.p2.director/src/org/eclipse/equinox/internal/p2/director/SimpleDirector.java
+++ b/bundles/org.eclipse.equinox.p2.director/src/org/eclipse/equinox/internal/p2/director/SimpleDirector.java
@@ -9,7 +9,6 @@
package org.eclipse.equinox.internal.p2.director;
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.internal.provisional.p2.engine.*;
import org.eclipse.equinox.internal.provisional.p2.metadata.IInstallableUnit;
@@ -21,13 +20,13 @@ public class SimpleDirector implements IDirector {
private IEngine engine;
private IPlanner planner;
- public SimpleDirector() {
- engine = (IEngine) ServiceHelper.getService(DirectorActivator.context, IEngine.class.getName());
+ public SimpleDirector(IEngine engine, IPlanner planner) {
if (engine == null)
throw new IllegalStateException("Provisioning engine is not registered"); //$NON-NLS-1$
- planner = (IPlanner) ServiceHelper.getService(DirectorActivator.context, IPlanner.class.getName());
+ this.engine = engine;
if (planner == null)
throw new IllegalStateException("Unable to find provisioning planner"); //$NON-NLS-1$
+ this.planner = planner;
}
public IStatus revert(IProfile currentProfile, IProfile revertProfile, ProvisioningContext context, IProgressMonitor monitor) {
diff --git a/bundles/org.eclipse.equinox.p2.director/src/org/eclipse/equinox/internal/p2/director/SimplePlanner.java b/bundles/org.eclipse.equinox.p2.director/src/org/eclipse/equinox/internal/p2/director/SimplePlanner.java
index 75705b273..719a69293 100644
--- a/bundles/org.eclipse.equinox.p2.director/src/org/eclipse/equinox/internal/p2/director/SimplePlanner.java
+++ b/bundles/org.eclipse.equinox.p2.director/src/org/eclipse/equinox/internal/p2/director/SimplePlanner.java
@@ -10,16 +10,14 @@
******************************************************************************/
package org.eclipse.equinox.internal.p2.director;
-import org.eclipse.equinox.internal.provisional.p2.metadata.Version;
-import org.eclipse.equinox.internal.provisional.p2.metadata.VersionRange;
-
import java.net.URI;
import java.util.*;
import java.util.Map.Entry;
import org.eclipse.core.runtime.*;
-import org.eclipse.equinox.internal.p2.core.helpers.*;
+import org.eclipse.equinox.internal.p2.core.helpers.LogHelper;
+import org.eclipse.equinox.internal.p2.core.helpers.Tracing;
import org.eclipse.equinox.internal.p2.rollback.FormerState;
-import org.eclipse.equinox.internal.provisional.p2.core.*;
+import org.eclipse.equinox.internal.provisional.p2.core.ProvisionException;
import org.eclipse.equinox.internal.provisional.p2.director.*;
import org.eclipse.equinox.internal.provisional.p2.engine.*;
import org.eclipse.equinox.internal.provisional.p2.metadata.*;
@@ -40,6 +38,9 @@ public class SimplePlanner implements IPlanner {
private static final String EXPLANATION = "org.eclipse.equinox.p2.director.explain"; //$NON-NLS-1$
private static final String CONSIDER_METAREQUIREMENTS = "org.eclipse.equinox.p2.planner.resolveMetaRequirements"; //$NON-NLS-1$
+ private final IMetadataRepositoryManager repoManager;
+ private final IProfileRegistry profileRegistry;
+
private ProvisioningPlan generateProvisioningPlan(Collection fromState, Collection toState, ProfileChangeRequest changeRequest, ProvisioningPlan installerPlan) {
InstallableUnitOperand[] iuOperands = generateOperations(fromState, toState);
PropertyOperand[] propertyOperands = generatePropertyOperations(changeRequest);
@@ -245,9 +246,8 @@ public class SimplePlanner implements IPlanner {
}
}
- IMetadataRepositoryManager repoMgr = (IMetadataRepositoryManager) ServiceHelper.getService(DirectorActivator.context, IMetadataRepositoryManager.class.getName());
if (repositories == null)
- repositories = repoMgr.getKnownRepositories(IRepositoryManager.REPOSITORIES_ALL);
+ repositories = repoManager.getKnownRepositories(IRepositoryManager.REPOSITORIES_ALL);
SubMonitor sub = SubMonitor.convert(monitor, repositories.length * 200);
for (int i = 0; i < repositories.length; i++) {
@@ -255,7 +255,7 @@ public class SimplePlanner implements IPlanner {
if (sub.isCanceled())
throw new OperationCanceledException();
- IMetadataRepository repository = repoMgr.loadRepository(repositories[i], sub.newChild(100));
+ IMetadataRepository repository = repoManager.loadRepository(repositories[i], sub.newChild(100));
Collector matches = repository.query(new InstallableUnitQuery(null, VersionRange.emptyRange), new Collector(), sub.newChild(100));
for (Iterator it = matches.iterator(); it.hasNext();) {
IInstallableUnit iu = (IInstallableUnit) it.next();
@@ -279,6 +279,13 @@ public class SimplePlanner implements IPlanner {
return false;
}
+ public SimplePlanner(IProfileRegistry profileRegistry, IMetadataRepositoryManager repoManager) {
+ Assert.isNotNull(profileRegistry);
+ Assert.isNotNull(repoManager);
+ this.profileRegistry = profileRegistry;
+ this.repoManager = repoManager;
+ }
+
private boolean satisfyMetaRequirements(Map props) {
if (props == null)
return true;
@@ -402,7 +409,6 @@ public class SimplePlanner implements IPlanner {
try {
sub.setTaskName(Messages.Director_Task_installer_plan);
- IProfileRegistry profileRegistry = (IProfileRegistry) ServiceHelper.getService(DirectorActivator.context, IProfileRegistry.class.getName());
if (profileRegistry == null)
return new ProvisioningPlan(new Status(IStatus.ERROR, DirectorActivator.PI_DIRECTOR, Messages.Planner_no_profile_registry), initialRequest, null);
@@ -677,17 +683,16 @@ public class SimplePlanner implements IPlanner {
public IInstallableUnit[] updatesFor(IInstallableUnit toUpdate, ProvisioningContext context, IProgressMonitor monitor) {
Map resultsMap = new HashMap();
- IMetadataRepositoryManager repoMgr = (IMetadataRepositoryManager) ServiceHelper.getService(DirectorActivator.context, IMetadataRepositoryManager.class.getName());
URI[] repositories = context.getMetadataRepositories();
if (repositories == null)
- repositories = repoMgr.getKnownRepositories(IRepositoryManager.REPOSITORIES_ALL);
+ repositories = repoManager.getKnownRepositories(IRepositoryManager.REPOSITORIES_ALL);
SubMonitor sub = SubMonitor.convert(monitor, repositories.length * 200);
for (int i = 0; i < repositories.length; i++) {
try {
if (sub.isCanceled())
throw new OperationCanceledException();
- IMetadataRepository repository = repoMgr.loadRepository(repositories[i], sub.newChild(100));
+ IMetadataRepository repository = repoManager.loadRepository(repositories[i], sub.newChild(100));
Collector matches = repository.query(new UpdateQuery(toUpdate), new Collector(), sub.newChild(100));
for (Iterator it = matches.iterator(); it.hasNext();) {
IInstallableUnit iu = (IInstallableUnit) it.next();
diff --git a/bundles/org.eclipse.equinox.p2.director/src/org/eclipse/equinox/internal/provisional/p2/director/IDirector.java b/bundles/org.eclipse.equinox.p2.director/src/org/eclipse/equinox/internal/provisional/p2/director/IDirector.java
index 6201888b8..caea4fa8c 100644
--- a/bundles/org.eclipse.equinox.p2.director/src/org/eclipse/equinox/internal/provisional/p2/director/IDirector.java
+++ b/bundles/org.eclipse.equinox.p2.director/src/org/eclipse/equinox/internal/provisional/p2/director/IDirector.java
@@ -28,6 +28,11 @@ import org.eclipse.equinox.internal.provisional.p2.engine.ProvisioningContext;
public interface IDirector {
/**
+ * Service name constant for the director service.
+ */
+ public static final String SERVICE_NAME = IDirector.class.getName();
+
+ /**
* performs the change request with the given context.
*
* @param profileChangeRequest The change request
diff --git a/bundles/org.eclipse.equinox.p2.director/src/org/eclipse/equinox/internal/provisional/p2/director/IPlanner.java b/bundles/org.eclipse.equinox.p2.director/src/org/eclipse/equinox/internal/provisional/p2/director/IPlanner.java
index 6f5b1f605..801be18ea 100644
--- a/bundles/org.eclipse.equinox.p2.director/src/org/eclipse/equinox/internal/provisional/p2/director/IPlanner.java
+++ b/bundles/org.eclipse.equinox.p2.director/src/org/eclipse/equinox/internal/provisional/p2/director/IPlanner.java
@@ -23,6 +23,11 @@ import org.eclipse.equinox.internal.provisional.p2.metadata.IInstallableUnit;
* provisioning operands that the engine should perform.
*/
public interface IPlanner {
+ /**
+ * Service name constant for the planner service.
+ */
+ public static final String SERVICE_NAME = IPlanner.class.getName();
+
public ProvisioningPlan getProvisioningPlan(ProfileChangeRequest profileChangeRequest, ProvisioningContext context, IProgressMonitor monitor);
public IInstallableUnit[] updatesFor(IInstallableUnit toUpdate, ProvisioningContext context, IProgressMonitor monitor);
diff --git a/bundles/org.eclipse.equinox.p2.engine/META-INF/MANIFEST.MF b/bundles/org.eclipse.equinox.p2.engine/META-INF/MANIFEST.MF
index 271a82898..ac818ce52 100644
--- a/bundles/org.eclipse.equinox.p2.engine/META-INF/MANIFEST.MF
+++ b/bundles/org.eclipse.equinox.p2.engine/META-INF/MANIFEST.MF
@@ -62,4 +62,4 @@ Require-Bundle: org.eclipse.equinox.common,
org.eclipse.equinox.registry,
org.eclipse.equinox.p2.metadata.repository;bundle-version="1.0.100",
org.eclipse.core.jobs;bundle-version="[3.4.0,4.0.0)"
-Service-Component: OSGI-INF/profileRegistry.xml
+Service-Component: OSGI-INF/profileRegistry.xml, OSGI-INF/engine.xml
diff --git a/bundles/org.eclipse.equinox.p2.engine/OSGI-INF/engine.xml b/bundles/org.eclipse.equinox.p2.engine/OSGI-INF/engine.xml
new file mode 100644
index 000000000..2f6630ca2
--- /dev/null
+++ b/bundles/org.eclipse.equinox.p2.engine/OSGI-INF/engine.xml
@@ -0,0 +1,8 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<scr:component xmlns:scr="http://www.osgi.org/xmlns/scr/v1.1.0" name="org.eclipse.equinox.p2.engine">
+ <implementation class="org.eclipse.equinox.internal.p2.engine.EngineComponent"/>
+ <service>
+ <provide interface="org.eclipse.equinox.p2.core.spi.IAgentServiceFactory"/>
+ </service>
+ <property name="p2.agent.servicename" type="String" value="org.eclipse.equinox.internal.provisional.p2.engine.IEngine"/>
+</scr:component> \ No newline at end of file
diff --git a/bundles/org.eclipse.equinox.p2.engine/OSGI-INF/profileRegistry.xml b/bundles/org.eclipse.equinox.p2.engine/OSGI-INF/profileRegistry.xml
index 0e5ba9e67..4cb89bde7 100644
--- a/bundles/org.eclipse.equinox.p2.engine/OSGI-INF/profileRegistry.xml
+++ b/bundles/org.eclipse.equinox.p2.engine/OSGI-INF/profileRegistry.xml
@@ -1,4 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<scr:component xmlns:scr="http://www.osgi.org/xmlns/scr/v1.1.0" name="org.eclipse.equinox.p2.engine.registry">
<implementation class="org.eclipse.equinox.internal.p2.engine.ProfileRegistryComponent"/>
+ <service>
+ <provide interface="org.eclipse.equinox.p2.core.spi.IAgentServiceFactory"/>
+ </service>
+ <property name="p2.agent.servicename" type="String" value="org.eclipse.equinox.internal.provisional.p2.engine.IProfileRegistry"/>
</scr:component> \ No newline at end of file
diff --git a/bundles/org.eclipse.equinox.p2.engine/build.properties b/bundles/org.eclipse.equinox.p2.engine/build.properties
index ce260dd3f..2be866258 100644
--- a/bundles/org.eclipse.equinox.p2.engine/build.properties
+++ b/bundles/org.eclipse.equinox.p2.engine/build.properties
@@ -1,11 +1,11 @@
output.. = bin/
bin.includes = META-INF/,\
+ OSGI-INF/,\
.,\
plugin.xml,\
about.html,\
plugin.properties,\
.options,\
- OSGI-INF/profileRegistry.xml
src.includes = about.html,\
schema/
source.. = src/
diff --git a/bundles/org.eclipse.equinox.p2.engine/src/org/eclipse/equinox/internal/p2/engine/EngineComponent.java b/bundles/org.eclipse.equinox.p2.engine/src/org/eclipse/equinox/internal/p2/engine/EngineComponent.java
new file mode 100644
index 000000000..6a8de3a60
--- /dev/null
+++ b/bundles/org.eclipse.equinox.p2.engine/src/org/eclipse/equinox/internal/p2/engine/EngineComponent.java
@@ -0,0 +1,33 @@
+/*******************************************************************************
+ * Copyright (c) 2009 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
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.equinox.internal.p2.engine;
+
+import org.eclipse.equinox.internal.provisional.p2.core.eventbus.IProvisioningEventBus;
+import org.eclipse.equinox.internal.provisional.p2.engine.*;
+import org.eclipse.equinox.p2.core.IProvisioningAgent;
+import org.eclipse.equinox.p2.core.spi.IAgentServiceFactory;
+
+/**
+ * Component that provides a factory that can create and initialize
+ * {@link IEngine} instances.
+ */
+public class EngineComponent implements IAgentServiceFactory {
+
+ /*(non-Javadoc)
+ * @see org.eclipse.equinox.p2.core.spi.IAgentServiceFactory#createService(org.eclipse.equinox.p2.core.IProvisioningAgent)
+ */
+ public Object createService(IProvisioningAgent agent) {
+ IProvisioningEventBus bus = (IProvisioningEventBus) agent.getService(IProvisioningEventBus.SERVICE_NAME);
+ Engine result = new Engine(bus);
+ result.setProfileRegistry((IProfileRegistry) agent.getService(IProfileRegistry.SERVICE_NAME));
+ return result;
+ }
+}
diff --git a/bundles/org.eclipse.equinox.p2.engine/src/org/eclipse/equinox/internal/p2/engine/ProfileRegistryComponent.java b/bundles/org.eclipse.equinox.p2.engine/src/org/eclipse/equinox/internal/p2/engine/ProfileRegistryComponent.java
index 0b6e6f728..1e05b8a91 100644
--- a/bundles/org.eclipse.equinox.p2.engine/src/org/eclipse/equinox/internal/p2/engine/ProfileRegistryComponent.java
+++ b/bundles/org.eclipse.equinox.p2.engine/src/org/eclipse/equinox/internal/p2/engine/ProfileRegistryComponent.java
@@ -24,7 +24,7 @@ public class ProfileRegistryComponent implements IAgentServiceFactory {
public Object createService(IProvisioningAgent agent) {
AgentLocation location = (AgentLocation) agent.getService(AgentLocation.SERVICE_NAME);
SimpleProfileRegistry registry = new SimpleProfileRegistry(SimpleProfileRegistry.getDefaultRegistryDirectory(location));
- registry.setEventBus((IProvisioningEventBus) agent.getService(AgentLocation.SERVICE_NAME));
+ registry.setEventBus((IProvisioningEventBus) agent.getService(IProvisioningEventBus.SERVICE_NAME));
return registry;
}
}
diff --git a/bundles/org.eclipse.equinox.p2.engine/src/org/eclipse/equinox/internal/provisional/p2/engine/Engine.java b/bundles/org.eclipse.equinox.p2.engine/src/org/eclipse/equinox/internal/provisional/p2/engine/Engine.java
index dcec62074..0ff2d0f12 100644
--- a/bundles/org.eclipse.equinox.p2.engine/src/org/eclipse/equinox/internal/provisional/p2/engine/Engine.java
+++ b/bundles/org.eclipse.equinox.p2.engine/src/org/eclipse/equinox/internal/provisional/p2/engine/Engine.java
@@ -13,7 +13,6 @@ package org.eclipse.equinox.internal.provisional.p2.engine;
import java.io.File;
import org.eclipse.core.runtime.*;
import org.eclipse.equinox.internal.p2.core.helpers.LogHelper;
-import org.eclipse.equinox.internal.p2.core.helpers.ServiceHelper;
import org.eclipse.equinox.internal.p2.engine.*;
import org.eclipse.equinox.internal.provisional.p2.core.eventbus.IProvisioningEventBus;
@@ -23,14 +22,27 @@ import org.eclipse.equinox.internal.provisional.p2.core.eventbus.IProvisioningEv
public class Engine implements IEngine {
private static final String ENGINE = "engine"; //$NON-NLS-1$
- private final IProvisioningEventBus eventBus;
private ActionManager actionManager;
+ private final IProvisioningEventBus eventBus;
+
+ private SimpleProfileRegistry profileRegistry;
public Engine(IProvisioningEventBus eventBus) {
this.eventBus = eventBus;
this.actionManager = new ActionManager();
}
+ private void checkArguments(IProfile iprofile, PhaseSet phaseSet, Operand[] operands, ProvisioningContext context, IProgressMonitor monitor) {
+ if (iprofile == null)
+ throw new IllegalArgumentException(Messages.null_profile);
+
+ if (phaseSet == null)
+ throw new IllegalArgumentException(Messages.null_phaseset);
+
+ if (operands == null)
+ throw new IllegalArgumentException(Messages.null_operands);
+ }
+
public IStatus perform(IProfile iprofile, PhaseSet phaseSet, Operand[] operands, ProvisioningContext context, IProgressMonitor monitor) {
checkArguments(iprofile, phaseSet, operands, context, monitor);
@@ -40,8 +52,6 @@ public class Engine implements IEngine {
if (monitor == null)
monitor = new NullProgressMonitor();
- SimpleProfileRegistry profileRegistry = (SimpleProfileRegistry) ServiceHelper.getService(EngineActivator.getContext(), IProfileRegistry.class.getName());
-
Profile profile = profileRegistry.validate(iprofile);
profileRegistry.lockProfile(profile);
@@ -86,6 +96,17 @@ public class Engine implements IEngine {
}
}
+ public void setProfileRegistry(IProfileRegistry registry) {
+ //we can only work with our own registry implementation
+ if (registry instanceof SimpleProfileRegistry)
+ this.profileRegistry = (SimpleProfileRegistry) registry;
+ }
+
+ public void unsetProfileRegistry(IProfileRegistry registry) {
+ if (this.profileRegistry == registry)
+ this.profileRegistry = null;
+ }
+
public IStatus validate(IProfile iprofile, PhaseSet phaseSet, Operand[] operands, ProvisioningContext context, IProgressMonitor monitor) {
checkArguments(iprofile, phaseSet, operands, context, monitor);
@@ -97,15 +118,4 @@ public class Engine implements IEngine {
return phaseSet.validate(actionManager, iprofile, operands, context, monitor);
}
-
- private void checkArguments(IProfile iprofile, PhaseSet phaseSet, Operand[] operands, ProvisioningContext context, IProgressMonitor monitor) {
- if (iprofile == null)
- throw new IllegalArgumentException(Messages.null_profile);
-
- if (phaseSet == null)
- throw new IllegalArgumentException(Messages.null_phaseset);
-
- if (operands == null)
- throw new IllegalArgumentException(Messages.null_operands);
- }
}
diff --git a/bundles/org.eclipse.equinox.p2.engine/src/org/eclipse/equinox/internal/provisional/p2/engine/IProfileRegistry.java b/bundles/org.eclipse.equinox.p2.engine/src/org/eclipse/equinox/internal/provisional/p2/engine/IProfileRegistry.java
index a3cfdbc4f..2b7cace00 100644
--- a/bundles/org.eclipse.equinox.p2.engine/src/org/eclipse/equinox/internal/provisional/p2/engine/IProfileRegistry.java
+++ b/bundles/org.eclipse.equinox.p2.engine/src/org/eclipse/equinox/internal/provisional/p2/engine/IProfileRegistry.java
@@ -19,6 +19,10 @@ import org.eclipse.equinox.internal.provisional.p2.core.ProvisionException;
*/
public interface IProfileRegistry {
public static final String SELF = "_SELF_"; //$NON-NLS-1$
+ /**
+ * Service name constant for the profile registry service.
+ */
+ public static final String SERVICE_NAME = IProfileRegistry.class.getName();
/**
* Return the profile in the registry that has the given id. If it does not exist,
diff --git a/bundles/org.eclipse.equinox.p2.exemplarysetup/src/org/eclipse/equinox/internal/p2/exemplarysetup/Activator.java b/bundles/org.eclipse.equinox.p2.exemplarysetup/src/org/eclipse/equinox/internal/p2/exemplarysetup/Activator.java
index af1e4a9ce..f35adaf57 100644
--- a/bundles/org.eclipse.equinox.p2.exemplarysetup/src/org/eclipse/equinox/internal/p2/exemplarysetup/Activator.java
+++ b/bundles/org.eclipse.equinox.p2.exemplarysetup/src/org/eclipse/equinox/internal/p2/exemplarysetup/Activator.java
@@ -21,7 +21,7 @@ import org.eclipse.equinox.internal.provisional.p2.core.eventbus.IProvisioningEv
import org.eclipse.equinox.internal.provisional.p2.core.location.AgentLocation;
import org.eclipse.equinox.internal.provisional.p2.director.IDirector;
import org.eclipse.equinox.internal.provisional.p2.director.IPlanner;
-import org.eclipse.equinox.internal.provisional.p2.engine.IProfileRegistry;
+import org.eclipse.equinox.internal.provisional.p2.engine.*;
import org.eclipse.equinox.internal.provisional.p2.metadata.repository.IMetadataRepositoryManager;
import org.osgi.framework.*;
@@ -49,6 +49,8 @@ public class Activator implements BundleActivator {
private ServiceReference metadataRepositoryReference;
+ private MetadataRepositoryManager metadataRepositoryManager;
+
public void start(BundleContext aContext) throws Exception {
//Need to do the configuration of all the bits and pieces:
Activator.context = aContext;
@@ -91,8 +93,9 @@ public class Activator implements BundleActivator {
}
private void registerDirector() {
- director = new SimpleDirector();
- registrationDirector = context.registerService(IDirector.class.getName(), director, null);
+ IEngine engine = (IEngine) ServiceHelper.getService(context, IEngine.SERVICE_NAME);
+ director = new SimpleDirector(engine, planner);
+ registrationDirector = context.registerService(IDirector.SERVICE_NAME, director, null);
}
private void unregisterDirector() {
@@ -102,8 +105,8 @@ public class Activator implements BundleActivator {
}
private void registerPlanner() {
- planner = new SimplePlanner();
- registrationPlanner = context.registerService(IPlanner.class.getName(), planner, null);
+ planner = new SimplePlanner(profileRegistry, metadataRepositoryManager);
+ registrationPlanner = context.registerService(IPlanner.SERVICE_NAME, planner, null);
}
private void unregisterPlanner() {
@@ -116,6 +119,9 @@ public class Activator implements BundleActivator {
profileRegistry = new SimpleProfileRegistry(SimpleProfileRegistry.getDefaultRegistryDirectory(agentLocation));
profileRegistry.setEventBus(bus);
registrationProfileRegistry = context.registerService(IProfileRegistry.class.getName(), profileRegistry, null);
+ Engine engine = (Engine) ServiceHelper.getService(context, IEngine.SERVICE_NAME);
+ if (engine != null)
+ engine.setProfileRegistry(profileRegistry);
}
private void unregisterProfileRegistry() {
@@ -132,10 +138,12 @@ public class Activator implements BundleActivator {
//register a metadata repository manager if there isn't one already registered
metadataRepositoryReference = context.getServiceReference(IMetadataRepositoryManager.SERVICE_NAME);
if (metadataRepositoryReference == null) {
- final MetadataRepositoryManager manager = new MetadataRepositoryManager();
- manager.setEventBus(bus);
- registrationDefaultManager = context.registerService(IMetadataRepositoryManager.SERVICE_NAME, manager, null);
+ metadataRepositoryManager = new MetadataRepositoryManager();
+ metadataRepositoryManager.setEventBus(bus);
+ registrationDefaultManager = context.registerService(IMetadataRepositoryManager.SERVICE_NAME, metadataRepositoryManager, null);
metadataRepositoryReference = registrationDefaultManager.getReference();
+ } else {
+ metadataRepositoryManager = (MetadataRepositoryManager) context.getService(metadataRepositoryReference);
}
}
diff --git a/bundles/org.eclipse.equinox.p2.metadata.repository/.project b/bundles/org.eclipse.equinox.p2.metadata.repository/.project
index b1aa25ac4..920d1f26a 100644
--- a/bundles/org.eclipse.equinox.p2.metadata.repository/.project
+++ b/bundles/org.eclipse.equinox.p2.metadata.repository/.project
@@ -26,6 +26,11 @@
</arguments>
</buildCommand>
<buildCommand>
+ <name>org.eclipse.pde.ds.core.builder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
<name>org.eclipse.ui.externaltools.ExternalToolBuilder</name>
<triggers>full,incremental,</triggers>
<arguments>
diff --git a/bundles/org.eclipse.equinox.p2.metadata.repository/META-INF/MANIFEST.MF b/bundles/org.eclipse.equinox.p2.metadata.repository/META-INF/MANIFEST.MF
index 3e222749b..45b9a8093 100644
--- a/bundles/org.eclipse.equinox.p2.metadata.repository/META-INF/MANIFEST.MF
+++ b/bundles/org.eclipse.equinox.p2.metadata.repository/META-INF/MANIFEST.MF
@@ -50,6 +50,8 @@ Import-Package: javax.xml.parsers,
org.eclipse.equinox.internal.provisional.p2.metadata.query,
org.eclipse.equinox.internal.provisional.p2.repository,
org.eclipse.equinox.internal.provisional.spi.p2.repository,
+ org.eclipse.equinox.p2.core,
+ org.eclipse.equinox.p2.core.spi,
org.eclipse.osgi.util;version="1.1.0",
org.osgi.framework;version="1.3.0",
org.osgi.util.tracker;version="1.3.0",
@@ -61,3 +63,4 @@ Bundle-RequiredExecutionEnvironment: J2SE-1.4,
Require-Bundle: org.eclipse.equinox.common;bundle-version="[3.5.0,4.0.0)",
org.eclipse.equinox.registry,
org.eclipse.ecf.filetransfer;bundle-version="2.0.0"
+Service-Component: OSGI-INF/repositoryManager.xml
diff --git a/bundles/org.eclipse.equinox.p2.metadata.repository/OSGI-INF/repositoryManager.xml b/bundles/org.eclipse.equinox.p2.metadata.repository/OSGI-INF/repositoryManager.xml
new file mode 100644
index 000000000..11fb66f15
--- /dev/null
+++ b/bundles/org.eclipse.equinox.p2.metadata.repository/OSGI-INF/repositoryManager.xml
@@ -0,0 +1,8 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<scr:component xmlns:scr="http://www.osgi.org/xmlns/scr/v1.1.0" name="org.eclipse.equinox.p2.metadata.repository">
+ <implementation class="org.eclipse.equinox.internal.p2.metadata.repository.MetadataRepositoryComponent"/>
+ <service>
+ <provide interface="org.eclipse.equinox.p2.core.spi.IAgentServiceFactory"/>
+ </service>
+ <property name="p2.agent.servicename" type="String" value="org.eclipse.equinox.internal.provisional.p2.metadata.repository.IMetadataRepositoryManager"/>
+</scr:component> \ No newline at end of file
diff --git a/bundles/org.eclipse.equinox.p2.metadata.repository/build.properties b/bundles/org.eclipse.equinox.p2.metadata.repository/build.properties
index 7a8c0c188..3e90a6c41 100644
--- a/bundles/org.eclipse.equinox.p2.metadata.repository/build.properties
+++ b/bundles/org.eclipse.equinox.p2.metadata.repository/build.properties
@@ -15,7 +15,8 @@ bin.includes = META-INF/,\
about.html,\
plugin.xml,\
plugin.properties,\
- ant_tasks/metadataRepository-ant.jar
+ ant_tasks/metadataRepository-ant.jar,\
+ OSGI-INF/
src.includes = about.html,\
schema/
jars.extra.classpath = platform:/plugin/org.apache.ant/lib/ant.jar
diff --git a/bundles/org.eclipse.equinox.p2.metadata.repository/src/org/eclipse/equinox/internal/p2/metadata/repository/Activator.java b/bundles/org.eclipse.equinox.p2.metadata.repository/src/org/eclipse/equinox/internal/p2/metadata/repository/Activator.java
index f8fa8c1db..0706b2556 100644
--- a/bundles/org.eclipse.equinox.p2.metadata.repository/src/org/eclipse/equinox/internal/p2/metadata/repository/Activator.java
+++ b/bundles/org.eclipse.equinox.p2.metadata.repository/src/org/eclipse/equinox/internal/p2/metadata/repository/Activator.java
@@ -11,7 +11,9 @@
*******************************************************************************/
package org.eclipse.equinox.internal.p2.metadata.repository;
+import org.eclipse.equinox.internal.p2.core.helpers.ServiceHelper;
import org.eclipse.equinox.internal.provisional.p2.core.eventbus.IProvisioningEventBus;
+import org.eclipse.equinox.internal.provisional.p2.core.location.AgentLocation;
import org.eclipse.equinox.internal.provisional.p2.metadata.repository.IMetadataRepositoryManager;
import org.osgi.framework.*;
import org.osgi.util.tracker.ServiceTracker;
@@ -37,23 +39,21 @@ public class Activator implements BundleActivator, ServiceTrackerCustomizer {
}
public void start(BundleContext context) throws Exception {
+ //TODO eventually there should be no singleton repository manager registered
Activator.bundleContext = context;
- cacheManager = new CacheManager();
-
- cacheManager.registerRepoEventListener();
+ cacheManager = new CacheManager((AgentLocation) ServiceHelper.getService(context, AgentLocation.SERVICE_NAME));
repositoryManager = new MetadataRepositoryManager();
repositoryManagerRegistration = context.registerService(IMetadataRepositoryManager.class.getName(), repositoryManager, null);
- // need to track event bus coming and going to make sure cache gets cleaned on
- // repository removals
+ // need to track event bus coming and going to make sure cache gets cleaned on repository removals
busTracker = new ServiceTracker(context, IProvisioningEventBus.SERVICE_NAME, this);
busTracker.open();
-
}
public void stop(BundleContext context) throws Exception {
+ IProvisioningEventBus bus = (IProvisioningEventBus) busTracker.getService();
if (cacheManager != null) {
- cacheManager.unregisterRepoEventListener();
+ cacheManager.unsetEventBus(bus);
cacheManager = null;
}
Activator.bundleContext = null;
@@ -71,7 +71,7 @@ public class Activator implements BundleActivator, ServiceTrackerCustomizer {
if (repositoryManager != null)
repositoryManager.setEventBus(bus);
if (cacheManager != null)
- cacheManager.registerRepoEventListener();
+ cacheManager.setEventBus(bus);
return bus;
}
@@ -81,7 +81,10 @@ public class Activator implements BundleActivator, ServiceTrackerCustomizer {
}
public void removedService(ServiceReference reference, Object service) {
+ final IProvisioningEventBus bus = (IProvisioningEventBus) service;
if (repositoryManager != null)
- repositoryManager.unsetEventBus((IProvisioningEventBus) service);
+ repositoryManager.unsetEventBus(bus);
+ if (cacheManager != null)
+ cacheManager.unsetEventBus(bus);
}
}
diff --git a/bundles/org.eclipse.equinox.p2.metadata.repository/src/org/eclipse/equinox/internal/p2/metadata/repository/CacheManager.java b/bundles/org.eclipse.equinox.p2.metadata.repository/src/org/eclipse/equinox/internal/p2/metadata/repository/CacheManager.java
index 1d4f074ef..24397e5e4 100644
--- a/bundles/org.eclipse.equinox.p2.metadata.repository/src/org/eclipse/equinox/internal/p2/metadata/repository/CacheManager.java
+++ b/bundles/org.eclipse.equinox.p2.metadata.repository/src/org/eclipse/equinox/internal/p2/metadata/repository/CacheManager.java
@@ -17,7 +17,8 @@ import java.net.URL;
import java.util.*;
import org.eclipse.core.runtime.*;
import org.eclipse.ecf.filetransfer.UserCancelledException;
-import org.eclipse.equinox.internal.p2.core.helpers.*;
+import org.eclipse.equinox.internal.p2.core.helpers.LogHelper;
+import org.eclipse.equinox.internal.p2.core.helpers.URLUtil;
import org.eclipse.equinox.internal.p2.repository.*;
import org.eclipse.equinox.internal.p2.repository.Activator;
import org.eclipse.equinox.internal.provisional.p2.core.ProvisionException;
@@ -36,6 +37,8 @@ import org.eclipse.osgi.util.NLS;
* was created for the repository.
*/
public class CacheManager {
+ private final AgentLocation agentLocation;
+
/**
* IStateful implementation of BufferedOutputStream. Class is used to get the status from
* a download operation.
@@ -58,6 +61,10 @@ public class CacheManager {
}
+ public CacheManager(AgentLocation agentLocation) {
+ this.agentLocation = agentLocation;
+ }
+
private static SynchronousProvisioningListener busListener;
private static final String DOWNLOADING = "downloading"; //$NON-NLS-1$
private static final String JAR_EXTENSION = ".jar"; //$NON-NLS-1$
@@ -234,7 +241,6 @@ public class CacheManager {
* Returns the file corresponding to the data area to be used by the cache manager.
*/
private File getCacheDirectory() {
- AgentLocation agentLocation = (AgentLocation) ServiceHelper.getService(Activator.getContext(), AgentLocation.class.getName());
URL dataArea = agentLocation.getDataArea(Activator.ID + "/cache/"); //$NON-NLS-1$
return URLUtil.toFile(dataArea);
}
@@ -327,12 +333,7 @@ public class CacheManager {
* Adds a {@link SynchronousProvisioningListener} to the event bus for
* deleting cache files when the corresponding repository is deleted.
*/
- public void registerRepoEventListener() {
- IProvisioningEventBus eventBus = (IProvisioningEventBus) ServiceHelper.getService(Activator.getContext(), IProvisioningEventBus.SERVICE_NAME);
- if (eventBus == null) {
- LogHelper.log(new Status(IStatus.ERROR, Activator.ID, "ProvisioningEventBus could not be obtained. Metadata caches may not be cleaned up properly.")); //$NON-NLS-1$
- return;
- }
+ public void registerRepoEventListener(IProvisioningEventBus eventBus) {
if (busListener == null) {
busListener = new SynchronousProvisioningListener() {
public void notify(EventObject o) {
@@ -359,16 +360,21 @@ public class CacheManager {
return false;
}
+ public void setEventBus(IProvisioningEventBus newBus) {
+ registerRepoEventListener(newBus);
+ }
+
+ public void unsetEventBus(IProvisioningEventBus oldBus) {
+ unregisterRepoEventListener(oldBus);
+ }
+
/**
* Removes the {@link SynchronousProvisioningListener} that cleans up the
* cache file from the event bus.
*/
- public void unregisterRepoEventListener() {
- IProvisioningEventBus eventBus = (IProvisioningEventBus) ServiceHelper.getService(Activator.getContext(), IProvisioningEventBus.SERVICE_NAME);
- if (eventBus != null && busListener != null) {
- eventBus.removeListener(busListener);
- busListener = null;
- }
+ public void unregisterRepoEventListener(IProvisioningEventBus bus) {
+ if (bus != null && busListener != null)
+ bus.removeListener(busListener);
}
private void updateCache(File cacheFile, URI remoteFile, long lastModifiedRemote, SubMonitor submonitor) throws FileNotFoundException, IOException, ProvisionException {
diff --git a/bundles/org.eclipse.equinox.p2.metadata.repository/src/org/eclipse/equinox/internal/p2/metadata/repository/MetadataRepositoryComponent.java b/bundles/org.eclipse.equinox.p2.metadata.repository/src/org/eclipse/equinox/internal/p2/metadata/repository/MetadataRepositoryComponent.java
new file mode 100644
index 000000000..9474158c8
--- /dev/null
+++ b/bundles/org.eclipse.equinox.p2.metadata.repository/src/org/eclipse/equinox/internal/p2/metadata/repository/MetadataRepositoryComponent.java
@@ -0,0 +1,33 @@
+/*******************************************************************************
+ * Copyright (c) 2009 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
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.equinox.internal.p2.metadata.repository;
+
+import org.eclipse.equinox.internal.provisional.p2.core.eventbus.IProvisioningEventBus;
+import org.eclipse.equinox.internal.provisional.p2.core.location.AgentLocation;
+import org.eclipse.equinox.internal.provisional.p2.metadata.repository.IMetadataRepositoryManager;
+import org.eclipse.equinox.p2.core.IProvisioningAgent;
+import org.eclipse.equinox.p2.core.spi.IAgentServiceFactory;
+
+/**
+ * Service factory for creating {@link IMetadataRepositoryManager} instances.
+ */
+public class MetadataRepositoryComponent implements IAgentServiceFactory {
+
+ public Object createService(IProvisioningAgent agent) {
+ MetadataRepositoryManager manager = new MetadataRepositoryManager();
+ final IProvisioningEventBus eventBus = (IProvisioningEventBus) agent.getService(IProvisioningEventBus.SERVICE_NAME);
+ manager.setEventBus(eventBus);
+ CacheManager cache = new CacheManager((AgentLocation) agent.getService(AgentLocation.SERVICE_NAME));
+ cache.setEventBus(eventBus);
+ return manager;
+ }
+
+}
diff --git a/bundles/org.eclipse.equinox.p2.repository/src/org/eclipse/equinox/internal/p2/repository/CacheManager.java b/bundles/org.eclipse.equinox.p2.repository/src/org/eclipse/equinox/internal/p2/repository/CacheManager.java
index 1d4f074ef..24397e5e4 100644
--- a/bundles/org.eclipse.equinox.p2.repository/src/org/eclipse/equinox/internal/p2/repository/CacheManager.java
+++ b/bundles/org.eclipse.equinox.p2.repository/src/org/eclipse/equinox/internal/p2/repository/CacheManager.java
@@ -17,7 +17,8 @@ import java.net.URL;
import java.util.*;
import org.eclipse.core.runtime.*;
import org.eclipse.ecf.filetransfer.UserCancelledException;
-import org.eclipse.equinox.internal.p2.core.helpers.*;
+import org.eclipse.equinox.internal.p2.core.helpers.LogHelper;
+import org.eclipse.equinox.internal.p2.core.helpers.URLUtil;
import org.eclipse.equinox.internal.p2.repository.*;
import org.eclipse.equinox.internal.p2.repository.Activator;
import org.eclipse.equinox.internal.provisional.p2.core.ProvisionException;
@@ -36,6 +37,8 @@ import org.eclipse.osgi.util.NLS;
* was created for the repository.
*/
public class CacheManager {
+ private final AgentLocation agentLocation;
+
/**
* IStateful implementation of BufferedOutputStream. Class is used to get the status from
* a download operation.
@@ -58,6 +61,10 @@ public class CacheManager {
}
+ public CacheManager(AgentLocation agentLocation) {
+ this.agentLocation = agentLocation;
+ }
+
private static SynchronousProvisioningListener busListener;
private static final String DOWNLOADING = "downloading"; //$NON-NLS-1$
private static final String JAR_EXTENSION = ".jar"; //$NON-NLS-1$
@@ -234,7 +241,6 @@ public class CacheManager {
* Returns the file corresponding to the data area to be used by the cache manager.
*/
private File getCacheDirectory() {
- AgentLocation agentLocation = (AgentLocation) ServiceHelper.getService(Activator.getContext(), AgentLocation.class.getName());
URL dataArea = agentLocation.getDataArea(Activator.ID + "/cache/"); //$NON-NLS-1$
return URLUtil.toFile(dataArea);
}
@@ -327,12 +333,7 @@ public class CacheManager {
* Adds a {@link SynchronousProvisioningListener} to the event bus for
* deleting cache files when the corresponding repository is deleted.
*/
- public void registerRepoEventListener() {
- IProvisioningEventBus eventBus = (IProvisioningEventBus) ServiceHelper.getService(Activator.getContext(), IProvisioningEventBus.SERVICE_NAME);
- if (eventBus == null) {
- LogHelper.log(new Status(IStatus.ERROR, Activator.ID, "ProvisioningEventBus could not be obtained. Metadata caches may not be cleaned up properly.")); //$NON-NLS-1$
- return;
- }
+ public void registerRepoEventListener(IProvisioningEventBus eventBus) {
if (busListener == null) {
busListener = new SynchronousProvisioningListener() {
public void notify(EventObject o) {
@@ -359,16 +360,21 @@ public class CacheManager {
return false;
}
+ public void setEventBus(IProvisioningEventBus newBus) {
+ registerRepoEventListener(newBus);
+ }
+
+ public void unsetEventBus(IProvisioningEventBus oldBus) {
+ unregisterRepoEventListener(oldBus);
+ }
+
/**
* Removes the {@link SynchronousProvisioningListener} that cleans up the
* cache file from the event bus.
*/
- public void unregisterRepoEventListener() {
- IProvisioningEventBus eventBus = (IProvisioningEventBus) ServiceHelper.getService(Activator.getContext(), IProvisioningEventBus.SERVICE_NAME);
- if (eventBus != null && busListener != null) {
- eventBus.removeListener(busListener);
- busListener = null;
- }
+ public void unregisterRepoEventListener(IProvisioningEventBus bus) {
+ if (bus != null && busListener != null)
+ bus.removeListener(busListener);
}
private void updateCache(File cacheFile, URI remoteFile, long lastModifiedRemote, SubMonitor submonitor) throws FileNotFoundException, IOException, ProvisionException {

Back to the top