Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJohn Arthorne2009-12-18 20:57:35 +0000
committerJohn Arthorne2009-12-18 20:57:35 +0000
commit3f81d92597298bcaff44455f6841ee4c415d2685 (patch)
tree33f42bf7a1818f55b546fd5af4cd0a97a44c8598
parentae810b22032c9b8cffd5e58e82dadab913585341 (diff)
downloadrt.equinox.p2-3f81d92597298bcaff44455f6841ee4c415d2685.tar.gz
rt.equinox.p2-3f81d92597298bcaff44455f6841ee4c415d2685.tar.xz
rt.equinox.p2-3f81d92597298bcaff44455f6841ee4c415d2685.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
-rw-r--r--bundles/org.eclipse.equinox.p2.touchpoint.eclipse/src/org/eclipse/equinox/internal/p2/update/ConfigurationParser.java2
-rw-r--r--bundles/org.eclipse.equinox.p2.touchpoint.eclipse/src/org/eclipse/equinox/internal/p2/update/ConfigurationWriter.java2
5 files changed, 79 insertions, 5 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 b7a4cb75d..ffa9687eb 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
@@ -127,7 +127,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);
+ }
+
+}
diff --git a/bundles/org.eclipse.equinox.p2.touchpoint.eclipse/src/org/eclipse/equinox/internal/p2/update/ConfigurationParser.java b/bundles/org.eclipse.equinox.p2.touchpoint.eclipse/src/org/eclipse/equinox/internal/p2/update/ConfigurationParser.java
index 7582f56e8..f52d2d80b 100644
--- a/bundles/org.eclipse.equinox.p2.touchpoint.eclipse/src/org/eclipse/equinox/internal/p2/update/ConfigurationParser.java
+++ b/bundles/org.eclipse.equinox.p2.touchpoint.eclipse/src/org/eclipse/equinox/internal/p2/update/ConfigurationParser.java
@@ -34,7 +34,7 @@ public class ConfigurationParser implements ConfigurationConstants {
* Parse the given file handle which points to a platform.xml file and a configuration object.
* Returns null if the file doesn't exist.
*/
- public static Configuration parse(File file, URL osgiInstallArea) throws ProvisionException {
+ static Configuration parse(File file, URL osgiInstallArea) throws ProvisionException {
return new ConfigurationParser(osgiInstallArea).internalParse(file);
}
diff --git a/bundles/org.eclipse.equinox.p2.touchpoint.eclipse/src/org/eclipse/equinox/internal/p2/update/ConfigurationWriter.java b/bundles/org.eclipse.equinox.p2.touchpoint.eclipse/src/org/eclipse/equinox/internal/p2/update/ConfigurationWriter.java
index b54ea6fd6..aeea26038 100644
--- a/bundles/org.eclipse.equinox.p2.touchpoint.eclipse/src/org/eclipse/equinox/internal/p2/update/ConfigurationWriter.java
+++ b/bundles/org.eclipse.equinox.p2.touchpoint.eclipse/src/org/eclipse/equinox/internal/p2/update/ConfigurationWriter.java
@@ -30,7 +30,7 @@ public class ConfigurationWriter implements ConfigurationConstants {
/*
* Save the given configuration to the specified location.
*/
- public static void save(Configuration configuration, File location, URL osgiInstallArea) throws ProvisionException {
+ static void save(Configuration configuration, File location, URL osgiInstallArea) throws ProvisionException {
XMLWriter writer = null;
try {
OutputStream output = new BufferedOutputStream(new FileOutputStream(location));

Back to the top