Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJohn Arthorne2010-01-07 18:59:13 +0000
committerJohn Arthorne2010-01-07 18:59:13 +0000
commit1196cf3aac160966624b1c629fb4620501e2c7ca (patch)
tree39ea4416038c7ec62f4b3e2e1f6058f5feeb60e1
parent4453a745b731e60f2bdb617732ff76607d64039e (diff)
downloadrt.equinox.p2-1196cf3aac160966624b1c629fb4620501e2c7ca.tar.gz
rt.equinox.p2-1196cf3aac160966624b1c629fb4620501e2c7ca.tar.xz
rt.equinox.p2-1196cf3aac160966624b1c629fb4620501e2c7ca.zip
Bug 296936 - [touchpoint] Performance issues when installing features
-rw-r--r--bundles/org.eclipse.equinox.p2.reconciler.dropins/src/org/eclipse/equinox/internal/p2/reconciler/dropins/PlatformXmlListener.java2
-rw-r--r--bundles/org.eclipse.equinox.p2.touchpoint.eclipse/src/org/eclipse/equinox/internal/p2/update/Configuration.java4
-rw-r--r--bundles/org.eclipse.equinox.p2.touchpoint.eclipse/src/org/eclipse/equinox/internal/p2/update/ConfigurationIO.java74
3 files changed, 77 insertions, 3 deletions
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 de86b9c40..973a65063 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
@@ -129,7 +129,7 @@ public class PlatformXmlListener extends DirectoryChangeListener {
if (changed) {
lastModified = root.lastModified();
try {
- Configuration configuration = ConfigurationParser.parse(root, Activator.getOSGiInstallArea());
+ Configuration configuration = Configuration.load(root, Activator.getOSGiInstallArea());
synchronizeConfiguration(configuration);
} catch (ProvisionException e) {
LogHelper.log(new Status(IStatus.ERROR, Activator.ID, Messages.errorProcessingConfg, e));
diff --git a/bundles/org.eclipse.equinox.p2.touchpoint.eclipse/src/org/eclipse/equinox/internal/p2/update/Configuration.java b/bundles/org.eclipse.equinox.p2.touchpoint.eclipse/src/org/eclipse/equinox/internal/p2/update/Configuration.java
index c3285ce7a..26de44c16 100644
--- a/bundles/org.eclipse.equinox.p2.touchpoint.eclipse/src/org/eclipse/equinox/internal/p2/update/Configuration.java
+++ b/bundles/org.eclipse.equinox.p2.touchpoint.eclipse/src/org/eclipse/equinox/internal/p2/update/Configuration.java
@@ -35,7 +35,7 @@ public class Configuration {
String shared_ur;
public static Configuration load(File location, URL osgiInstallArea) throws ProvisionException {
- return ConfigurationParser.parse(location, osgiInstallArea);
+ return ConfigurationIO.read(location, osgiInstallArea);
}
public Configuration() {
@@ -43,7 +43,7 @@ public class Configuration {
}
public void save(File location, URL osgiInstallArea) throws ProvisionException {
- ConfigurationWriter.save(this, location, osgiInstallArea);
+ ConfigurationIO.write(location, this, osgiInstallArea);
}
public String getSharedUR() {
diff --git a/bundles/org.eclipse.equinox.p2.touchpoint.eclipse/src/org/eclipse/equinox/internal/p2/update/ConfigurationIO.java b/bundles/org.eclipse.equinox.p2.touchpoint.eclipse/src/org/eclipse/equinox/internal/p2/update/ConfigurationIO.java
new file mode 100644
index 000000000..c87720ce1
--- /dev/null
+++ b/bundles/org.eclipse.equinox.p2.touchpoint.eclipse/src/org/eclipse/equinox/internal/p2/update/ConfigurationIO.java
@@ -0,0 +1,74 @@
+/*******************************************************************************
+ * 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.update;
+
+import java.io.File;
+import java.net.URL;
+import org.eclipse.equinox.internal.provisional.p2.core.ProvisionException;
+
+/*
+ * Class which controls the reading and writing of Configuration (platform.xml) objects.
+ * We keep a local cached copy to avoid multiple reads. When we install new features we
+ * seem to only write out the platform.xml in the "commit" phase so we don't need to
+ * batch the writes.
+ */
+public class ConfigurationIO {
+ private static CacheEntry cache = null;
+
+ // class used to represent cache values
+ static class CacheEntry {
+ Configuration config;
+ URL osgiInstallArea;
+ File location;
+ long timestamp;
+ }
+
+ /*
+ * Return the configuration object which is represented by the given file.
+ */
+ static Configuration read(File file, URL osgiInstallArea) throws ProvisionException {
+ // check the cached copy first
+ if (cache != null && file.lastModified() == cache.timestamp)
+ return cache.config;
+
+ // cache miss or file is out of date, read from disk
+ Configuration config = ConfigurationParser.parse(file, osgiInstallArea);
+ if (config == null)
+ return null;
+
+ // successful read, store in the cache before we return
+ cache(file, config, osgiInstallArea);
+ return config;
+ }
+
+ /*
+ * Store the given configuration file in the local cache.
+ */
+ private static void cache(File location, Configuration config, URL osgiInstallArea) {
+ CacheEntry entry = new CacheEntry();
+ entry.config = config;
+ entry.osgiInstallArea = osgiInstallArea;
+ entry.location = location;
+ entry.timestamp = location.lastModified();
+ cache = entry;
+ }
+
+ /*
+ * Save the given configuration to the file-system.
+ */
+ static void write(File location, Configuration config, URL osgiInstallArea) throws ProvisionException {
+ // write it to disk
+ ConfigurationWriter.save(config, location, osgiInstallArea);
+ // save a copy in the cache
+ cache(location, config, osgiInstallArea);
+ }
+
+}

Back to the top