Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDJ Houghton2008-04-23 17:07:42 -0400
committerDJ Houghton2008-04-23 17:07:42 -0400
commit75e8e817c9beb83b863f3acb0ffbcfc41a485136 (patch)
treefe640e86dba37dcf30f4a6da9b5fa82e0c5514b4 /bundles
parent967f1ba280215e57561c375d22dd77be27d5b409 (diff)
downloadrt.equinox.p2-75e8e817c9beb83b863f3acb0ffbcfc41a485136.tar.gz
rt.equinox.p2-75e8e817c9beb83b863f3acb0ffbcfc41a485136.tar.xz
rt.equinox.p2-75e8e817c9beb83b863f3acb0ffbcfc41a485136.zip
Bug 228272 - p2 auto-discovers already installed features on startup
Diffstat (limited to 'bundles')
-rw-r--r--bundles/org.eclipse.equinox.p2.reconciler.dropins/src/org/eclipse/equinox/internal/p2/reconciler/dropins/Activator.java6
-rw-r--r--bundles/org.eclipse.equinox.p2.reconciler.dropins/src/org/eclipse/equinox/internal/p2/reconciler/dropins/PlatformXmlListener.java10
-rw-r--r--bundles/org.eclipse.equinox.p2.reconciler.dropins/src/org/eclipse/equinox/internal/p2/reconciler/dropins/ProfileSynchronizer.java27
-rw-r--r--bundles/org.eclipse.equinox.p2.reconciler/src/org/eclipse/equinox/internal/p2/reconciler/dropins/Activator.java6
-rw-r--r--bundles/org.eclipse.equinox.p2.reconciler/src/org/eclipse/equinox/internal/p2/reconciler/dropins/PlatformXmlListener.java10
-rw-r--r--bundles/org.eclipse.equinox.p2.reconciler/src/org/eclipse/equinox/internal/p2/reconciler/dropins/ProfileSynchronizer.java27
6 files changed, 48 insertions, 38 deletions
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 ac629f3bc..c8edc4b3a 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
@@ -121,7 +121,7 @@ public class Activator implements BundleActivator {
// keep an eye on the platform.xml
watchConfiguration();
- synchronize(new ArrayList(0), null);
+ synchronize(null);
// we should probably be holding on to these repos by URL
// see Bug 223422
@@ -156,12 +156,12 @@ public class Activator implements BundleActivator {
/*
* Synchronize the profile.
*/
- public static synchronized void synchronize(Collection extraRepositories, IProgressMonitor monitor) {
+ public static synchronized void synchronize(IProgressMonitor monitor) {
IProfile profile = getCurrentProfile(bundleContext);
if (profile == null)
return;
// create the profile synchronizer on all available repositories
- Set repositories = new HashSet(extraRepositories);
+ Set repositories = new HashSet();
if (dropinRepositories != null)
repositories.addAll(dropinRepositories);
diff --git a/bundles/org.eclipse.equinox.p2.reconciler.dropins/src/org/eclipse/equinox/internal/p2/reconciler/dropins/PlatformXmlListener.java b/bundles/org.eclipse.equinox.p2.reconciler.dropins/src/org/eclipse/equinox/internal/p2/reconciler/dropins/PlatformXmlListener.java
index cb5e41c19..de869d5c7 100644
--- a/bundles/org.eclipse.equinox.p2.reconciler.dropins/src/org/eclipse/equinox/internal/p2/reconciler/dropins/PlatformXmlListener.java
+++ b/bundles/org.eclipse.equinox.p2.reconciler.dropins/src/org/eclipse/equinox/internal/p2/reconciler/dropins/PlatformXmlListener.java
@@ -142,10 +142,6 @@ public class PlatformXmlListener extends DirectoryChangeListener {
for (Iterator iter = sites.iterator(); iter.hasNext();) {
Site site = (Site) iter.next();
String siteURL = site.getUrl();
- // TODO: this is our way of skipping the base.
- // we will need to change this to platform:/base/ at some point
- if ("file:.".equals(siteURL) || "file:".equals(siteURL)) //$NON-NLS-1$//$NON-NLS-2$
- continue;
if (siteURL.startsWith("file:") && siteURL.endsWith("/eclipse/")) //$NON-NLS-1$//$NON-NLS-2$
siteURL = siteURL.substring(0, siteURL.length() - 8);
IMetadataRepository match = getMatchingRepo(Activator.getConfigurationRepositories(), siteURL);
@@ -165,9 +161,7 @@ public class PlatformXmlListener extends DirectoryChangeListener {
}
}
// if we didn't add any new repos then there is no work to do
- if (newRepos.isEmpty())
- return;
- configRepositories = newRepos;
- Activator.synchronize(newRepos, null);
+ if (!newRepos.isEmpty())
+ configRepositories = newRepos;
}
}
diff --git a/bundles/org.eclipse.equinox.p2.reconciler.dropins/src/org/eclipse/equinox/internal/p2/reconciler/dropins/ProfileSynchronizer.java b/bundles/org.eclipse.equinox.p2.reconciler.dropins/src/org/eclipse/equinox/internal/p2/reconciler/dropins/ProfileSynchronizer.java
index ff99ce813..8c249c425 100644
--- a/bundles/org.eclipse.equinox.p2.reconciler.dropins/src/org/eclipse/equinox/internal/p2/reconciler/dropins/ProfileSynchronizer.java
+++ b/bundles/org.eclipse.equinox.p2.reconciler.dropins/src/org/eclipse/equinox/internal/p2/reconciler/dropins/ProfileSynchronizer.java
@@ -27,6 +27,7 @@ import org.eclipse.equinox.internal.provisional.p2.metadata.IInstallableUnit;
import org.eclipse.equinox.internal.provisional.p2.metadata.query.InstallableUnitQuery;
import org.eclipse.equinox.internal.provisional.p2.metadata.repository.IMetadataRepository;
import org.eclipse.equinox.internal.provisional.p2.query.Collector;
+import org.eclipse.equinox.internal.provisional.p2.query.Query;
import org.osgi.framework.BundleContext;
import org.osgi.framework.ServiceReference;
@@ -261,21 +262,31 @@ public class ProfileSynchronizer {
// get all IUs from all our repos (toAdd)
Collector allIUs = getAllIUsFromRepos();
for (Iterator iter = allIUs.iterator(); iter.hasNext();) {
- IInstallableUnit iu = (IInstallableUnit) iter.next();
- if (Boolean.valueOf(iu.getProperty(IInstallableUnit.PROP_TYPE_GROUP)).booleanValue())
- request.setInstallableUnitProfileProperty(iu, IInstallableUnit.PROP_PROFILE_ROOT_IU, Boolean.TRUE.toString());
- // mark all IUs with special property
- request.setInstallableUnitProfileProperty(iu, PROP_FROM_DROPINS, Boolean.TRUE.toString());
- request.setInstallableUnitInclusionRules(iu, PlannerHelper.createOptionalInclusionRule(iu));
- toAdd.add(iu);
+ final IInstallableUnit iu = (IInstallableUnit) iter.next();
+ // if the IU is already installed in the profile then skip it
+ Query query = new Query() {
+ public boolean isMatch(Object candidate) {
+ return iu.equals(candidate);
+ }
+ };
+ Collector collector = profile.query(query, new Collector(), null);
+ if (collector.size() == 0) {
+ if (Boolean.valueOf(iu.getProperty(IInstallableUnit.PROP_TYPE_GROUP)).booleanValue())
+ request.setInstallableUnitProfileProperty(iu, IInstallableUnit.PROP_PROFILE_ROOT_IU, Boolean.TRUE.toString());
+ // mark all IUs with special property
+ request.setInstallableUnitProfileProperty(iu, PROP_FROM_DROPINS, Boolean.TRUE.toString());
+ request.setInstallableUnitInclusionRules(iu, PlannerHelper.createOptionalInclusionRule(iu));
+ toAdd.add(iu);
+ }
}
// get all IUs from profile with marked property (existing)
Collector profileIUs = profile.query(new IUProfilePropertyQuery(profile, PROP_FROM_DROPINS, Boolean.toString(true)), new Collector(), null);
+ Collection all = allIUs.toCollection();
for (Iterator iter = profileIUs.iterator(); iter.hasNext();) {
IInstallableUnit iu = (IInstallableUnit) iter.next();
// remove the IUs that are in the intersection between the 2 sets
- if (toAdd.contains(iu))
+ if (all.contains(iu))
toAdd.remove(iu);
else
toRemove.add(iu);
diff --git a/bundles/org.eclipse.equinox.p2.reconciler/src/org/eclipse/equinox/internal/p2/reconciler/dropins/Activator.java b/bundles/org.eclipse.equinox.p2.reconciler/src/org/eclipse/equinox/internal/p2/reconciler/dropins/Activator.java
index ac629f3bc..c8edc4b3a 100644
--- a/bundles/org.eclipse.equinox.p2.reconciler/src/org/eclipse/equinox/internal/p2/reconciler/dropins/Activator.java
+++ b/bundles/org.eclipse.equinox.p2.reconciler/src/org/eclipse/equinox/internal/p2/reconciler/dropins/Activator.java
@@ -121,7 +121,7 @@ public class Activator implements BundleActivator {
// keep an eye on the platform.xml
watchConfiguration();
- synchronize(new ArrayList(0), null);
+ synchronize(null);
// we should probably be holding on to these repos by URL
// see Bug 223422
@@ -156,12 +156,12 @@ public class Activator implements BundleActivator {
/*
* Synchronize the profile.
*/
- public static synchronized void synchronize(Collection extraRepositories, IProgressMonitor monitor) {
+ public static synchronized void synchronize(IProgressMonitor monitor) {
IProfile profile = getCurrentProfile(bundleContext);
if (profile == null)
return;
// create the profile synchronizer on all available repositories
- Set repositories = new HashSet(extraRepositories);
+ Set repositories = new HashSet();
if (dropinRepositories != null)
repositories.addAll(dropinRepositories);
diff --git a/bundles/org.eclipse.equinox.p2.reconciler/src/org/eclipse/equinox/internal/p2/reconciler/dropins/PlatformXmlListener.java b/bundles/org.eclipse.equinox.p2.reconciler/src/org/eclipse/equinox/internal/p2/reconciler/dropins/PlatformXmlListener.java
index cb5e41c19..de869d5c7 100644
--- a/bundles/org.eclipse.equinox.p2.reconciler/src/org/eclipse/equinox/internal/p2/reconciler/dropins/PlatformXmlListener.java
+++ b/bundles/org.eclipse.equinox.p2.reconciler/src/org/eclipse/equinox/internal/p2/reconciler/dropins/PlatformXmlListener.java
@@ -142,10 +142,6 @@ public class PlatformXmlListener extends DirectoryChangeListener {
for (Iterator iter = sites.iterator(); iter.hasNext();) {
Site site = (Site) iter.next();
String siteURL = site.getUrl();
- // TODO: this is our way of skipping the base.
- // we will need to change this to platform:/base/ at some point
- if ("file:.".equals(siteURL) || "file:".equals(siteURL)) //$NON-NLS-1$//$NON-NLS-2$
- continue;
if (siteURL.startsWith("file:") && siteURL.endsWith("/eclipse/")) //$NON-NLS-1$//$NON-NLS-2$
siteURL = siteURL.substring(0, siteURL.length() - 8);
IMetadataRepository match = getMatchingRepo(Activator.getConfigurationRepositories(), siteURL);
@@ -165,9 +161,7 @@ public class PlatformXmlListener extends DirectoryChangeListener {
}
}
// if we didn't add any new repos then there is no work to do
- if (newRepos.isEmpty())
- return;
- configRepositories = newRepos;
- Activator.synchronize(newRepos, null);
+ if (!newRepos.isEmpty())
+ configRepositories = newRepos;
}
}
diff --git a/bundles/org.eclipse.equinox.p2.reconciler/src/org/eclipse/equinox/internal/p2/reconciler/dropins/ProfileSynchronizer.java b/bundles/org.eclipse.equinox.p2.reconciler/src/org/eclipse/equinox/internal/p2/reconciler/dropins/ProfileSynchronizer.java
index ff99ce813..8c249c425 100644
--- a/bundles/org.eclipse.equinox.p2.reconciler/src/org/eclipse/equinox/internal/p2/reconciler/dropins/ProfileSynchronizer.java
+++ b/bundles/org.eclipse.equinox.p2.reconciler/src/org/eclipse/equinox/internal/p2/reconciler/dropins/ProfileSynchronizer.java
@@ -27,6 +27,7 @@ import org.eclipse.equinox.internal.provisional.p2.metadata.IInstallableUnit;
import org.eclipse.equinox.internal.provisional.p2.metadata.query.InstallableUnitQuery;
import org.eclipse.equinox.internal.provisional.p2.metadata.repository.IMetadataRepository;
import org.eclipse.equinox.internal.provisional.p2.query.Collector;
+import org.eclipse.equinox.internal.provisional.p2.query.Query;
import org.osgi.framework.BundleContext;
import org.osgi.framework.ServiceReference;
@@ -261,21 +262,31 @@ public class ProfileSynchronizer {
// get all IUs from all our repos (toAdd)
Collector allIUs = getAllIUsFromRepos();
for (Iterator iter = allIUs.iterator(); iter.hasNext();) {
- IInstallableUnit iu = (IInstallableUnit) iter.next();
- if (Boolean.valueOf(iu.getProperty(IInstallableUnit.PROP_TYPE_GROUP)).booleanValue())
- request.setInstallableUnitProfileProperty(iu, IInstallableUnit.PROP_PROFILE_ROOT_IU, Boolean.TRUE.toString());
- // mark all IUs with special property
- request.setInstallableUnitProfileProperty(iu, PROP_FROM_DROPINS, Boolean.TRUE.toString());
- request.setInstallableUnitInclusionRules(iu, PlannerHelper.createOptionalInclusionRule(iu));
- toAdd.add(iu);
+ final IInstallableUnit iu = (IInstallableUnit) iter.next();
+ // if the IU is already installed in the profile then skip it
+ Query query = new Query() {
+ public boolean isMatch(Object candidate) {
+ return iu.equals(candidate);
+ }
+ };
+ Collector collector = profile.query(query, new Collector(), null);
+ if (collector.size() == 0) {
+ if (Boolean.valueOf(iu.getProperty(IInstallableUnit.PROP_TYPE_GROUP)).booleanValue())
+ request.setInstallableUnitProfileProperty(iu, IInstallableUnit.PROP_PROFILE_ROOT_IU, Boolean.TRUE.toString());
+ // mark all IUs with special property
+ request.setInstallableUnitProfileProperty(iu, PROP_FROM_DROPINS, Boolean.TRUE.toString());
+ request.setInstallableUnitInclusionRules(iu, PlannerHelper.createOptionalInclusionRule(iu));
+ toAdd.add(iu);
+ }
}
// get all IUs from profile with marked property (existing)
Collector profileIUs = profile.query(new IUProfilePropertyQuery(profile, PROP_FROM_DROPINS, Boolean.toString(true)), new Collector(), null);
+ Collection all = allIUs.toCollection();
for (Iterator iter = profileIUs.iterator(); iter.hasNext();) {
IInstallableUnit iu = (IInstallableUnit) iter.next();
// remove the IUs that are in the intersection between the 2 sets
- if (toAdd.contains(iu))
+ if (all.contains(iu))
toAdd.remove(iu);
else
toRemove.add(iu);

Back to the top