This commit was manufactured by cvs2svn to create branch 'v20020411a'.
Sprout from master 2002-04-11 14:05:05 UTC rodrigo <rodrigo> 'Updated plug-in version id.'
Cherrypick from master 2002-04-25 13:40:14 UTC DJ Houghton <dj> 'Fix for Bug 14223.':
bundles/org.eclipse.core.runtime/src/org/eclipse/core/internal/runtime/PlatformLogReader.java
bundles/org.eclipse.core.runtime/src/org/eclipse/core/internal/runtime/PlatformLogWriter.java
tests/org.eclipse.core.tests.runtime/src/org/eclipse/core/tests/internal/runtime/LogSerializationTest.java
Delete:
bundles/org.eclipse.core.boot/.classpath
bundles/org.eclipse.core.boot/.cvsignore
bundles/org.eclipse.core.boot/.project
bundles/org.eclipse.core.boot/about.html
bundles/org.eclipse.core.boot/build.properties
bundles/org.eclipse.core.boot/plugin.properties
bundles/org.eclipse.core.boot/plugin.xml
bundles/org.eclipse.core.boot/src/com/ibm/oti/vm/VM.java
bundles/org.eclipse.core.boot/src/org/eclipse/core/boot/BootLoader.java
bundles/org.eclipse.core.boot/src/org/eclipse/core/boot/IPlatformConfiguration.java
bundles/org.eclipse.core.boot/src/org/eclipse/core/boot/IPlatformRunnable.java
bundles/org.eclipse.core.boot/src/org/eclipse/core/boot/package.html
bundles/org.eclipse.core.boot/src/org/eclipse/core/internal/boot/DelegatingURLClassLoader.java
bundles/org.eclipse.core.boot/src/org/eclipse/core/internal/boot/InternalBootLoader.java
bundles/org.eclipse.core.boot/src/org/eclipse/core/internal/boot/PlatformClassLoader.java
bundles/org.eclipse.core.boot/src/org/eclipse/core/internal/boot/PlatformConfiguration.java
bundles/org.eclipse.core.boot/src/org/eclipse/core/internal/boot/PlatformURLBaseConnection.java
bundles/org.eclipse.core.boot/src/org/eclipse/core/internal/boot/PlatformURLConnection.java
bundles/org.eclipse.core.boot/src/org/eclipse/core/internal/boot/PlatformURLHandler.java
bundles/org.eclipse.core.boot/src/org/eclipse/core/internal/boot/PlatformURLHandlerFactory.java
bundles/org.eclipse.core.boot/src/org/eclipse/core/internal/boot/PlatformURLHandlerFactoryProxy.java
bundles/org.eclipse.core.boot/src/org/eclipse/core/internal/boot/Policy.java
bundles/org.eclipse.core.boot/src/org/eclipse/core/internal/boot/ResourceEnumeration.java
bundles/org.eclipse.core.boot/src/org/eclipse/core/internal/boot/ResourceLoader.java
bundles/org.eclipse.core.boot/src/org/eclipse/core/internal/boot/URLContentFilter.java
bundles/org.eclipse.core.boot/src/org/eclipse/core/internal/boot/messages.properties
tests/org.eclipse.core.tests.harness/.classpath
tests/org.eclipse.core.tests.harness/.cvsignore
tests/org.eclipse.core.tests.harness/.project
tests/org.eclipse.core.tests.harness/about.html
tests/org.eclipse.core.tests.harness/build-tests.xml
tests/org.eclipse.core.tests.harness/build.properties
tests/org.eclipse.core.tests.harness/plugin.xml
tests/org.eclipse.core.tests.harness/readme.txt
tests/org.eclipse.core.tests.harness/src/org/eclipse/core/tests/harness/CancelingProgressMonitor.java
tests/org.eclipse.core.tests.harness/src/org/eclipse/core/tests/harness/CorePerformanceTest.java
tests/org.eclipse.core.tests.harness/src/org/eclipse/core/tests/harness/DeltaDebugListener.java
tests/org.eclipse.core.tests.harness/src/org/eclipse/core/tests/harness/EclipseTestHarnessApplication.java
tests/org.eclipse.core.tests.harness/src/org/eclipse/core/tests/harness/EclipseWorkspaceTest.java
tests/org.eclipse.core.tests.harness/src/org/eclipse/core/tests/harness/ExampleTest.java
tests/org.eclipse.core.tests.harness/src/org/eclipse/core/tests/harness/ExampleWorkspaceTest.java
tests/org.eclipse.core.tests.harness/src/org/eclipse/core/tests/harness/FussyProgressMonitor.java
tests/org.eclipse.core.tests.harness/src/org/eclipse/core/tests/harness/LoggingPerformanceTestResult.java
tests/org.eclipse.core.tests.harness/src/org/eclipse/core/tests/harness/PerformanceTestResult.java
tests/org.eclipse.core.tests.harness/src/org/eclipse/core/tests/harness/PerformanceTimer.java
tests/org.eclipse.core.tests.harness/src/org/eclipse/core/tests/harness/SessionTestApplication.java
tests/org.eclipse.core.tests.harness/src/org/eclipse/core/tests/harness/TestProgressMonitor.java
tests/org.eclipse.core.tests.harness/src/org/eclipse/core/tests/harness/WorkspaceSessionTest.java
tests/org.eclipse.core.tests.harness/test.xml
diff --git a/bundles/org.eclipse.core.boot/.classpath b/bundles/org.eclipse.core.boot/.classpath
deleted file mode 100644
index dbbc1d8..0000000
--- a/bundles/org.eclipse.core.boot/.classpath
+++ /dev/null
@@ -1,6 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<classpath>
- <classpathentry kind="var" path="JRE_LIB" rootpath="JRE_SRCROOT" sourcepath="JRE_SRC"/>
- <classpathentry kind="src" path="src"/>
- <classpathentry kind="output" path="bin"/>
-</classpath>
diff --git a/bundles/org.eclipse.core.boot/.cvsignore b/bundles/org.eclipse.core.boot/.cvsignore
deleted file mode 100644
index c5e82d7..0000000
--- a/bundles/org.eclipse.core.boot/.cvsignore
+++ /dev/null
@@ -1 +0,0 @@
-bin
\ No newline at end of file
diff --git a/bundles/org.eclipse.core.boot/.project b/bundles/org.eclipse.core.boot/.project
deleted file mode 100644
index c6103e5..0000000
--- a/bundles/org.eclipse.core.boot/.project
+++ /dev/null
@@ -1,18 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<projectDescription>
- <name>org.eclipse.core.boot</name>
- <comment></comment>
- <projects>
- </projects>
- <buildSpec>
- <buildCommand>
- <name>org.eclipse.jdt.core.javabuilder</name>
- <arguments>
- </arguments>
- </buildCommand>
- </buildSpec>
- <natures>
- <nature>org.eclipse.jdt.core.javanature</nature>
- <nature>org.eclipse.team.cvs.core.cvsnature</nature>
- </natures>
-</projectDescription>
diff --git a/bundles/org.eclipse.core.boot/about.html b/bundles/org.eclipse.core.boot/about.html
deleted file mode 100644
index 441774f..0000000
--- a/bundles/org.eclipse.core.boot/about.html
+++ /dev/null
@@ -1,42 +0,0 @@
-<html>
-<head>
-<title>About</title>
-<style type="text/css">
-p, table, td, th { font-family: arial, helvetica, geneva; font-size: 10pt}
-pre { font-family: "Courier New", Courier, mono; font-size: 10pt}
-h2 { font-family: arial, helvetica, geneva; font-size: 18pt; font-weight: bold ; line-height: 14px}
-code { font-family: "Courier New", Courier, mono; font-size: 10pt}
-sup { font-family: arial,helvetica,geneva; font-size: 10px}
-h3 { font-family: arial, helvetica, geneva; font-size: 14pt; font-weight: bold}
-li { font-family: arial, helvetica, geneva; font-size: 10pt}
-h1 { font-family: arial, helvetica, geneva; font-size: 28px; font-weight: bold}
-body { font-family: arial, helvetica, geneva; font-size: 10pt; clip: rect( ); margin-top: 5mm; margin-left: 3mm}
-</style>
-</head>
-<body lang="EN-US" link="blue" vlink="purple">
-<table border="0" cellspacing="5" cellpadding="2" width="100%" >
- <tr>
- <td align="LEFT" valign="TOP" colspan="2" bgcolor="#0080C0"><b><font color="#FFFFFF">About This Content</font></b></td>
- </tr>
- <tr>
- <td>
-<p>11th December, 2001</p>
-<h3>License</h3>
-<p>Eclipse.org makes available all content in this plug-in "Content". Unless otherwise indicated below, the Content is provided to you under the terms and conditions of the
-<a href="http://www.eclipse.org/legal/cpl-v05.html">Common Public License Version 0.5</a> "CPL". For purposes of the CPL, "Program" will mean the Content.</p>
-
-<h3>Contributions</h3>
-
-<p>If this Content is licensed to you under the terms and conditions of the CPL, any Contributions, as defined in the CPL, uploaded, submitted, or otherwise
-made available to Eclipse.org, members of Eclipse.org and/or the host of Eclipse.org web site, by you that relate to such
-Content are provided under the terms and conditions of the CPL and can be made available to others under the terms of the CPL.</p>
-
-<p>If this Content is licensed to you under license terms and conditions other than the CPL "Other License", any modifications, enhancements and/or
-other code and/or documentation "Modifications" uploaded, submitted, or otherwise made available to Eclipse.org, members of Eclipse.org and/or the
-host of Eclipse.org, by you that relate to such Content are provided under terms and conditions of the Other License and can be made available
-to others under the terms of the Other License. In addition, with regard to Modifications for which you are the copyright holder, you are also
-providing the Modifications under the terms and conditions of the CPL and such Modifications can be made available to others under the terms of
-the CPL.</p>
-</td></tr></table>
-</body>
-</html>
\ No newline at end of file
diff --git a/bundles/org.eclipse.core.boot/build.properties b/bundles/org.eclipse.core.boot/build.properties
deleted file mode 100644
index f7a041b..0000000
--- a/bundles/org.eclipse.core.boot/build.properties
+++ /dev/null
@@ -1,4 +0,0 @@
-source.boot.jar=src/
-bin.includes=plugin.xml,*.jar,plugin.properties,about.html
-javadoc.packages=org.eclipse.core.boot.*
-
diff --git a/bundles/org.eclipse.core.boot/plugin.properties b/bundles/org.eclipse.core.boot/plugin.properties
deleted file mode 100644
index dfac5a9..0000000
--- a/bundles/org.eclipse.core.boot/plugin.properties
+++ /dev/null
@@ -1,3 +0,0 @@
-# Boot strings
-pluginName = Core Boot
-providerName = Object Technology International, Inc.
\ No newline at end of file
diff --git a/bundles/org.eclipse.core.boot/plugin.xml b/bundles/org.eclipse.core.boot/plugin.xml
deleted file mode 100644
index 609a462..0000000
--- a/bundles/org.eclipse.core.boot/plugin.xml
+++ /dev/null
@@ -1,14 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<plugin
- id="org.eclipse.core.boot"
- name="%pluginName"
- version="2.0.7"
- provider-name="%providerName">
-
-<runtime>
- <library name="boot.jar">
- <export name="*"/>
- </library>
-</runtime>
-
-</plugin>
diff --git a/bundles/org.eclipse.core.boot/src/com/ibm/oti/vm/VM.java b/bundles/org.eclipse.core.boot/src/com/ibm/oti/vm/VM.java
deleted file mode 100644
index f6e875e..0000000
--- a/bundles/org.eclipse.core.boot/src/com/ibm/oti/vm/VM.java
+++ /dev/null
@@ -1,21 +0,0 @@
-package com.ibm.oti.vm;
-
-/*
- * (c) Copyright IBM Corp. 2000, 2001.
- * All Rights Reserved.
- */
-
-/*
- * Dummy class to fill in for the real J9 VM support class.
- * This class will be overridden when running the platform on J9
- * because the real class is part of the boot class path.
- */
-
-abstract public class VM {
-
-public static void enableClassHotSwap(Class clazz) {
-}
-public static void setClassPathImpl(ClassLoader cl, String path) {
-}
-
-}
diff --git a/bundles/org.eclipse.core.boot/src/org/eclipse/core/boot/BootLoader.java b/bundles/org.eclipse.core.boot/src/org/eclipse/core/boot/BootLoader.java
deleted file mode 100644
index 72bd6a9..0000000
--- a/bundles/org.eclipse.core.boot/src/org/eclipse/core/boot/BootLoader.java
+++ /dev/null
@@ -1,376 +0,0 @@
-package org.eclipse.core.boot;
-
-/*
- * (c) Copyright IBM Corp. 2000, 2001.
- * All Rights Reserved.
- */
-
-import java.io.IOException;
-import java.net.URL;
-
-import org.eclipse.core.internal.boot.InternalBootLoader;
-
-/**
- * Special boot loader class for the Eclipse Platform. This class cannot
- * be instantiated; all functionality is provided by static methods.
- * <p>
- * The Eclipse Platform makes heavy use of Java class loaders for
- * loading plug-ins. Even the Platform Core Runtime itself, including
- * the <code>Platform</code> class, needs to be loaded by a special
- * class loader. The upshot is that a client program (such as a Java main
- * program, a servlet) cannot directly reference even the
- * <code>Platform</code> class. Instead, a client must use this
- * loader class for initializing the platform, invoking functionality
- * defined in plug-ins, and shutting down the platform when done.
- * </p>
- *
- * @see org.eclipse.core.runtime.Platform
- */
-public final class BootLoader {
-
- /**
- * The unique identifier constant (value "<code>org.eclipse.core.boot</code>")
- * of the Core Boot (pseudo-) plug-in.
- */
- public static final String PI_BOOT = "org.eclipse.core.boot";
-
- /**
- * Constant string (value "win32") indicating the platform is running on a
- * Window 32-bit operating system (e.g., Windows 98, NT, 2000).
- */
- public static final String OS_WIN32 = "win32";
-
- /**
- * Constant string (value "linux") indicating the platform is running on a
- * Linux-based operating system.
- */
- public static final String OS_LINUX = "linux";
-
- /**
- * Constant string (value "aix") indicating the platform is running on an
- * AIX-based machine.
- */
- public static final String OS_AIX = "aix";
-
- /**
- * Constant string (value "solaris") indicating the platform is running on a
- * Solaris-based machine.
- */
- public static final String OS_SOLARIS = "solaris";
-
- /**
- * Constant string (value "hpux") indicating the platform is running on an
- * HP/UX-based machine.
- */
- public static final String OS_HPUX = "hpux";
-
- /**
- * Constant string (value "qnx") indicating the platform is running on a
- * QNX-based machine.
- */
- public static final String OS_QNX = "qnx";
-
- /**
- * Constant string (value "unknown") indicating the platform is running on a
- * machine running an unknown operating system.
- */
- public static final String OS_UNKNOWN = "unknown";
-
- /**
- * Constant string (value "x86") indicating the platform is running on an
- * x86-based architecture.
- */
- public static final String ARCH_X86 = "x86";
-
- /**
- * Constant string (value "win32") indicating the platform is running on a
- * machine using the Windows windowing system.
- */
- public static final String WS_WIN32 = "win32";
-
- /**
- * Constant string (value "motif") indicating the platform is running on a
- * machine using the Motif windowing system.
- */
- public static final String WS_MOTIF = "motif";
-
- /**
- * Constant string (value "gtk") indicating the platform is running on a
- * machine using the GTK windowing system.
- */
- public static final String WS_GTK = "gtk";
-
- /**
- * Constant string (value "photon") indicating the platform is running on a
- * machine using the Photon windowing system.
- */
- public static final String WS_PHOTON = "photon";
-
- /**
- * Constant string (value "unknown") indicating the platform is running on a
- * machine running an unknown windowing system.
- */
- public static final String WS_UNKNOWN = "unknown";
-
-/**
- * Private constructor to block instance creation.
- */
-private BootLoader() {
-}
-/**
- * Returns whether the given location (typically a directory in the
- * local file system) contains the saved data for a platform. The
- * saved data for the platform is recognizable by the presence of
- * a special platform metadata subdirectory; however, this metadata
- * directory is not usually created unless there is some reason to do so
- * (for example, so that an active plug-in can save its state).
- *
- * @return <code>true</code> if the location contains the
- * saved data for a platform, and <code>false</code> otherwise
- */
-public static boolean containsSavedPlatform(String location) {
- return InternalBootLoader.containsSavedPlatform(location);
-}
-/**
- * Returns the command line args provided to the platform when it was first run.
- * Note that individual platform runnables may be provided with different arguments
- * if they are being run individually rather than with <code>Platform.run()</code>.
- *
- * @return the command line used to start the platform
- */
-public static String[] getCommandLineArgs() {
- return InternalBootLoader.getCommandLineArgs();
-}
-/**
- * Returns the current platform configuration.
- *
- * @return platform configuration used in current instance of platform
- * @since 2.0
- */
-public static IPlatformConfiguration getCurrentPlatformConfiguration() {
- return InternalBootLoader.getCurrentPlatformConfiguration();
-}
-/**
- * Returns URL at which the Platform runtime executables and libraries are installed.
- * The returned value is distinct from the location of any given platform's data.
- *
- * @return the URL indicating where the platform runtime is installed.
- */
-public static URL getInstallURL() {
- return InternalBootLoader.getInstallURL();
-}
-/**
- * Returns the string name of the current locale for use in finding files
- * whose path starts with <code>$nl$</code>. <code>null</code> is returned
- * if the locale cannot be determined.
- *
- * @return the string name of the current locale or <code>null</code>
- */
-public static String getNL() {
- return InternalBootLoader.getNL();
-}
-/**
- * Returns the string name of the current operating system for use in finding files
- * whose path starts with <code>$os$</code>. <code>OS_UNKNOWN</code> is returned
- * if the operating system cannot be determined. The value may indicate one of the following
- * operating systems known to the platform (<code>OS_WIN32</code>, <code>OS_LINUX</code>,
- * <code>OS_AIX</code>, <code>OS_SOLARIS</code>, <code>OS_HPUX</code> or
- * a user-defined string if the operating system name is specified on the command line.
- *
- * @return the string name of the current operating system
- *
- */
-public static String getOS() {
- return InternalBootLoader.getOS();
-}
-/**
- * Returns the string name of the current system architecture.
- * The value is a user-defined string if the architecture is
- * specified on the command line, otherwise it is the value
- * returned by <code>java.lang.System.getProperty("os.arch")</code>.
- *
- * @return the string name of the current system architecture
- * @since 2.0
- */
-public static String getOSArch() {
- return InternalBootLoader.getOSArch();
-}
-/**
- * Returns a platform configuration object, optionally initialized with previously saved
- * configuration information.
- *
- * @param url location of previously save configuration information. If <code>null</code>
- * is specified, an empty configuration object is returned
- * @return platform configuration used in current instance of platform
- * @since 2.0
- */
-public static IPlatformConfiguration getPlatformConfiguration(URL url) throws IOException {
- return InternalBootLoader.getPlatformConfiguration(url);
-}
-/**
- * Returns the complete plugin path defined by the file at the given location.
- * If the given location is <code>null</code> or does not indicate a valid
- * plug-in path definition file, <code>null</code> is returned.
- *
- * @return the complete set of URLs which locate plug-ins
- */
-public static URL[] getPluginPath(URL pluginPathLocation) {
- return InternalBootLoader.getPluginPath(pluginPathLocation);
-}
-/**
- * Instantiates and returns an instance of the named application's
- * runnable entry point.
- * <code>null</code> is returned if the runnable cannot be found.
- *
- * @param applicationName the fully qualified name of an
- * extension installed in the platform's <code>applications</code>
- * extension point (i.e., <code>org.eclipse.core.applications</code>).
- * @return a platform runnable
- * @exception Exception if there is a problem instantiating the specified runnable
- */
-public static IPlatformRunnable getRunnable(String applicationName) throws Exception {
- return InternalBootLoader.getRunnable(applicationName);
-}
-/**
- * Instantiates and returns an instance of the named class. The class
- * must implement <code>IPlatformRunnable</code>.
- * If the class implements <code>IExecutableExtension</code>, the created
- * instance is initialized with the given arguments.
- * <code>null</code> is returned if the runnable cannot be found.
- *
- * @param pluginId the unique identifier of the plug-in containing the given class
- * @param className the fully qualified name of the class to instantiate
- * @param args the initialization arguments passed to the new instance
- * @return a platform runnable, or <code>null</code> if the runnable cannot
- * be found
- * @exception Exception if there is a problem instantiating the specified runnable
- */
-public static IPlatformRunnable getRunnable(String pluginId, String className, Object args) throws Exception {
- return InternalBootLoader.getRunnable(pluginId, className, args);
-}
-/**
- * Returns the string name of the current window system for use in finding files
- * whose path starts with <code>$ws$</code>. <code>null</code> is returned
- * if the window system cannot be determined.
- *
- * @return the string name of the current window system or <code>null</code>
- */
-public static String getWS() {
- return InternalBootLoader.getWS();
-}
-/**
- * Returns <code>true</code> if the platform is currently running in
- * debug mode. The platform is run
- * in debug mode using the "-debug" command line argument.
- *
- * @return whether or not the platform is running in debug mode
- */
-public static boolean inDebugMode() {
- return InternalBootLoader.inDebugMode();
-}
-/**
- * Returns <code>true</code> if the platform is currently running in
- * development mode. That is, if special procedures are to be
- * taken when defining plug-in class paths. The platform is run
- * in development mode using the "-dev" command line argument.
- *
- * @return whether or not the platform is running in development mode
- */
-public static boolean inDevelopmentMode() {
- return InternalBootLoader.inDevelopmentMode();
-}
-/**
- * Returns whether the platform is running.
- * The <code>startup</code> method starts the platform running;
- * the <code>shutdown</code> method stops it.
- *
- * @return <code>true</code> if the platform is running,
- * and <code>false</code> otherwise
- * @see #startup
- * @see #shutdown
- */
-public static boolean isRunning() {
- return InternalBootLoader.isRunning();
-}
-/**
- * Launches the Platform to run a single application.
- * This convenince method starts up the Platform,
- * runs the indicated application, and then shuts down
- * the Platform. The Platform must not be running already.
- *
- * @param applicationName The fully qualified name of an
- * extension installed in the Platform plug-in's <code>applications</code>
- * extension-point (i.e., <code>org.eclipse.core.runtime.applications</code>).
- * @param pluginPathLocation the URL of the plug-in path; this is where
- * the Platform is to find the code for plug-ins
- * @param location the location (usually a string path in the local file
- * file system) for the saved platform state
- * @param args the array of command-line style argments which are passed
- * to the Platform on initialization. The arguments which are consumed by the
- * Platform's initialization are removed from the arg list. This modified arg list is
- * the return value of this method.
- *@return the list of <code>args</code> which were supplied but not consumed
- * by this method.
- * @return the result, or <code>null</code> if none
- * @exception Exception if anything goes wrong
- * @see #startup
- */
-public static Object run(String applicationName, URL pluginPathLocation, String location, String[] args) throws Exception {
- return InternalBootLoader.run(applicationName, pluginPathLocation, location, args);
-}
-/**
- * Shuts down the Platform. The Platform must be running. In the process,
- * each active plug-in is told to shutdown via <code>Plugin.shutdown</code>.
- * <p>
- * Note that the state of the Platform is not automatically saved
- * before shutting down.
- * </p>
- * <p>
- * On return, the Platform will no longer be running (but could
- * be re-launched with another call to <code>startup</code>).
- * Any objects handed out by running Platform, including
- * Platform runnables obtained via <code>getRunnable</code>,
- * will be permanently invalid. The effects of attempting to invoke
- * methods on invalid objects is undefined.
- * </p>
- * @exception Exception if there were problems shutting down
- */
-public static void shutdown() throws Exception {
- InternalBootLoader.shutdown();
-}
-/**
- * Launches the Eclipse Platform. The Platform must not be running.
- * <p>
- * The location of the started Platform is defined as follows:
- * <ul>
- * <li>If the <code>location</code> argument is specified, that value is used.
- * <li>If <code>location</code> is <code>null</code> but <code>args</code>
- * contains a <code>-platform <location></code> pair, then the given value is used.
- * <li> If neither is specified, <code>System.getProperty("user.dir")</code> is used.
- * </ul>
- * The plug-in path of the started Platform is defined as follows:
- * <ul>
- * <li>If the <code>pluginPathLocation</code> argument is specified, that value is tried.
- * <li>If <code>pluginPathLocation</code> is <code>null</code> but <code>args</code>
- * contains a <code>-plugins <location></code> pair, then the given value is tried.
- * <li>If neither value is specified or a given location does not exist,
- * the Platform's location is searched.
- * <li>Finally, the default plug-in path is used. This value identifies the plug-ins in the
- * Platform's install location.
- * </ul>
- * @param pluginPathLocation the URL of the plug-in path; this is where
- * the Platform is to find the code for plug-ins
- * @param location the location (usually a string path in the local file
- * file system) for the saved Platform state
- * @param args the array of command-line style argments which are passed
- * to the platform on initialization. The arguments which are consumed by the
- * Platform's initialization are removed from the arg list. This modified arg list is
- * the return value of this method.
- * @return the list of <code>args</code> which were supplied but not consumed
- * by this method.
- * @exception Exception if there are problems starting the platform
- */
-public static String[] startup(URL pluginPathLocation, String location, String[] args) throws Exception {
- return InternalBootLoader.startup(pluginPathLocation, location, args);
-}
-}
diff --git a/bundles/org.eclipse.core.boot/src/org/eclipse/core/boot/IPlatformConfiguration.java b/bundles/org.eclipse.core.boot/src/org/eclipse/core/boot/IPlatformConfiguration.java
deleted file mode 100644
index 9ac8c57..0000000
--- a/bundles/org.eclipse.core.boot/src/org/eclipse/core/boot/IPlatformConfiguration.java
+++ /dev/null
@@ -1,485 +0,0 @@
-package org.eclipse.core.boot;
-/*
- * (c) Copyright IBM Corp. 2000, 2001.
- * All Rights Reserved.
- */
-
-import java.io.IOException;
-import java.net.URL;
-
-/**
- * Platform configuration interface. Represents the runtime
- * configuration used by the Eclipse platform. Any configuration
- * changes do not take effect until next startup of the Eclipse
- * platform
- *
- * @since 2.0
- */
-public interface IPlatformConfiguration {
-
- /**
- * Configuration entry representing an install site.
- *
- * @since 2.0
- */
- public interface ISiteEntry {
-
- /**
- * Returns the URL for this site
- *
- * @return site url
- * @since 2.0
- */
- public URL getURL();
-
- /**
- * Returns the policy for this site
- *
- * @return site policy
- * @since 2.0
- */
- public ISitePolicy getSitePolicy();
-
- /**
- * Sets the site policy
- *
- * @param policy site policy
- * @since 2.0
- */
- public void setSitePolicy(ISitePolicy policy);
-
- /**
- * Returns a list of features visible on the site. Note, that this is simply a
- * reflection of the site content. The features may or may not be actually configured.
- *
- * @return an array of feature entries, or an empty array if no features are found.
- * A feature entry is returned as a path relative to the site URL
- * @since 2.0
- */
- public String[] getFeatures();
-
- /**
- * Returns a list of plug-ins visible on the site. Note, that this is simply a
- * reflection of the site content and the current policy for the site. The plug-ins
- * may or may not end up being used by Eclipse (depends on which plug-in are
- * actually bound by the platform).
- *
- * @return an array of plug-in entries, or an empty array if no plug-ins are found.
- * A plug-in entry is returned as a path relative to the site URL *
- * @since 2.0
- */
- public String[] getPlugins();
-
- /**
- * Returns a stamp reflecting the current state of the site. If called repeatedly,
- * returns the same value as long as no changes were made to the site (changes to
- * features or plugins).
- *
- * @return site change stamp
- * @since 2.0
- */
- public long getChangeStamp();
-
- /**
- * Returns a stamp reflecting the current state of the features on the site.
- * If called repeatedly, returns the same value as long as no changes were made to
- * features on the site.
- *
- * @return site features change stamp
- * @since 2.0
- */
- public long getFeaturesChangeStamp();
-
- /**
- * Returns a stamp reflecting the current state of the plug-ins on the site.
- * If called repeatedly, returns the same value as long as no changes were made to
- * plug-ins on the site.
- *
- * @return site plug-ins change stamp
- * @since 2.0
- */
- public long getPluginsChangeStamp();
-
- /**
- * Returns an indication whether the site can be updated.
- *
- * @return <code>true</code> if site can be updated, <code>false</code> otherwise
- * @since 2.0
- */
- public boolean isUpdateable();
- }
-
- /**
- * Site policy. The site policy object determines how plug-ins
- * contained on the site are processed during startup. In general,
- * there are 3 ways of configuring a site policy
- * <ul>
- * <li>explicitly specify which plug-ins are to be included at
- * startup (type==USER_INCLUDE). Any other plug-ins located
- * at the site are ignored at startup. This is typically the best
- * policy when using remote sites where the user wishes
- * to retain explicit control over the plug-ins that are included
- * from such site.
- * <li>explicitly specify which plug-ins are to be excluded at
- * startup (type==USER-EXCLUDE). All other plug-ins located
- * at the site are used at startup. This policy requires that
- * the site support an access "protocol" that allows plug-in
- * discovery. In general, these are sites defined using the "file"
- * URL protocol. This is typically the best policy for local
- * install sites (on the user system).
- * </ul>
- *
- * @since 2.0
- */
- public interface ISitePolicy {
-
- /**
- * Policy type constants.
- */
-
- /**
- * User-defined inclusion list. The list associated with this
- * policy type is interpreted as path entries to included plugin.xml
- * or fragment.xml <b>relative</b> to the site URL
- */
- public static final int USER_INCLUDE = 0;
-
- /**
- * User-defined exclusion list. The list associated with this
- * policy type is interpreted as path entries to excluded plugin.xml
- * or fragment.xml <b>relative</b> to the site URL
- */
- public static final int USER_EXCLUDE = 1;
-
- /**
- * Return policy type
- *
- * @return policy type
- * @since 2.0
- */
- public int getType();
-
- /**
- * Return policy inclusion/ exclusion list
- *
- * @return the list as an array
- * @since 2.0
- */
- public String[] getList();
-
- /**
- * Set new policy list. The list entries are interpreted based on the policy
- * type. See description of the policy type constants for details.
- *
- * @param list policy inclusion/ exclusion list as an array.
- * Returns an empty array if there are no entries.
- * @see USER_INCLUDE
- * @see USER_EXCLUDE
- * @since 2.0
- */
- public void setList(String[] list);
- }
-
- /**
- * Feature entry.
- * Represents runtime "hints" about configured features.
- * The information is used during startup to locate the
- * correct attribution information for a primary feature. Note,
- * that a typical configuration can declare multiple feature
- * entries. At execution time, only one can be selected as
- * the active primary feature. This is determined based on
- * specified command line arguments or computed defaults.
- *
- * @since 2.0
- */
- public interface IFeatureEntry {
-
- /**
- * Returns feature identifier.
- * @return feature identifier
- * @since 2.0
- */
- public String getFeatureIdentifier();
-
- /**
- * Returns the currently configured version for the feature.
- * @return feature version (as string), or <code>null</code>
- * @since 2.0
- */
- public String getFeatureVersion();
-
- /**
- * Returns the application to run when this feature is the
- * primary feature.
- * @return application identifier, or <code>null</code>
- * @since 2.0
- */
- public String getFeatureApplication();
-
- /**
- * Returns URL to the feature "root" files potentially
- * containing feature customization information
- * @return feature root path, or <code>null</code>
- * @since 2.0
- */
- public URL getFeatureRootURL();
- }
-
- /**
- * Create a site entry
- *
- * @param url site URL
- * @param policy site policy
- * @return created site entry
- * @since 2.0
- */
- public ISiteEntry createSiteEntry(URL url, ISitePolicy policy);
-
- /**
- * Create a site policy. The policy determines the way the site
- * plug-in are processed at startpu
- *
- * @param type policy type
- * @param list an array of site-relative paths representing the
- * inclusion/ exclusion list
- * @return created site policy entry
- * @since 2.0
- */
- public ISitePolicy createSitePolicy(int type, String[] list);
-
- /**
- * Create a feature entry
- * @param id feature identifier. Must not be <code>null</code>.
- * @param version feature version (as String). Can be <code>null</code>.
- * @param application identifier of the application to run when
- * this feature is the primary feature. Can be <code>null</code>.
- * If specified, the identifier must represent a valid extension
- * registered in the <code>org.eclipse.core.runtime.applications</code>
- * extension point.
- * @param root URL to feature root. Can be <code>null</code>.
- * @return create feature entry
- * @since 2.0
- */
- public IFeatureEntry createFeatureEntry(String id, String version, String application, URL root);
-
- /**
- * Configures the specified site entry. If a site entry with the
- * same site URL is already configured, the entry is <b>not</b> replaced.
- *
- * @param entry site entry
- * @since 2.0
- */
- public void configureSite(ISiteEntry entry);
-
- /**
- * Configures the specified site entry. If a site entry with the
- * same site URL is already configured, the replacement behavior for
- * the entry can be specified.
- *
- * @param entry site entry
- * @param flag indicating whether an existing configured entry with
- * the same URL should be replaced (<code>true</code>) or not (<code>false</code>).
- * @since 2.0
- */
- public void configureSite(ISiteEntry entry, boolean replace);
-
- /**
- * Unconfigures the specified entry. Does not do anything if the entry
- * is not configured.
- *
- * @param entry site entry
- * @since 2.0
- */
- public void unconfigureSite(ISiteEntry entry);
-
- /**
- * Returns configured site entries
- *
- * @return array of site entries. Returns an empty array if no sites are
- * configured
- * @since 2.0
- */
- public ISiteEntry[] getConfiguredSites();
-
- /**
- * Returns a site entry matching the specified URL
- *
- * @param url site url
- * @return matching site entry, or <code>null</code> if no match found
- * @since 2.0
- */
- public ISiteEntry findConfiguredSite(URL url);
-
- /**
- * Configures the feature entry.
- * If another feature entry with the same feature identifier
- * already exists, it is replaced.
- * @param entry feature entry
- * @since 2.0
- */
- public void configureFeatureEntry(IFeatureEntry entry);
-
- /**
- * Unconfigures the specified feature entry if it exists.
- * @param entry feature entry
- * @since 2.0
- */
- public void unconfigureFeatureEntry(IFeatureEntry entry);
-
- /**
- * Returns a list of configured feature entries.
- * @return array or entries, or an empty array if no entries
- * are configured
- * @since 2.0
- */
- public IFeatureEntry[] getConfiguredFeatureEntries();
-
- /**
- * Locates the specified feature entry.
- * @param id feature identifier
- * @return ferature entry, or <code>null</code>.
- * @since 2.0
- */
- public IFeatureEntry findConfiguredFeatureEntry(String id);
-
- /**
- * Returns the URL location of the configuration information
- *
- * @return configuration location URL, or <code>null</code> if the
- * configuration location could not be determined.
- * @since 2.0
- */
- public URL getConfigurationLocation();
-
- /**
- * Returns a stamp reflecting the current state of the configuration. If called repeatedly,
- * returns the same value as long as no changes were made to the configuration (changes to
- * sites, features or plugins).
- *
- * @return configuration change stamp
- * @since 2.0
- */
- public long getChangeStamp();
-
- /**
- * Returns a stamp reflecting the current state of the features in the configuration.
- * If called repeatedly, returns the same value as long as no changes were made to
- * features in the configuration.
- *
- * @return configuration features change stamp
- * @since 2.0
- */
- public long getFeaturesChangeStamp();
-
- /**
- * Returns a stamp reflecting the current state of the plug-ins in the configuration.
- * If called repeatedly, returns the same value as long as no changes were made to
- * plug-ins in the configuration.
- *
- * @return configuration plug-ins change stamp
- * @since 2.0
- */
- public long getPluginsChangeStamp();
-
-
-
- /**
- * Returns the identifier of the configured primary feature. A primary feature
- * is used to specify product customization information for a running instance
- * of Eclipse.
- *
- * @return primary feature identifier, or <code>null</code> if none configured
- * @since 2.0
- */
- public String getPrimaryFeatureIdentifier();
-
- /**
- * Computes the plug-in path for this configuration. The result includes all plug-ins
- * visible on each of the configured sites based on each site policy.
- *
- * @return an array of plug-in path elements (full URL entries), or an empty array.
- * @since 2.0
- */
- public URL[] getPluginPath();
-
- /**
- * Returns an array of bootstrap plugin identifiers whose
- * location needs to be explicitly identified in the configuration.
- *
- * @return an array of identifiers, or empty array
- * otherwise
- * @since 2.0
- */
- public String[] getBootstrapPluginIdentifiers();
-
- /**
- * Sets the location of a bootstrap plugin.
- *
- * @see IPlatformConfiguration#getBootstrapPluginIdentifiers()
- * @param id plugin identifier. Must match one of the entries returned
- * by getBootstrapPluginIdentifiers()
- * @param location
- * @since 2.0
- */
- public void setBootstrapPluginLocation(String id, URL location);
-
- /**
- * Returns an indication whether the configuration can be updated.
- *
- * @return <code>true</code> if configuration can be updated, <code>false</code>
- * otherwise
- * @since 2.0
- */
- public boolean isUpdateable();
-
- /**
- * Returns an indication whether the configuration is transient. A transient
- * configuration typically represents a scenario where the configuration
- * was computed for a single instantiation of the platform and is not
- * guaranteed to be valid on subsequent instantiations.
- *
- * @return <code>true</code> if configuration is transient, <code>false</code>
- * otherwise
- * @since 2.0
- */
- public boolean isTransient();
-
- /**
- * Indicates whether the configuration is transient or not. A transient
- * configuration typically represents a scenario where the configuration
- * was computed for a single instantiation of the platform and is not
- * guaranteed to be valid on subsequent instantiations. This method has
- * no effect if called on the current platform configuration.
- *
- * @see BootLoader#getCurrentPlatformConfiguration()
- * @param value <code>true</code> if configuration is transient, <code>false</code>
- * otherwise
- * @since 2.0
- */
- public void isTransient(boolean value);
-
- /**
- * Called to refresh the configuration information. In particular,
- * causes change stamps to be recomputed based on the current
- * configuration state, and updates the lists of available plug-ins.
- * @since 2.0
- */
- public void refresh();
-
- /**
- * Called to save the configuration information
- * @since 2.0
- */
- public void save() throws IOException;
-
- /**
- * Called to save the configuration information in the
- * specified location
- *
- * @param url save location.
- * @since 2.0
- */
- public void save(URL url) throws IOException;
-
-}
-
diff --git a/bundles/org.eclipse.core.boot/src/org/eclipse/core/boot/IPlatformRunnable.java b/bundles/org.eclipse.core.boot/src/org/eclipse/core/boot/IPlatformRunnable.java
deleted file mode 100644
index a02fd39..0000000
--- a/bundles/org.eclipse.core.boot/src/org/eclipse/core/boot/IPlatformRunnable.java
+++ /dev/null
@@ -1,38 +0,0 @@
-package org.eclipse.core.boot;
-
-/*
- * (c) Copyright IBM Corp. 2000, 2001.
- * All Rights Reserved.
- */
-
-/**
- * Bootstrap type for the platform. Platform runnables represent executable
- * entry points into plug-ins. Runnables can be configured into the Platform's
- * <code>org.eclipse.core.runtime.applications</code> extension-point
- * or be made available through code or extensions on other plug-in's extension-points.
- *
- * <p>
- * Clients may implement this interface.
- * </p>
- */
-public interface IPlatformRunnable {
-
-/**
- * Exit object indicating normal termination
- */
-public static final Integer EXIT_OK = new Integer(0);
-
-/**
- * Exit object requesting platform restart
- */
-public static final Integer EXIT_RESTART = new Integer(23);
-
-/**
- * Runs this runnable with the given args and returns a result.
- * The content of the args is unchecked and should conform to the expectations of
- * the runnable being invoked. Typically this is a <code>String<code> array.
- *
- * @exception Exception if there is a problem running this runnable.
- */
-public Object run(Object args) throws Exception;
-}
diff --git a/bundles/org.eclipse.core.boot/src/org/eclipse/core/boot/package.html b/bundles/org.eclipse.core.boot/src/org/eclipse/core/boot/package.html
deleted file mode 100644
index d87fdf3..0000000
--- a/bundles/org.eclipse.core.boot/src/org/eclipse/core/boot/package.html
+++ /dev/null
@@ -1,22 +0,0 @@
-<!doctype html public "-//w3c//dtd html 4.0 transitional//en">
-<html>
-<head>
- <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
- <meta name="Author" content="IBM">
- <meta name="GENERATOR" content="Mozilla/4.75 [en] (Windows NT 5.0; U) [Netscape]">
- <title>Package-level Javadoc</title>
-</head>
-<body>
-Provides basic support for launching the Eclipse Platform.
-<h2>
-Package Specification</h2>
-The Eclipse Platform makes heavy use of Java class loaders for loading
-plug-ins. Even the Platform Core Runtime itself, including the <tt>Platform</tt>
-class, needs to be loaded by a special class loader. The upshot is that
-a client program (such as a Java main program, a servlet) cannot directly
-reference even the <tt>Platform</tt> class. Instead, a client must use
-a boot loader (provided here) for initializing the platform, invoking functionality
-defined in plug-ins, and shutting down the platform when done.
-<br>
-</body>
-</html>
diff --git a/bundles/org.eclipse.core.boot/src/org/eclipse/core/internal/boot/DelegatingURLClassLoader.java b/bundles/org.eclipse.core.boot/src/org/eclipse/core/internal/boot/DelegatingURLClassLoader.java
deleted file mode 100644
index 16dd767..0000000
--- a/bundles/org.eclipse.core.boot/src/org/eclipse/core/internal/boot/DelegatingURLClassLoader.java
+++ /dev/null
@@ -1,823 +0,0 @@
-package org.eclipse.core.internal.boot;
-
-/*
- * (c) Copyright IBM Corp. 2000, 2001.
- * All Rights Reserved.
- */
-
-import java.net.*;
-import java.util.*;
-import java.io.*;
-import java.security.CodeSource;
-import java.security.ProtectionDomain;
-import org.eclipse.core.boot.BootLoader;
-import com.ibm.oti.vm.VM;
-
-public abstract class DelegatingURLClassLoader extends URLClassLoader {
-
- // loader base
- protected URL base;
-
- // delegation chain
- protected DelegateLoader[] imports = null;
-
- // extra resource class loader
- protected URLClassLoader resourceLoader = null;
-
- // filter table
- private Hashtable filterTable = new Hashtable();
-
- // development mode class path additions
- public static String devClassPath = null;
-
- // control class load tracing
- public static boolean DEBUG = false;
- public static boolean DEBUG_SHOW_CREATE = true;
- public static boolean DEBUG_SHOW_ACTIVATE = true;
- public static boolean DEBUG_SHOW_ACTIONS = true;
- public static boolean DEBUG_SHOW_SUCCESS = true;
- public static boolean DEBUG_SHOW_FAILURE = true;
- public static String[] DEBUG_FILTER_CLASS = new String[0];
- public static String[] DEBUG_FILTER_LOADER = new String[0];
- public static String[] DEBUG_FILTER_RESOURCE = new String[0];
- public static String[] DEBUG_FILTER_NATIVE = new String[0];
-
- public static final String PLUGIN = "plugin";
-
- private static boolean isHotSwapEnabled = InternalBootLoader.inDevelopmentMode() & ((VM.class.getModifiers() & java.lang.reflect.Modifier.ABSTRACT) == 0);
-
- private static String[] JAR_VARIANTS = buildJarVariants();
- private static String[] LIBRARY_VARIANTS = buildLibraryVariants();
-
- // DelegateLoader. Represents a single class loader this loader delegates to.
- protected static class DelegateLoader {
-
- private DelegatingURLClassLoader loader;
- private boolean isExported;
-
- public DelegateLoader(DelegatingURLClassLoader loader, boolean isExported) {
- this.loader = loader;
- this.isExported = isExported;
- }
-
- public Class loadClass(String name, DelegatingURLClassLoader current, DelegatingURLClassLoader requestor, Vector seen) {
- if (isExported || current == requestor)
- return loader.loadClass(name, false, requestor, seen, false);
- else
- return null;
- }
-
- public URL findResource(String name, DelegatingURLClassLoader current, DelegatingURLClassLoader requestor, Vector seen) {
- if (isExported || current == requestor)
- return loader.findResource(name, requestor, seen);
- else
- return null;
- }
- public Enumeration findResources(String name, DelegatingURLClassLoader current, DelegatingURLClassLoader requestor, Vector seen) {
- if (isExported || current == requestor)
- return loader.findResources(name, requestor, seen);
- else
- return null;
- }
- }
-
- // unchecked DelegatingLoaderException
- protected static class DelegatingLoaderException extends RuntimeException {
- Exception e = null;
-
- public DelegatingLoaderException() {
- super();
- }
-
- public DelegatingLoaderException(String message) {
- super(message);
- }
-
- public DelegatingLoaderException(String message, Exception e) {
- super(message);
- this.e = e;
- }
-
- public Throwable getException() {
- return e;
- }
-
- public void printStackTrace() {
- printStackTrace(System.err);
- }
-
- public void printStackTrace(PrintStream output) {
- synchronized (output) {
- if (e != null) {
- output.print("org.eclipse.core.internal.boot.DelegatingLoaderException: ");
- e.printStackTrace(output);
- } else
- super.printStackTrace(output);
- }
- }
-
- public void printStackTrace(PrintWriter output) {
- synchronized (output) {
- if (e != null) {
- output.print("org.eclipse.core.internal.boot.DelegatingLoaderException: ");
- e.printStackTrace(output);
- } else
- super.printStackTrace(output);
- }
- }
- }
-
-private static String[] buildJarVariants() {
- ArrayList result = new ArrayList();
-
- result.add("ws/" + InternalBootLoader.getWS() + "/");
- result.add("os/" + InternalBootLoader.getOS() + "/" + InternalBootLoader.getOSArch() + "/");
- result.add("os/" + InternalBootLoader.getOS() + "/");
- String nl = InternalBootLoader.getNL();
- nl = nl.replace('_', '/');
- while (nl.length() > 0) {
- result.add("nl/" + nl + "/");
- int i = nl.lastIndexOf('/');
- nl = (i < 0) ? "" : nl.substring(0, i);
- }
- result.add("");
- return (String[])result.toArray(new String[result.size()]);
-}
-
-private static String[] buildLibraryVariants() {
- ArrayList result = new ArrayList();
-
- result.add("ws/" + InternalBootLoader.getWS() + "/");
- result.add("os/" + InternalBootLoader.getOS() + "/" + InternalBootLoader.getOSArch() + "/");
- result.add("os/" + InternalBootLoader.getOS() + "/");
- String nl = InternalBootLoader.getNL();
- nl = nl.replace('_', '/');
- while (nl.length() > 0) {
- result.add("nl/" + nl + "/");
- int i = nl.lastIndexOf('/');
- nl = (i < 0) ? "" : nl.substring(0, i);
- }
- result.add ("");
- return (String[])result.toArray(new String[result.size()]);
-}
-
-public DelegatingURLClassLoader(URL[] codePath, URLContentFilter[] codeFilters, URL[] resourcePath, URLContentFilter[] resourceFilters, ClassLoader parent) {
-
-// Instead of constructing the loader with supplied classpath, create loader
-// with empty path, "fix up" jar entries and then explicitly add the classpath
-// to the newly constructed loader
-
- super(mungeJarURLs (codePath), parent);
- resourcePath = mungeJarURLs(resourcePath);
-
- if (resourcePath != null && resourcePath.length > 0)
- resourceLoader = new ResourceLoader(resourcePath);
-
- if (codePath != null) {
- if (codeFilters == null || codeFilters.length != codePath.length)
- throw new DelegatingLoaderException();
- setHotSwapPath(this, codePath);
- for (int i = 0; i < codePath.length; i++) {
- if (codeFilters[i] != null)
- filterTable.put(codePath[i], codeFilters[i]);
- }
- }
- if (resourcePath != null) {
- if (resourceFilters == null || resourceFilters.length != resourcePath.length)
- throw new DelegatingLoaderException();
- for (int i = 0; i < resourcePath.length; i++) {
- if (resourceFilters[i] != null)
- filterTable.put(resourcePath[i], resourceFilters[i]);
- }
- }
-}
-
-/**
- * This method is to be used internally only for adding the proper class path and resource path
- * entries to the class loaders for Runtime and Xerces. They are special cases since they need
- * to be brought up before everything else. (and before the registry is loaded)
- */
-public void addURLs(URL[] codePath, URLContentFilter[] codeFilters, URL[] resourcePath, URLContentFilter[] resourceFilters) {
- Set keys = filterTable.keySet();
-
- codePath = mungeJarURLs(codePath);
- resourcePath = mungeJarURLs(resourcePath);
- if (resourcePath != null && resourcePath.length > 0)
- resourceLoader = new ResourceLoader(resourcePath);
-
- if (codePath != null) {
- if (codeFilters == null || codeFilters.length != codePath.length)
- throw new DelegatingLoaderException();
- setHotSwapPath(this, codePath);
- for (int i=0; i<codePath.length; i++) {
- URL path = codePath[i];
- if (!keys.contains(path)) {
- addURL(path);
- filterTable.put(path, codeFilters[i]);
- }
- }
- }
-
- if (resourcePath != null) {
- if (resourceFilters == null || resourceFilters.length != resourcePath.length)
- throw new DelegatingLoaderException();
- for (int i = 0; i < resourcePath.length; i++) {
- URL path = resourcePath[i];
- if (resourceFilters[i] != null && !keys.contains(path))
- filterTable.put(path, resourceFilters[i]);
- }
- }
-}
-
-/**
- * strip-off jar: protocol
- */
-private static URL mungeJarURL(URL url) {
- if (url.getProtocol().equals("jar")) {
- String file = url.getFile();
- if (file.startsWith("file:") || file.startsWith("valoader:")) {
- int ix = file.indexOf("!/");
- if (ix != -1) file = file.substring(0,ix);
- try {
- url = new URL(file);
- } catch (MalformedURLException e) {
- // just use the original if we cannot create a new one
- }
- }
- }
- return url;
-}
-
-private static URL[] mungeJarURLs(URL[] urls) {
- if (urls == null)
- return null;
- for (int i = 0; i < urls.length; i++)
- urls[i] = mungeJarURL(urls[i]);
- return urls;
-}
-
-/**
- * Returns the given class or <code>null</code> if the class is not visible to the
- * given requestor. The <code>inCache</code> flag controls how this action is
- * reported if in debug mode.
- */
-protected Class checkClassVisibility(Class result, DelegatingURLClassLoader requestor, boolean inCache) {
- if (result == null)
- return null;
- if (isClassVisible(result, requestor)) {
- if (DEBUG && DEBUG_SHOW_SUCCESS && debugClass(result.getName()))
- debug("found " + result.getName() + " in " + (inCache ? "cache" : getURLforClass(result).toExternalForm()));
- } else {
- if (DEBUG && DEBUG_SHOW_ACTIONS && debugClass(result.getName()))
- debug("skip " + result.getName() + " in " + (inCache ? "cache" : getURLforClass(result).toExternalForm()));
- return null;
- }
- return result;
-}
-/**
- * Returns the given resource URL or <code>null</code> if the resource is not visible to the
- * given requestor.
- */
-protected URL checkResourceVisibility(String name, URL result, DelegatingURLClassLoader requestor) {
- if (result == null)
- return null;
- if (isResourceVisible(name, result, requestor)) {
- if (DEBUG && DEBUG_SHOW_SUCCESS && debugResource(name))
- debug("found " + result);
- } else {
- if (DEBUG && DEBUG_SHOW_ACTIONS && debugResource(name))
- debug("skip " + result);
- result = null;
- }
- return result;
-}
-protected void debug(String s) {
-
- System.out.println(toString()+"^"+Integer.toHexString(Thread.currentThread().hashCode())+" "+s);
-}
-protected boolean debugClass(String name) {
-
- if (debugLoader()) {
- return debugMatchesFilter(name,DEBUG_FILTER_CLASS);
- }
- return false;
-}
-protected void debugConstruction() {
- if (DEBUG && DEBUG_SHOW_CREATE && debugLoader()) {
- URL[] urls = getURLs();
- debug("Class Loader Created");
- debug("> baseURL=" + base);
- if (urls == null || urls.length == 0)
- debug("> empty search path");
- else {
- URLContentFilter filter;
- for (int i = 0; i < urls.length; i++) {
- debug("> searchURL=" + urls[i].toString());
- filter = (URLContentFilter) filterTable.get(urls[i]);
- if (filter != null)
- debug("> export=" + filter.toString());
- }
- }
- }
-}
-protected String debugId() {
- return "";
-}
-protected boolean debugLoader() {
-
- return debugMatchesFilter(debugId(),DEBUG_FILTER_LOADER);
-}
-private boolean debugMatchesFilter(String name, String[] filter) {
-
- if (filter.length==0) return false;
-
- for (int i=0; i<filter.length; i++) {
- if (filter[i].equals("*")) return true;
- if (name.startsWith(filter[i])) return true;
- }
- return false;
-}
-protected boolean debugNative(String name) {
-
- if (debugLoader()) {
- return debugMatchesFilter(name,DEBUG_FILTER_NATIVE);
- }
- return false;
-}
-protected boolean debugResource(String name) {
-
- if (debugLoader()) {
- return debugMatchesFilter(name,DEBUG_FILTER_RESOURCE);
- }
- return false;
-}
-protected void enableHotSwap(ClassLoader cl, Class clazz) {
- if (isHotSwapEnabled)
- VM.enableClassHotSwap(clazz);
-}
-/**
- * Looks for the requested class in the parent of this loader using
- * standard Java protocols. If the parent is null then the system class
- * loader is consulted. <code>null</code> is returned if the class could
- * not be found.
- */
-protected Class findClassParents(String name, boolean resolve) {
- try {
- ClassLoader parent = getParent();
- if (parent == null)
- return findSystemClass(name);
- return parent.loadClass(name);
- } catch (ClassNotFoundException e) {
- }
- return null;
-}
-/**
- * Finds and loads the class with the specified name from the URL search
- * path. Any URLs referring to JAR files are loaded and opened as needed
- * until the class is found. Search on the parent chain and then self.
- *
- * Subclasses should implement this method.
- *
- * @param name the name of the class
- * @param resolve whether or not to resolve the class if found
- * @param requestor class loader originating the request
- * @param checkParents whether the parent of this loader should be consulted
- * @return the resulting class
- */
-protected abstract Class findClassParentsSelf(String name, boolean resolve, DelegatingURLClassLoader requestor, boolean checkParents);
-/**
- * Finds and loads the class with the specified name from the URL search
- * path. Any URLs referring to JAR files are loaded and opened as needed
- * until the class is found. This method consults only the platform class loader.
- *
- * @param name the name of the class
- * @param resolve whether or not to resolve the class if found
- * @param requestor class loader originating the request
- * @param checkParents whether the parent of this loader should be consulted
- * @return the resulting class
- */
-protected Class findClassPlatform(String name, boolean resolve, DelegatingURLClassLoader requestor, boolean checkParents) {
- DelegatingURLClassLoader platform = PlatformClassLoader.getDefault();
- if (this == platform)
- return null;
- return platform.findClassParentsSelf(name, resolve, requestor, false);
-}
-/**
- * Finds and loads the class with the specified name from the URL search
- * path. Any URLs referring to JAR files are loaded and opened as needed
- * until the class is found. This method considers only the classes loadable
- * by its explicit prerequisite loaders.
- *
- * @param name the name of the class
- * @param requestor class loader originating the request
- * @param seen list of delegated class loaders already searched
- * @return the resulting class
- */
-protected Class findClassPrerequisites(final String name, DelegatingURLClassLoader requestor, Vector seen) {
- if (imports == null)
- return null;
- if (seen == null)
- seen = new Vector(); // guard against delegation loops
- seen.addElement(this);
- // Grab onto the imports value to protect against concurrent write.
- DelegateLoader[] loaders = imports;
- for (int i = 0; i < loaders.length; i++) {
- Class result = loaders[i].loadClass(name, this, requestor, seen);
- if (result != null)
- return result;
- }
- return null;
-}
-/**
- * Finds the resource with the specified name on the URL search path.
- * This method is used specifically to find the file containing a class to verify
- * that the class exists without having to load it.
- * Returns a URL for the resource. Searches only this loader's classpath.
- * <code>null</code> is returned if the resource cannot be found.
- *
- * @param name the name of the resource
- */
-protected URL findClassResource(String name) {
- return super.findResource(name);
-}
-/**
- * Returns the absolute path name of a native library. The VM
- * invokes this method to locate the native libraries that belong
- * to classes loaded with this class loader. If this method returns
- * <code>null</code>, the VM searches the library along the path
- * specified as the <code>java.library.path</code> property.
- *
- * @param libname the library name
- * @return the absolute path of the native library
- */
-protected String findLibrary(String libName) {
- if (libName.length() == 0)
- return null;
- if (libName.charAt(0) == '/' || libName.charAt(0) == '\\')
- libName = libName.substring(1);
- libName = System.mapLibraryName(libName);
-
- if (DEBUG && DEBUG_SHOW_ACTIONS && debugNative(libName))
- debug("findLibrary(" + libName + ")");
- if (base == null)
- return null;
- String libFileName = null;
- if (base.getProtocol().equals(PlatformURLHandler.FILE) || base.getProtocol().equals(PlatformURLHandler.VA)) {
- // directly access library
- libFileName = (base.getFile() + libName).replace('/', File.separatorChar);
- } else {
- if (base.getProtocol().equals(PlatformURLHandler.PROTOCOL)) {
- URL[] searchList = getSearchURLs (base);
- if ((searchList != null) && (searchList.length != 0)) {
- URL foundPath = searchVariants(searchList, LIBRARY_VARIANTS, libName);
- if (foundPath != null)
- libFileName = foundPath.getFile();
- }
- }
- }
-
- if (libFileName == null)
- return null;
-
- return new File(libFileName).getAbsolutePath();
-}
-/**
- * Finds the resource with the specified name on the URL search path.
- * Returns a URL for the resource. If resource is not found in own
- * URL search path, delegates search to prerequisite loaders.
- * Null is returned if none of the loaders find the resource.
- *
- * @param name the name of the resource
- */
-public URL findResource(String name) {
- return findResource(name, this, null);
-}
-/**
- * Delegated resource access call.
- * Does not check prerequisite loader parent chain.
- */
-protected URL findResource(String name, DelegatingURLClassLoader requestor, Vector seen) {
- // guard against delegation loops
- if (seen != null && seen.contains(this))
- return null;
-
- if (DEBUG && DEBUG_SHOW_ACTIONS && debugResource(name))
- debug("findResource(" + name + ")");
-
- // check the normal class path for self
- URL result = super.findResource(name);
- result = checkResourceVisibility(name, result, requestor);
- if (result != null)
- return result;
-
- // check our extra resource path if any
- if (resourceLoader != null) {
- result = resourceLoader.findResource(name);
- result = checkResourceVisibility(name, result, requestor);
- if (result != null)
- return result;
- }
-
- // delegate down the prerequisite chain if we haven't found anything yet.
- if (imports != null) {
- if (seen == null)
- seen = new Vector(); // guard against delegation loops
- seen.addElement(this);
- for (int i = 0; i < imports.length && result == null; i++)
- result = imports[i].findResource(name, this, requestor, seen);
- }
- return result;
-}
-/**
- * Returns an Enumeration of URLs representing all of the resources
- * on the URL search path having the specified name.
- *
- * @param name the resource name
- */
-public Enumeration findResources(String name) throws IOException {
- return findResources(name, this, null);
-}
-/**
- * Delegated call to locate all named resources.
- * Does not check prerequisite loader parent chain.
- */
-private Enumeration findResources(String name, DelegatingURLClassLoader requestor, Vector seen) {
- // guard against delegation loops
- if (seen != null && seen.contains(this))
- return null;
-
- if (DEBUG && DEBUG_SHOW_ACTIONS && debugResource(name))
- debug("findResources(" + name + ")");
-
- // check own URL search path
- Enumeration e = null;
- try {
- e = super.findResources(name);
- } catch (IOException ioe) {
- }
- ResourceEnumeration result = new ResourceEnumeration(name, e, this, requestor);
-
- // delegate down the prerequisite chain
- if (imports != null) {
- if (seen == null)
- seen = new Vector(); // guard against delegation loops
- seen.addElement(this);
- for (int i = 0; i < imports.length; i++)
- result.add(imports[i].findResources(name, this, requestor, seen));
- }
-
- return result;
-}
-protected String getFileFromURL(URL target) {
- try {
- URL url = InternalBootLoader.resolve(target);
- String protocol = url.getProtocol();
- // check only for the file protocol here. Not interested in Jar files.
- if (protocol.equals(PlatformURLHandler.FILE))
- return url.getFile();
- } catch (IOException e) {
- }
- return null;
-}
-private File[] getNativeLibraryAsLocal(String osname) {
- URL[] tempResult = null;
- File[] result = null;
-
- try {
- URL liburl = new URL(base, osname);
- PlatformURLConnection c = (PlatformURLConnection) liburl.openConnection();
- URL localName = c.getURLAsLocal();
- tempResult = c.getAuxillaryURLs();
- int tempLength = (tempResult == null) ? 0 : tempResult.length;
-
- result = new File[tempLength + 1];
- result[0] = new File(localName.getFile());
-
- // Now add the fragment URLs to the result
- for (int i = 1; i < result.length; i++) {
- liburl = new URL(tempResult[i-1], osname);
- c = (PlatformURLConnection) liburl.openConnection();
- localName = c.getURLAsLocal();
- result[i] = new File(localName.getFile());
- }
- } catch (IOException e) {
- // Why don't we do anything with this exception??
- }
-
- return result;
-}
-
-private URL[] getSearchURLs (URL base) {
- URL[] auxList = null;
- ArrayList result = new ArrayList();
-
- PlatformURLConnection c = null;
- try {
- c = (PlatformURLConnection) base.openConnection();
- result.add(c.getURLAsLocal());
- } catch (IOException e) {
- // Catch intentionally left empty. Skip
- // poorly formed URLs
- }
-
- try {
- auxList = c.getAuxillaryURLs();
- int auxLength = (auxList == null) ? 0 : auxList.length;
-
- // Now add the fragment URLs to the result
- for (int i = 0; i < auxLength; i++) {
- try {
- c = (PlatformURLConnection) auxList[i].openConnection();
- result.add(c.getURLAsLocal());
- } catch (IOException e) {
- // Catch intentionally left empty. Skip
- // poorly formed URLs
- }
- }
- } catch (IOException e) {
- // Catch intentionally left empty. Skip
- // poorly formed URLs
- }
-
- return (URL[])result.toArray(new URL[result.size()]);
-}
-
-private URL searchVariants (URL[] basePaths, String[] variants, String path) {
- // This method assumed basePaths are 'resolved' URLs
- for (int i = 0; i < variants.length; i++) {
- for (int j = 0; j < basePaths.length; j++) {
- String fileName = basePaths[j].getFile() + variants[i] + path;
- File file = new File(fileName);
- if (!file.exists()) {
- if (DEBUG && DEBUG_SHOW_FAILURE)
- debug("not found " + file.getAbsolutePath());
- } else {
- if (DEBUG && DEBUG_SHOW_SUCCESS)
- debug("found " + path + " as " + file.getAbsolutePath());
- try {
- return new URL ("file:" + fileName);
- } catch (MalformedURLException e) {
- // Intentionally ignore this exception
- // so we continue looking for a matching
- // URL.
- }
- }
- }
- }
- return null;
-}
-public URL getResource(String name) {
- if (DEBUG && DEBUG_SHOW_ACTIONS && debugResource(name))
- debug("getResource(" + name + ")");
-
- URL result = super.getResource(name);
- if (result == null) {
- if (DEBUG && DEBUG_SHOW_FAILURE && debugResource(name))
- debug("not found " + name);
- }
- return result;
-}
-private URL getURLforClass(Class clazz) {
- ProtectionDomain pd = clazz.getProtectionDomain();
- if (pd != null) {
- CodeSource cs = pd.getCodeSource();
- if (cs != null)
- return cs.getLocation();
- }
- if (DEBUG && DEBUG_SHOW_ACTIONS && debugClass(clazz.getName()))
- debug("*** " + clazz.getName());
- return null;
-}
-public void initializeImportedLoaders() {
-}
-/**
- * check to see if class is visible (exported)
- */
-boolean isClassVisible(Class clazz, DelegatingURLClassLoader requestor) {
- URL lib = getURLforClass(clazz);
- if (lib == null)
- return true; // have a system class (see comment below)
-
- URLContentFilter filter = (URLContentFilter) filterTable.get(lib);
- if (filter == null) {
- // This code path is being executed because some VMs (eg. Sun JVM)
- // return from the class cache classes that were not loaded
- // by this class loader. Consequently we do not find the
- // corresponding jar filter. This appears to be a performance
- // optimization that we are defeating with our filtering scheme.
- // We return the class if it is a system class (see above). Otherwise
- // we reject the class which caused the load to be
- // delegated down the prerequisite chain until we find the
- // correct loader.
- if (DEBUG && DEBUG_SHOW_ACTIONS && debugClass(clazz.getName()))
- debug("*** Unable to find library filter for " + clazz.getName() + " from " + lib);
- return false;
- } else
- return filter.isClassVisible(clazz, this, requestor);
-}
-/**
- * check to see if resource is visible (exported)
- */
-boolean isResourceVisible(String name, URL resource, DelegatingURLClassLoader requestor) {
- URL lib = null;
- String file = resource.getFile();
- try {
- lib = new URL(resource.getProtocol(), resource.getHost(), file.substring(0, file.length() - name.length()));
- } catch (MalformedURLException e) {
- if (DEBUG)
- debug("Unable to determine resource lib for " + name + " from " + resource);
- return false;
- }
-
- URLContentFilter filter = (URLContentFilter) filterTable.get(lib);
- // retry with non-jar URL if necessary
- if (filter == null) filter = (URLContentFilter) filterTable.get(mungeJarURL(lib));
- if (filter == null) {
- if (DEBUG)
- debug("Unable to find library filter for " + name + " from " + lib);
- return false;
- } else
- return filter.isResourceVisible(name, this, requestor);
-}
-/**
- * Non-delegated load call. This method is not synchronized. Implementations of
- * findClassParentsSelf, and perhaps others, should synchronize themselves as
- * required. Synchronizing this method is too coarse-grained. It results in plugin
- * activation being synchronized and may cause deadlock.
- */
-protected Class loadClass(String name, boolean resolve) throws ClassNotFoundException {
- if (DEBUG && DEBUG_SHOW_ACTIONS && debugClass(name))
- debug("loadClass(" + name + ")");
- Class result = loadClass(name, resolve, this, null, true);
- if (result == null) {
- if (DEBUG && DEBUG_SHOW_FAILURE && debugClass(name))
- debug("not found " + name);
- throw new ClassNotFoundException(name);
- }
- return result;
-}
-/**
- * Delegated load call. This method is not synchronized. Implementations of
- * findClassParentsSelf, and perhaps others, should synchronize themselves as
- * required. Synchronizing this method is too coarse-grained. It results in plugin
- * activation being synchronized and may cause deadlock.
- */
-private Class loadClass(String name, boolean resolve, DelegatingURLClassLoader requestor, Vector seen, boolean checkParents) {
- // guard against delegation loops
- if (seen != null && seen.contains(this))
- return null;
-
- // look in the parents and self
- Class result = findClassParentsSelf(name, resolve, requestor, checkParents);
-
- // search platform
- if (result == null)
- result = findClassPlatform(name, resolve, requestor, false);
-
- // search prerequisites
- if (result == null)
- result = findClassPrerequisites(name, requestor, seen);
-
- // if we found a class, consider resolving it
- if (result != null && resolve)
- resolveClass(result);
-
- return result;
-}
-private void setHotSwapPath(ClassLoader cl, URL[] urls) {
- if (!isHotSwapEnabled)
- return;
- StringBuffer path = new StringBuffer();
- for(int i = 0; i < urls.length; i++) {
- String file = getFileFromURL (urls[i]);
- if (file != null) {
- if (file.charAt(0) == '/')
- file = file.substring(1, file.length());
- if (file.charAt(file.length() - 1) == '/')
- file = file.substring(0, file.length() - 1);
- if (path.length() > 0)
- path.append(";");
- path.append(file);
- }
- }
- if (path.length() > 0)
- VM.setClassPathImpl(cl, path.toString());
-}
-protected void setImportedLoaders(DelegateLoader[] loaders) {
-
- imports = loaders;
-
- if(DEBUG && DEBUG_SHOW_CREATE && debugLoader()) {
- debug("Imports");
- if (imports==null || imports.length==0) debug("> none");
- else {
- for (int i=0; i<imports.length; i++) {
- debug("> " + imports[i].loader.toString() + " export=" + imports[i].isExported);
- }
- }
- }
-}
-public String toString() {
- return "Loader [" + debugId() + "]";
-}
-}
diff --git a/bundles/org.eclipse.core.boot/src/org/eclipse/core/internal/boot/InternalBootLoader.java b/bundles/org.eclipse.core.boot/src/org/eclipse/core/internal/boot/InternalBootLoader.java
deleted file mode 100644
index 1cb8403..0000000
--- a/bundles/org.eclipse.core.boot/src/org/eclipse/core/internal/boot/InternalBootLoader.java
+++ /dev/null
@@ -1,895 +0,0 @@
-package org.eclipse.core.internal.boot;
-
-/*
- * (c) Copyright IBM Corp. 2000, 2001.
- * All Rights Reserved.
- */
-
-import java.io.*;
-import java.lang.reflect.InvocationTargetException;
-import java.lang.reflect.Method;
-import java.net.*;
-import java.util.*;
-
-import org.eclipse.core.boot.*;
-
-/**
- * Special boot loader class for the Eclipse Platform. This class cannot
- * be instantiated; all functionality is provided by static methods.
- * <p>
- * The Eclipse Platform makes heavy use of Java class loaders for
- * loading plug-ins. Even the Platform Core Runtime itself, including
- * the <code>Platform</code> class, needs to be loaded by a special
- * class loader. The upshot is that a client program (such as a Java main
- * program, a servlet) cannot directly reference even the
- * <code>Platform</code> class. Instead, a client must use this
- * loader class for initializing the platform, invoking functionality
- * defined in plug-ins, and shutting down the platform when done.
- * </p>
- *
- * @see org.eclipse.core.runtime.Platform
- */
-public final class InternalBootLoader {
- private static boolean running = false;
- private static boolean starting = false;
- private static String[] commandLine;
- private static ClassLoader loader = null;
- private static String baseLocation = null;
- private static String applicationR10 = null; // R1.0 compatibility
- private static URL installURL = null;
- private static boolean debugRequested = false;
- private static boolean usage = false;
- private static String devClassPath = null;
- private static String debugOptionsFilename = null;
- private static Properties options = null;
- private static boolean inDevelopmentMode = false;
- private static PlatformConfiguration currentPlatformConfiguration = null;
-
- // state for tracking the Platform context (e.g., the OS, Window system, locale, architecture, ...)
- private static String nl = null;
- private static String ws = null;
- private static String os = null;
- private static String arch = null;
- private static final String[] OS_LIST = { BootLoader.OS_WIN32, BootLoader.OS_LINUX, BootLoader.OS_AIX, BootLoader.OS_SOLARIS, BootLoader.OS_HPUX, BootLoader.OS_QNX };
-
- private static final String PLATFORM_ENTRYPOINT = "org.eclipse.core.internal.runtime.InternalPlatform";
- private static final String BOOTNAME = "org.eclipse.core.boot";
- private static final String RUNTIMENAME = "org.eclipse.core.runtime";
- private static final String PLUGINSDIR = "plugins/";
- private static final String LIBRARY = "library";
- private static final String EXPORT = "export";
- private static final String EXPORT_PUBLIC = "public";
- private static final String EXPORT_PROTECTED = "protected";
- private static final String META_AREA = ".metadata";
- private static final String WORKSPACE = "workspace";
- private static final String PLUGIN_PATH = ".plugin-path";
- private static final String BOOTDIR = PLUGINSDIR + BOOTNAME + "/";
- private static final String RUNTIMEDIR = PLUGINSDIR + RUNTIMENAME + "/";
- private static final String OPTIONS = ".options";
- // While we recognize the SunOS operating system, we change
- // this internally to be Solaris.
- private static final String INTERNAL_OS_SUNOS = "SunOS";
- // While we recognize the i386 architecture, we change
- // this internally to be x86.
- private static final String INTERNAL_ARCH_I386 = "i386";
-
- /**
- * Execution options for the Runtime plug-in. They are defined here because
- * we need to load them into the PlatformClassLoader which is created by the
- * boot system. Users should see these options as Runtime options since there
- * boot does not figure into normal Platform operation.
- */
- private static final String PI_RUNTIME = "org.eclipse.core.runtime";
- private static final String OPTION_STARTTIME = PI_RUNTIME + "/starttime";
- private static final String OPTION_LOADER_DEBUG = PI_RUNTIME + "/loader/debug";
- private static final String OPTION_LOADER_SHOW_CREATE = PI_RUNTIME + "/loader/debug/create";
- private static final String OPTION_LOADER_SHOW_ACTIVATE = PI_RUNTIME + "/loader/debug/activateplugin";
- private static final String OPTION_LOADER_SHOW_ACTIONS = PI_RUNTIME + "/loader/debug/actions";
- private static final String OPTION_LOADER_SHOW_SUCCESS = PI_RUNTIME + "/loader/debug/success";
- private static final String OPTION_LOADER_SHOW_FAILURE = PI_RUNTIME + "/loader/debug/failure";
- private static final String OPTION_LOADER_FILTER_CLASS = PI_RUNTIME + "/loader/debug/filter/class";
- private static final String OPTION_LOADER_FILTER_LOADER = PI_RUNTIME + "/loader/debug/filter/loader";
- private static final String OPTION_LOADER_FILTER_RESOURCE = PI_RUNTIME + "/loader/debug/filter/resource";
- private static final String OPTION_LOADER_FILTER_NATIVE = PI_RUNTIME + "/loader/debug/filter/native";
- private static final String OPTION_URL_DEBUG = PI_RUNTIME+ "/url/debug";
- private static final String OPTION_URL_DEBUG_CONNECT = PI_RUNTIME+ "/url/debug/connect";
- private static final String OPTION_URL_DEBUG_CACHE_LOOKUP = PI_RUNTIME+ "/url/debug/cachelookup";
- private static final String OPTION_URL_DEBUG_CACHE_COPY = PI_RUNTIME+ "/url/debug/cachecopy";
- private static final String OPTION_UPDATE_DEBUG = PI_RUNTIME+ "/update/debug";
- private static final String OPTION_CONFIGURATION_DEBUG = PI_RUNTIME+ "/config/debug";
-
- // command line arguments
- private static final String DEBUG = "-debug";
- private static final String PLATFORM = "-platform";
- private static final String DATA = "-data";
- private static final String DEV = "-dev";
- private static final String WS = "-ws";
- private static final String OS = "-os";
- private static final String ARCH = "-arch";
- private static final String NL = "-nl";
- private static final String USAGE = "-?";
-
- // Development mode constants
- private static final String PLUGIN_JARS = "plugin.jars";
- private static final String VA_PROPERTIES = ".va.properties";
- private static final String KEY_LIBRARY = "library";
- private static final String KEY_EXPORT = "export";
- private static final String KEY_PROJECT = "projects";
-
- private static boolean inVAJ;
- static {
- try {
- Class.forName("com.ibm.uvm.lang.ProjectClassLoader");
- inVAJ = true;
- } catch (Exception e) {
- inVAJ = false;
- }
- }
-
- private static boolean inVAME;
- static {
- try {
- Class.forName("com.ibm.eclipse.core.VAME");
- inVAME = true;
- } catch (Exception e) {
- inVAME = false;
- }
- }
-
-/**
- * Private constructor to block instance creation.
- */
-private InternalBootLoader() {
-}
-private static void assertNotRunning() {
- if (running)
- throw new RuntimeException("The Platform must not be running");
-}
-private static void assertRunning() {
- if (!running)
- throw new RuntimeException("The Platform is not running");
-}
-/**
- * Configure the class loader for the runtime plug-in.
- */
-private static PlatformClassLoader configurePlatformLoader() {
- Object[] loadPath = getPlatformClassLoaderPath();
- URL base = null;
- try {
- base = new URL(PlatformURLBaseConnection.PLATFORM_URL_STRING+RUNTIMEDIR);
- } catch (MalformedURLException e) {
- }
- return new PlatformClassLoader((URL[]) loadPath[0], (URLContentFilter[]) loadPath[1], InternalBootLoader.class.getClassLoader(), base);
-}
-/**
- * @see BootLoader
- */
-public static boolean containsSavedPlatform(String location) {
- return new File(location + "/" + META_AREA).exists();
-}
-/**
- * convert a list of comma-separated tokens into an array
- */
-private static String[] getArrayFromList(String prop) {
- if (prop == null || prop.trim().equals(""))
- return new String[0];
- Vector list = new Vector();
- StringTokenizer tokens = new StringTokenizer(prop, ",");
- while (tokens.hasMoreTokens()) {
- String token = tokens.nextToken().trim();
- if (!token.equals(""))
- list.addElement(token);
- }
- return list.isEmpty() ? new String[0] : (String[]) list.toArray(new String[0]);
-}
-private static boolean getBooleanOption(String option, boolean defaultValue) {
- String optionValue = options.getProperty(option);
- return (optionValue == null) ? defaultValue : optionValue.equalsIgnoreCase("true");
-}
-/**
- * @see BootLoader#getCommandLineArgs
- */
-public static String[] getCommandLineArgs() {
- return commandLine;
-}
-/**
- * @see BootLoader
- */
-public static PlatformConfiguration getCurrentPlatformConfiguration() {
- return PlatformConfiguration.getCurrent();
-}
-/**
- * @see BootLoader
- */
-public static URL getInstallURL() {
- if (installURL != null)
- return installURL;
-
- // Get the location of this class and compute the install location.
- // this involves striping off last element (jar or directory) and adjusting
- // for VAJ/VAME peculiarities.
- URL url = InternalBootLoader.class.getProtectionDomain().getCodeSource().getLocation();
- String path = url.getFile();
- if (path.endsWith("/"))
- path = path.substring(0, path.length() - 1);
- int ix = path.lastIndexOf('/');
- if ((inVAJ || inVAME))
- // in VAJ or VAME strip off one segment (the boot project). Be sure to leave a trailing /
- path = path.substring(0, ix + 1);
- else {
- // in jdk ... strip off boot jar/bin, boot plugin and plugins dir. Be sure to leave a trailing /
- path = path.substring(0, ix);
- ix = path.lastIndexOf('/');
- path = path.substring(0, ix);
- ix = path.lastIndexOf('/');
- path = path.substring(0, ix + 1);
- }
-
- try {
- if (url.getProtocol().equals("jar"))
- installURL = new URL(path);
- else
- installURL = new URL(url.getProtocol(), url.getHost(), url.getPort(), path);
- if (debugRequested)
- System.out.println("Install URL: "+installURL.toExternalForm());
- } catch (MalformedURLException e) {
- throw new RuntimeException("Fatal Error: Unable to determine platform installation URL "+e);
- }
- return installURL;
-}
-
-
-private static String[] getListOption(String option) {
- String filter = options.getProperty(option);
- if (filter == null)
- return new String[0];
- List result = new ArrayList(5);
- StringTokenizer tokenizer = new StringTokenizer(filter, " ,\t\n\r\f");
- while (tokenizer.hasMoreTokens())
- result.add(tokenizer.nextToken());
- return (String[]) result.toArray(new String[result.size()]);
-}
-/**
- * @see BootLoader
- */
-public static String getOSArch() {
- return arch;
-}
-/**
- * @see BootLoader
- */
-public static String getNL() {
- return nl;
-}
-/**
- * @see BootLoader
- */
-public static String getOS() {
- return os;
-}
-/**
- * @see BootLoader
- */
-public static PlatformConfiguration getPlatformConfiguration(URL url) throws IOException {
- return new PlatformConfiguration(url);
-}
-
-private static Object[] getPlatformClassLoaderPath() {
-
- PlatformConfiguration config = getCurrentPlatformConfiguration();
- String execBase = config.getPluginPath(RUNTIMENAME).toExternalForm();
- if (execBase == null)
- execBase = getInstallURL() + RUNTIMEDIR;
-
- String devBase = null;
- Properties jarDefinitions = null;
- if (InternalBootLoader.inVAJ || InternalBootLoader.inVAME) {
- devBase = getInstallURL().toExternalForm();
- jarDefinitions = loadJarDefinitions();
- } else
- devBase = execBase;
-
- // build a list alternating lib spec and export spec
- ArrayList libSpecs = new ArrayList(5);
- String[] exportAll = new String[] { "*" };
-
- // add in any development mode class paths and the export all filter
- if (DelegatingURLClassLoader.devClassPath != null) {
- String[] specs = getArrayFromList(DelegatingURLClassLoader.devClassPath);
- // convert dev class path into url strings
- for (int j = 0; j < specs.length; j++) {
- libSpecs.add(devBase + specs[j] + "/");
- libSpecs.add(exportAll);
- }
- }
- ArrayList list = new ArrayList(5);
- list.add("runtime.jar");
- list.add(exportAll);
-
- // add in the class path entries spec'd in the config. If in development mode,
- // add the entries from the plugin.jars first.
- for (Iterator i = list.iterator(); i.hasNext();) {
- String library = (String) i.next();
- String[] filters = (String[]) i.next();
- // check for jar definitions
- if (jarDefinitions != null) {
- String key = library.substring(library.lastIndexOf('/') + 1);
- String[] specs = getArrayFromList(jarDefinitions.getProperty(key));
- for (int j = 0; j < specs.length; j++) {
- libSpecs.add(devBase + specs[j] + "/");
- libSpecs.add(filters);
- }
- }
-
- // convert plugin.xml library entries to url strings if running in JDK
- if (!(InternalBootLoader.inVAJ || InternalBootLoader.inVAME)) {
- String libSpec = execBase + library.replace(File.separatorChar, '/');
- if (!libSpec.endsWith("/")) {
- if (libSpec.startsWith(PlatformURLHandler.PROTOCOL + PlatformURLHandler.PROTOCOL_SEPARATOR))
- libSpec += PlatformURLHandler.JAR_SEPARATOR;
- else
- libSpec = PlatformURLHandler.JAR + PlatformURLHandler.PROTOCOL_SEPARATOR + libSpec + PlatformURLHandler.JAR_SEPARATOR;
- }
- libSpecs.add(libSpec);
- libSpecs.add(filters);
- }
- }
-
- // create path entries for libraries
- ArrayList urls = new ArrayList(5);
- ArrayList cfs = new ArrayList(5);
- for (Iterator it = libSpecs.iterator(); it.hasNext();) {
- try {
- urls.add(new URL((String) it.next()));
- cfs.add(new URLContentFilter((String[]) it.next()));
- } catch (MalformedURLException e) {
- // skip bad URLs
- }
- }
-
- Object[] result = new Object[2];
- result[0] = urls.toArray(new URL[urls.size()]);
- result[1] = cfs.toArray(new URLContentFilter[cfs.size()]);
- return result;
-}
-/**
- * @see BootLoader
- */
-/*
- * This method is retained for R1.0 compatibility because it is defined as API.
- * It's function matches the API description (returns <code>null</code> when
- * argument URL is <code>null</code> or cannot be read).
- */
-public static URL[] getPluginPath(URL pluginPathLocation/*R1.0 compatibility*/) {
- InputStream input = null;
- // first try and see if the given plugin path location exists.
- if (pluginPathLocation == null)
- return null;
- try {
- input = pluginPathLocation.openStream();
- } catch (IOException e) {
- }
-
- // if the given path was null or did not exist, look for a plugin path
- // definition in the install location.
- if (input == null)
- try {
- URL url = new URL(PlatformURLBaseConnection.PLATFORM_URL_STRING + PLUGIN_PATH);
- input = url.openStream();
- } catch (MalformedURLException e) {
- } catch (IOException e) {
- }
-
- // nothing was found at the supplied location or in the install location
- if (input == null)
- return null;
- // if we found a plugin path definition somewhere so read it and close the location.
- URL[] result = null;
- try {
- try {
- result = readPluginPath(input);
- } finally {
- input.close();
- }
- } catch (IOException e) {
- }
- return result;
-}
-private static URL[] getPluginPathVa(URL[] pluginPath) {
- Vector result = new Vector(Arrays.asList(pluginPath));
- if (inVAME) {
- // check for projects with plugins on Java classpath
- String classpath = System.getProperty("java.class.path");
- StringTokenizer paths = new StringTokenizer(classpath, File.pathSeparator);
- while (paths.hasMoreTokens()) {
- String curr = (String) paths.nextToken();
- if (!curr.endsWith(File.separator))
- curr += File.separator;
- curr += "plugins" + File.separator;
- File dir = new File(curr);
- if (dir.isDirectory()) {
- try {
- result.add(dir.toURL());
- } catch (MalformedURLException e) {
- }
- }
- }
- } else
- if (inVAJ /*disabled*/
- && false) {
- // check for projects with plugins in project_resources
- File pr = new File(getInstallURL().getFile());
- String[] projects = ((projects = pr.list()) == null) ? new String[0] : projects;
- for (int i = 0; i < projects.length; i++) {
- File dir = new File(pr, projects[i] + File.separator + "plugins");
- if (dir.isDirectory()) {
- try {
- result.add(dir.toURL());
- } catch (MalformedURLException e) {
- }
- }
- }
- }
-
- // if there are no new entries, return original plugin path. Otherwise, return the new path
- if (pluginPath.length == result.size())
- return pluginPath;
- else
- return (URL[]) result.toArray(new URL[result.size()]);
-}
-/**
- * @see BootLoader
- */
-public static IPlatformRunnable getRunnable(String applicationName) throws Exception {
- assertRunning();
- Class platform = loader.loadClass(PLATFORM_ENTRYPOINT);
- Method method = platform.getDeclaredMethod("loaderGetRunnable", new Class[] {String.class});
- try {
- return (IPlatformRunnable) method.invoke(platform, new Object[] {applicationName});
- } catch (InvocationTargetException e) {
- if (e.getTargetException() instanceof Error)
- throw (Error) e.getTargetException();
- else
- throw e;
- }
-}
-/**
- * @see BootLoader
- */
-public static IPlatformRunnable getRunnable(String pluginId, String className, Object args) throws Exception {
- assertRunning();
- Class platform = loader.loadClass(PLATFORM_ENTRYPOINT);
- Method method = platform.getDeclaredMethod("loaderGetRunnable", new Class[] {String.class, String.class, Object.class});
- try {
- return (IPlatformRunnable) method.invoke(platform, new Object[] {pluginId, className, args});
- } catch (InvocationTargetException e) {
- if (e.getTargetException() instanceof Error)
- throw (Error) e.getTargetException();
- else
- throw e;
- }
-}
-/**
- * @see BootLoader
- */
-public static String getWS() {
- return ws;
-}
-/**
- * @see BootLoader
- */
-public static boolean inDebugMode() {
- return debugRequested;
-}
-/**
- * @see BootLoader
- */
-public static boolean inDevelopmentMode() {
- return inDevelopmentMode || inVAJ || inVAME;
-}
-private static String[] initialize(URL pluginPathLocation/*R1.0 compatibility*/, String location, String[] args) throws Exception {
- if (running)
- throw new RuntimeException("The platform is already running");
- baseLocation = location;
- String[] appArgs = processCommandLine(args);
- // Do setupSystemContext() ASAP after processCommandLine
- setupSystemContext();
- // setup the devClassPath if any
- DelegatingURLClassLoader.devClassPath = devClassPath;
-
- // if a platform location was not found in the arguments, compute one.
- if (baseLocation == null) {
- if (inVAJ || inVAME) {
- // In VAJ, set user.dir to be <code>eclipse</code> in the parent of the install
- // directory. This typically makes the platform working directory:
- // .../ide/eclipse
- String dir = new File(new File(getInstallURL().getFile()).getParent(), "eclipse").getAbsolutePath();
- System.setProperty("user.dir", dir);
- baseLocation = dir;
- } else {
- // otherwise, use user.dir. If user.dir overlaps with the install dir, then make the
- // location be a workspace subdir of the install location.
- baseLocation = System.getProperty("user.dir");
- URL installURL = resolve(getInstallURL());
- String installLocation = new File(installURL.getFile()).getAbsolutePath();
- if (baseLocation.equals(installLocation))
- baseLocation = new File(installLocation, WORKSPACE).getAbsolutePath();
- }
- }
-
- // load any debug options
- loadOptions();
-
- // initialize eclipse URL handling
- PlatformURLHandlerFactory.startup(baseLocation + File.separator + META_AREA);
- PlatformURLBaseConnection.startup(getInstallURL()); // past this point we can use eclipse:/platform/ URLs
-
- // load platform configuration and consume configuration-related arguments (must call after URL handler initialization)
- appArgs = PlatformConfiguration.startup(appArgs, pluginPathLocation/*R1.0 compatibility*/, applicationR10/*R1.0 compatibility*/);
-
- // create and configure platform class loader
- loader = configurePlatformLoader();
-
- return appArgs;
-}
-/**
- * Returns the complete plugin path.
- * If in development mode, the returned value may have additional VA
- * values added.
- */
-private static URL[] internalGetPluginPath() {
- URL[] result = getCurrentPlatformConfiguration().getPluginPath();
- // augment with additional VA entries if in development mode.
- if (inDevelopmentMode())
- result = getPluginPathVa(result);
- return result;
-}
-/**
- * @see BootLoader
- */
-public static boolean isRunning() {
- return running;
-}
-public static boolean isStarting() {
- return starting;
-}
-
-private static Properties loadJarDefinitions() {
- if (!inDevelopmentMode())
- return null;
- Properties result = null;
- InputStream is;
- try {
- result = new Properties();
- URL props = new URL(getInstallURL(), PLUGINSDIR + RUNTIMENAME + "/" + PLUGIN_JARS);
- is = props.openStream();
- try {
- result.load(is);
- return result;
- } finally {
- is.close();
- }
- } catch (IOException e) {
- result = null;
- }
- return result;
-}
-private static void loadOptions() {
- // if no debug option was specified, don't even bother to try.
- // Must ensure that the options slot is null as this is the signal to the
- // platform that debugging is not enabled.
- if (!debugRequested) {
- options = null;
- return;
- }
- options = new Properties();
- URL optionsFile;
- if (debugOptionsFilename == null)
- debugOptionsFilename = getInstallURL().toExternalForm() + OPTIONS;
- try {
- optionsFile = new URL(debugOptionsFilename);
- } catch (MalformedURLException e) {
- System.out.println("Unable to construct URL for options file: " + debugOptionsFilename);
- e.printStackTrace(System.out);
- return;
- }
- System.out.println("Debug-Options: " + debugOptionsFilename);
- try {
- InputStream input = optionsFile.openStream();
- try {
- options.load(input);
- } finally {
- input.close();
- }
- } catch (FileNotFoundException e) {
- // Its not an error to not find the options file
- } catch (IOException e) {
- System.out.println("Could not parse the options file: " + optionsFile);
- e.printStackTrace(System.out);
- }
- // trim off all the blanks since properties files don't do that.
- for (Iterator i = options.keySet().iterator(); i.hasNext();) {
- Object key = i.next();
- options.put(key, ((String) options.get(key)).trim());
- }
- InternalBootLoader.setupOptions();
-}
-private static String[] processCommandLine(String[] args) throws Exception {
- int[] configArgs = new int[100];
- configArgs[0] = -1; // need to initialize the first element to something that could not be an index.
- int configArgIndex = 0;
- for (int i = 0; i < args.length; i++) {
- boolean found = false;
- // check for args without parameters (i.e., a flag arg)
- // check if debug should be enabled for the entire platform
- // If this is the last arg or there is a following arg (i.e., arg+1 has a leading -),
- // simply enable debug. Otherwise, assume that that the following arg is
- // actually the filename of an options file. This will be processed below.
- if (args[i].equalsIgnoreCase(DEBUG) && ((i + 1 == args.length) || ((i + 1 < args.length) && (args[i + 1].startsWith("-"))))) {
- found = true;
- debugRequested = true;
- }
-
- // check if development mode should be enabled for the entire platform
- // If this is the last arg or there is a following arg (i.e., arg+1 has a leading -),
- // simply enable development mode. Otherwise, assume that that the following arg is
- // actually some additional development time class path entries. This will be processed below.
- if (args[i].equalsIgnoreCase(DEV) && ((i + 1 == args.length) || ((i + 1 < args.length) && (args[i + 1].startsWith("-"))))) {
- inDevelopmentMode = true;
- found = true;
- continue;
- }
-
- // look for the usage flag
- if (args[i].equalsIgnoreCase(USAGE)) {
- usage = true;
- found = true;
- }
-
- if (found) {
- configArgs[configArgIndex++] = i;
- continue;
- }
- // check for args with parameters. If we are at the last argument or if the next one
- // has a '-' as the first character, then we can't have an arg with a parm so continue.
- if (i == args.length - 1 || args[i + 1].startsWith("-")) {
- continue;
- }
- String arg = args[++i];
-
- // look for the debug options file location.
- if (args[i - 1].equalsIgnoreCase(DEBUG)) {
- found = true;
- debugRequested = true;
- debugOptionsFilename = arg;
- }
-
- // look for the development mode and class path entries.
- if (args[i - 1].equalsIgnoreCase(DEV)) {
- inDevelopmentMode = true;
- devClassPath = arg;
- found = true;
- continue;
- }
-
- // look for the platform location. Only set it if not already set. This
- // preserves the value set in the startup() parameter. Be sure however
- // to consume the command-line argument.
- if (args[i - 1].equalsIgnoreCase(PLATFORM) || args[i - 1].equalsIgnoreCase(DATA)) {
- found = true;
- if (baseLocation == null)
- baseLocation = arg;
- }
-
- // look for the window system.
- if (args[i - 1].equalsIgnoreCase(WS)) {
- found = true;
- ws = arg;
- }
-
- // look for the operating system
- if (args[i - 1].equalsIgnoreCase(OS)) {
- found = true;
- os = arg;
- }
-
- // look for the system architecture
- if (args[i - 1].equalsIgnoreCase(ARCH)) {
- found = true;
- arch = arg;
- }
-
- // look for the system architecture
- if (args[i - 1].equalsIgnoreCase(NL)) {
- found = true;
- nl = arg;
- }
-
- // done checking for args. Remember where an arg was found
- if (found) {
- configArgs[configArgIndex++] = i - 1;
- configArgs[configArgIndex++] = i;
- }
- }
-
- // remove all the arguments consumed by this argument parsing
- if (configArgIndex == 0)
- return args;
- String[] passThruArgs = new String[args.length - configArgIndex];
- configArgIndex = 0;
- int j = 0;
- for (int i = 0; i < args.length; i++) {
- if (i == configArgs[configArgIndex])
- configArgIndex++;
- else
- passThruArgs[j++] = args[i];
- }
- return passThruArgs;
-}
-private static URL[] readPluginPath(InputStream input) {
- Properties ini = new Properties();
- try {
- ini.load(input);
- } catch (IOException e) {
- return null;
- }
- Vector result = new Vector(5);
- for (Enumeration groups = ini.propertyNames(); groups.hasMoreElements();) {
- String group = (String) groups.nextElement();
- for (StringTokenizer entries = new StringTokenizer(ini.getProperty(group), ";"); entries.hasMoreElements();) {
- String entry = (String) entries.nextElement();
- if (!entry.equals(""))
- try {
- result.addElement(new URL(entry));
- } catch (MalformedURLException e) {
- }
- }
- }
- return (URL[]) result.toArray(new URL[result.size()]);
-}
-public static URL resolve(URL url) throws IOException {
- if (!url.getProtocol().equals(PlatformURLHandler.PROTOCOL))
- return url;
- URLConnection connection = url.openConnection();
- if (connection instanceof PlatformURLConnection)
- return ((PlatformURLConnection) connection).getResolvedURL();
- else
- return url;
-}
-/**
- * @see BootLoader
- */
-public static Object run(String applicationName/*R1.0 compatibility*/, URL pluginPathLocation/*R1.0 compatibility*/, String location, String[] args) throws Exception {
- Object result = null;
- applicationR10 = applicationName; // for R1.0 compatibility
- String[] applicationArgs = null;
- try {
- applicationArgs = startup(pluginPathLocation, location, args);
- } catch (Exception e) {
- throw e;
- }
-
- String application = getCurrentPlatformConfiguration().getApplicationIdentifier();
- IPlatformRunnable runnable = getRunnable(application);
- if (runnable == null)
- throw new IllegalArgumentException("Application not found: " + application);
- try {
- result = runnable.run(applicationArgs);
- } catch (Throwable e) {
- e.printStackTrace();
- throw e;
- } finally {
- shutdown();
- return result;
- }
-}
-/**
- * Setup the debug flags for the given debug options. This method will likely
- * be called twice. Once when loading the options file from the command
- * line or install dir and then again when we have loaded options from the
- * specific platform metaarea.
- */
-public static void setupOptions() {
- // if no debug option was specified, don't even bother to try.
- // Must ensure that the options slot is null as this is the signal to the
- // platform that debugging is not enabled.
- if (!debugRequested)
- return;
- options.put(OPTION_STARTTIME, Long.toString(System.currentTimeMillis()));
- DelegatingURLClassLoader.DEBUG = getBooleanOption(OPTION_LOADER_DEBUG, false);
- DelegatingURLClassLoader.DEBUG_SHOW_CREATE = getBooleanOption(OPTION_LOADER_SHOW_CREATE, true);
- DelegatingURLClassLoader.DEBUG_SHOW_ACTIVATE = getBooleanOption(OPTION_LOADER_SHOW_ACTIVATE, true);
- DelegatingURLClassLoader.DEBUG_SHOW_ACTIONS = getBooleanOption(OPTION_LOADER_SHOW_ACTIONS, true);
- DelegatingURLClassLoader.DEBUG_SHOW_SUCCESS = getBooleanOption(OPTION_LOADER_SHOW_SUCCESS, true);
- DelegatingURLClassLoader.DEBUG_SHOW_FAILURE = getBooleanOption(OPTION_LOADER_SHOW_FAILURE, true);
- DelegatingURLClassLoader.DEBUG_FILTER_CLASS = getListOption(OPTION_LOADER_FILTER_CLASS);
- DelegatingURLClassLoader.DEBUG_FILTER_LOADER = getListOption(OPTION_LOADER_FILTER_LOADER);
- DelegatingURLClassLoader.DEBUG_FILTER_RESOURCE = getListOption(OPTION_LOADER_FILTER_RESOURCE);
- DelegatingURLClassLoader.DEBUG_FILTER_NATIVE = getListOption(OPTION_LOADER_FILTER_NATIVE);
- PlatformURLConnection.DEBUG = getBooleanOption(OPTION_URL_DEBUG, false);
- PlatformURLConnection.DEBUG_CONNECT = getBooleanOption(OPTION_URL_DEBUG_CONNECT, true);
- PlatformURLConnection.DEBUG_CACHE_LOOKUP = getBooleanOption(OPTION_URL_DEBUG_CACHE_LOOKUP, true);
- PlatformURLConnection.DEBUG_CACHE_COPY = getBooleanOption(OPTION_URL_DEBUG_CACHE_COPY, true);
- PlatformConfiguration.DEBUG = getBooleanOption(OPTION_CONFIGURATION_DEBUG,false);
-}
-/**
- * Initializes the execution context for this run of the platform. The context
- * includes information about the locale, operating system and window system.
- */
-private static void setupSystemContext() {
- if (nl == null)
- nl = Locale.getDefault().toString();
-
- if (os == null) {
- String name = System.getProperty("os.name");
- for (int i = 0; i < OS_LIST.length; i++)
- if (name.regionMatches(true, 0, OS_LIST[i], 0, 3))
- os = OS_LIST[i];
- // EXCEPTION: All mappings of SunOS convert to Solaris
- if (os == null)
- os = name.equalsIgnoreCase(INTERNAL_OS_SUNOS) ? BootLoader.OS_SOLARIS : BootLoader.OS_UNKNOWN;
- }
-
- if (ws == null)
- // setup default values for known OSes if nothing was specified
- if (os.equals(BootLoader.OS_WIN32))
- ws = BootLoader.WS_WIN32;
- else
- if (os.equals(BootLoader.OS_LINUX))
- ws = BootLoader.WS_MOTIF;
- else
- ws = BootLoader.WS_UNKNOWN;
-
- if (arch == null) {
- String name = System.getProperty("os.arch");
- // Map i386 architecture to x86
- arch = name.equalsIgnoreCase(INTERNAL_ARCH_I386) ? BootLoader.ARCH_X86 : name;
- }
-}
-/**
- * @see BootLoader
- */
-public static void shutdown() throws Exception {
- assertRunning();
- // no matter what happens, record that its no longer running
- running = false;
- Class platform = loader.loadClass(PLATFORM_ENTRYPOINT);
- Method method = platform.getDeclaredMethod("loaderShutdown", new Class[0]);
- try {
- method.invoke(platform, new Object[0]);
- } catch (InvocationTargetException e) {
- if (e.getTargetException() instanceof Error)
- throw (Error) e.getTargetException();
- else
- throw e;
- } finally {
- PlatformURLHandlerFactory.shutdown();
- PlatformConfiguration.shutdown();
- loader = null;
- }
-}
-/**
- * @see BootLoader
- */
-public static String[] startup(URL pluginPathLocation/*R1.0 compatibility*/, String location, String[] args) throws Exception {
- assertNotRunning();
- starting = true;
- commandLine = args;
- String[] applicationArgs = initialize(pluginPathLocation, location, args);
- Class platform = loader.loadClass(PLATFORM_ENTRYPOINT);
- Method method = platform.getDeclaredMethod("loaderStartup", new Class[] { URL[].class, String.class, Properties.class, String[].class });
- try {
- URL[] pluginPath = internalGetPluginPath();
- method.invoke(platform, new Object[] { pluginPath, baseLocation, options, args });
- } catch (InvocationTargetException e) {
- if (e.getTargetException() instanceof Error)
- throw (Error) e.getTargetException();
- else
- throw e;
- }
- // only record the platform as running if everything went swimmingly
- running = true;
- starting = false;
- return applicationArgs;
-}
-}
diff --git a/bundles/org.eclipse.core.boot/src/org/eclipse/core/internal/boot/PlatformClassLoader.java b/bundles/org.eclipse.core.boot/src/org/eclipse/core/internal/boot/PlatformClassLoader.java
deleted file mode 100644
index f801b60..0000000
--- a/bundles/org.eclipse.core.boot/src/org/eclipse/core/internal/boot/PlatformClassLoader.java
+++ /dev/null
@@ -1,99 +0,0 @@
-package org.eclipse.core.internal.boot;
-
-/*
- * (c) Copyright IBM Corp. 2000, 2001.
- * All Rights Reserved.
- */
-
-import java.net.URL;
-
-/**
- * This is the singleton platform loader. It searches jars and
- * directories containing the base runtime support.
- */
-public final class PlatformClassLoader extends DelegatingURLClassLoader {
- private static PlatformClassLoader singleton = null;
-/**
- * Creates the default instance of PlatformClassLoader according to the
- * given classpath, filters and parent.
- */
-public PlatformClassLoader(URL[] searchPath, URLContentFilter[] filters, ClassLoader parent, URL base) {
- super(searchPath, filters, null, null, parent);
- this.base = base;
- if (singleton == null)
- singleton = this;
- debugConstruction(); // must have initialized loader
-}
-protected String debugId() {
- return "PLATFORM";
-}
-/**
- * Finds and loads the class with the specified name from the URL search
- * path. Any URLs referring to JAR files are loaded and opened as needed
- * until the class is found. Only our own URL search path and that of our parent
- * is used. This method consults this loader's parent first but only if <code>checkParents</code>
- * is <code>true</code>. Following that, this loader's own search path is checked.
- * <code>null</code> is returned if the class cannot be found.
-
- * @param name the name of the class
- * @param resolve whether to resolve any loaded class
- * @param requestor class loader originating the request
- * @param checkParents whether to check the parent loader
- * @return the resulting class
- */
-protected Class findClassParentsSelf(final String name, boolean resolve, DelegatingURLClassLoader requestor, boolean checkParents) {
- Class result = null;
- synchronized (this) {
- // check the cache. If we find something, check to see if its visible.
- // If it is, return it. If not, return null if we are not checking parents. There is
- // no point in looking in self as the class was already in the cache.
- result = findLoadedClass(name);
- if (result != null) {
- result = checkClassVisibility(result, requestor, true);
- if (result != null || !checkParents)
- return result;
- }
-
- // if it wasn't in the cache or was not visible, check the parents (if requested)
- if (checkParents) {
- result = findClassParents(name, resolve);
- if (result != null)
- return result;
- }
- try {
- result = super.findClass(name);
- // If the class is loaded in this classloader register it with
- // the hot swap support. Need to do this regardless of visibility
- // because the class was actually loaded.
- if (result == null)
- return null;
- enableHotSwap(this, result);
- return checkClassVisibility(result, requestor, false);
- } catch (ClassNotFoundException e) {
- return null;
- }
- }
-}
-/**
- * Returns the default/singleton instance of PlatformClassLoader.
- * The class loader must have been explicitly created previously
- * otherwise this method returns <code>null</code>.
- */
-public static PlatformClassLoader getDefault() {
- return singleton;
-}
-/**
- * Sets the list of imported loaders. If the supplied list is <code>null</code>
- * then this loader's list of imports is cleared.
- */
-public synchronized void setImports(DelegatingURLClassLoader[] loaders) {
- if (loaders == null) {
- imports = null;
- return;
- }
- DelegateLoader[] delegates = new DelegateLoader[loaders.length];
- for (int i = 0; i < loaders.length; i++)
- delegates[i] = new DelegateLoader(loaders[i], false);
- imports = delegates;
-}
-}
diff --git a/bundles/org.eclipse.core.boot/src/org/eclipse/core/internal/boot/PlatformConfiguration.java b/bundles/org.eclipse.core.boot/src/org/eclipse/core/internal/boot/PlatformConfiguration.java
deleted file mode 100644
index edcf0e3..0000000
--- a/bundles/org.eclipse.core.boot/src/org/eclipse/core/internal/boot/PlatformConfiguration.java
+++ /dev/null
@@ -1,2146 +0,0 @@
-package org.eclipse.core.internal.boot;
-/*
- * (c) Copyright IBM Corp. 2000, 2001.
- * All Rights Reserved.
- */
-
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.FileOutputStream;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.OutputStream;
-import java.io.PrintWriter;
-import java.net.MalformedURLException;
-import java.net.URL;
-import java.net.URLConnection;
-import java.net.URLDecoder;
-import java.net.UnknownServiceException;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Date;
-import java.util.HashMap;
-import java.util.Properties;
-import java.util.StringTokenizer;
-
-import org.eclipse.core.boot.BootLoader;
-import org.eclipse.core.boot.IPlatformConfiguration;
-import org.eclipse.core.boot.IPlatformConfiguration.IFeatureEntry;
-import org.eclipse.core.boot.IPlatformConfiguration.ISiteEntry;
-import org.eclipse.core.boot.IPlatformConfiguration.ISitePolicy;
-
-public class PlatformConfiguration implements IPlatformConfiguration {
-
- private static PlatformConfiguration currentPlatformConfiguration = null;
-
- private URL configLocation;
- private HashMap sites;
- private HashMap externalLinkSites; // used to restore prior link site state
- private HashMap cfgdFeatures;
- private HashMap bootPlugins;
- private String defaultFeature;
- private long lastChangeStamp;
- private long changeStamp;
- private boolean changeStampIsValid = false;
- private long lastFeaturesChangeStamp;
- private long featuresChangeStamp;
- private boolean featuresChangeStampIsValid = false;
- private long lastPluginsChangeStamp;
- private long pluginsChangeStamp;
- private boolean pluginsChangeStampIsValid = false;
- private boolean featureChangesConfigured = false;
- private boolean transientConfig = false;
-
- private static String cmdConfiguration;
- private static String cmdFeature;
- private static String cmdApplication;
- private static URL cmdPlugins;
- private static boolean cmdUpdate;
- private static boolean cmdNoUpdate;
- private static boolean cmdDev;
-
- static boolean DEBUG = false;
-
- private static final String ECLIPSEDIR = "eclipse";
- private static final String PLUGINS = "plugins";
- private static final String INSTALL = "install";
- private static final String CONFIG_FILE = "platform.cfg";
- private static final String CONFIG_FILE_INIT = "install.ini";
- private static final String FEATURES = INSTALL + "/features";
- private static final String LINKS = "links";
- private static final String PLUGIN_XML = "plugin.xml";
- private static final String FRAGMENT_XML = "fragment.xml";
- private static final String FEATURE_XML = "feature.xml";
-
- private static final String[] BOOTSTRAP_PLUGINS = {"org.eclipse.core.boot", "org.eclipse.core.runtime"};
- private static final String CFG_BOOT_PLUGIN = "bootstrap";
- private static final String CFG_SITE = "site";
- private static final String CFG_URL = "url";
- private static final String CFG_POLICY = "policy";
- private static final String[] CFG_POLICY_TYPE = {"USER-INCLUDE", "USER-EXCLUDE"};
- private static final String CFG_POLICY_TYPE_UNKNOWN = "UNKNOWN";
- private static final String CFG_LIST = "list";
- private static final String CFG_STAMP = "stamp";
- private static final String CFG_FEATURE_STAMP = "stamp.features";
- private static final String CFG_PLUGIN_STAMP = "stamp.plugins";
- private static final String CFG_UPDATEABLE = "updateable";
- private static final String CFG_LINK_FILE = "linkfile";
- private static final String CFG_FEATURE_ENTRY = "feature";
- private static final String CFG_FEATURE_ENTRY_DEFAULT = "feature.default.id";
- private static final String CFG_FEATURE_ENTRY_ID = "id";
- private static final String CFG_FEATURE_ENTRY_VERSION = "version";
- private static final String CFG_FEATURE_ENTRY_APPLICATION = "application";
- private static final String CFG_FEATURE_ENTRY_ROOT = "root";
-
- private static final String INIT_DEFAULT_FEATURE_ID = "feature.default.id";
- private static final String INIT_DEFAULT_FEATURE_APPLICATION = "feature.default.application";
- private static final String DEFAULT_FEATURE_ID = "org.eclipse.sdk";
- private static final String DEFAULT_FEATURE_APPLICATION = "org.eclipse.ui.workbench";
-
- private static final String CFG_VERSION = "version";
- private static final String CFG_TRANSIENT = "transient";
- private static final String VERSION = "1.0";
- private static final String EOF = "eof";
- private static final int CFG_LIST_LENGTH = 10;
-
- private static final int DEFAULT_POLICY_TYPE = ISitePolicy.USER_EXCLUDE;
- private static final String[] DEFAULT_POLICY_LIST = new String[0];
-
- private static final String ARG_USER_DIR = "user.dir";
- private static final String ARG_USER_HOME = "user.home";
- private static final String ARG_COMMON = "common";
-
- private static final String LINK_PATH = "path";
- private static final String LINK_READ = "r";
- private static final String LINK_READ_WRITE = "rw";
-
- private static final String CMD_CONFIGURATION = "-configuration";
- private static final String CMD_FEATURE = "-feature";
- private static final String CMD_APPLICATION = "-application";
- private static final String CMD_PLUGINS = "-plugins";
- private static final String CMD_UPDATE = "-update";
- private static final String CMD_NO_UPDATE = "-noupdate";
- private static final String CMD_DEV = "-dev"; // triggers -noupdate
-
- private static final String RECONCILER_APP = "org.eclipse.update.core.reconciler";
-
- private static final char[] HEX = {'0','1','2','3','4','5','6','7','8','9','A','B','C','D','E','F'};
-
- public class SiteEntry implements IPlatformConfiguration.ISiteEntry {
-
- private URL url; // this is the external URL for the site
- private URL resolvedURL; // this is the resolved URL used internally
- private ISitePolicy policy;
- private boolean updateable = true;
- private ArrayList features;
- private ArrayList plugins;
- private PlatformConfiguration parent;
- private long lastChangeStamp;
- private long changeStamp;
- private boolean changeStampIsValid = false;
- private long lastFeaturesChangeStamp;
- private long featuresChangeStamp;
- private boolean featuresChangeStampIsValid = false;
- private long lastPluginsChangeStamp;
- private long pluginsChangeStamp;
- private boolean pluginsChangeStampIsValid = false;
- private String linkFileName = null;
-
- private SiteEntry() {
- }
- private SiteEntry(URL url, ISitePolicy policy, PlatformConfiguration parent) {
- if (url==null)
- throw new IllegalArgumentException();
-
- if (policy==null)
- throw new IllegalArgumentException();
-
- if (parent==null)
- throw new IllegalArgumentException();
-
- this.url = url;
- this.policy = policy;
- this.parent = parent;
- this.features = null;
- this.plugins = null;
- this.resolvedURL = this.url;
- if (url.getProtocol().equals(PlatformURLHandler.PROTOCOL)) {
- try {
- resolvedURL = ((PlatformURLConnection)url.openConnection()).getResolvedURL();
- } catch(IOException e) {
- }
- }
- }
-
- /*
- * @see ISiteEntry#getURL()
- */
- public URL getURL() {
- return url;
- }
-
- /*
- * @see ISiteEntry#getSitePolicy()
- */
- public ISitePolicy getSitePolicy() {
- return policy;
- }
-
- /*
- * @see ISiteEntry#setSitePolicy(ISitePolicy)
- */
- public synchronized void setSitePolicy(ISitePolicy policy) {
- if (policy==null)
- throw new IllegalArgumentException();
- this.policy = policy;
- }
-
- /*
- * @see ISiteEntry#getFeatures()
- */
- public String[] getFeatures() {
- return getDetectedFeatures();
- }
-
- /*
- * @see ISiteEntry#getPlugins()
- */
- public String[] getPlugins() {
-
- ISitePolicy policy = getSitePolicy();
-
- if (policy.getType()==ISitePolicy.USER_INCLUDE)
- return policy.getList();
-
- if (policy.getType()==ISitePolicy.USER_EXCLUDE) {
- ArrayList detectedPlugins = new ArrayList(Arrays.asList(getDetectedPlugins()));
- String[] excludedPlugins = policy.getList();
- for (int i=0; i<excludedPlugins.length; i++) {
- if (detectedPlugins.contains(excludedPlugins[i]))
- detectedPlugins.remove(excludedPlugins[i]);
- }
- return (String[])detectedPlugins.toArray(new String[0]);
- }
-
- // bad policy type
- return new String[0];
- }
-
- /*
- * @see ISiteEntry#getChangeStamp()
- */
- public long getChangeStamp() {
- if (!changeStampIsValid)
- computeChangeStamp();
- return changeStamp;
- }
-
- /*
- * @see ISiteEntry#getFeaturesChangeStamp()
- */
- public long getFeaturesChangeStamp() {
- if (!featuresChangeStampIsValid)
- computeFeaturesChangeStamp();
- return featuresChangeStamp;
- }
-
- /*
- * @see ISiteEntry#getPluginsChangeStamp()
- */
- public long getPluginsChangeStamp() {
- if (!pluginsChangeStampIsValid)
- computePluginsChangeStamp();
- return pluginsChangeStamp;
- }
-
- /*
- * @see ISiteEntry#isUpdateable()
- */
- public boolean isUpdateable() {
- //FIXME: should add actual read-write check
- return updateable;
- }
-
- private String[] detectFeatures() {
-
- // invalidate stamps ... we are doing discovery
- changeStampIsValid = false;
- featuresChangeStampIsValid = false;
- parent.changeStampIsValid = false;
- parent.featuresChangeStampIsValid = false;
-
- features = new ArrayList();
-
- if (!supportsDetection(resolvedURL))
- return new String[0];
-
- // locate feature entries on site
- long start = 0;
- if (DEBUG)
- start = (new Date()).getTime();
- File root =
- new File(resolvedURL.getFile().replace('/', File.separatorChar) + FEATURES);
- String[] list = root.list();
- String path;
- File plugin;
- for (int i = 0; list != null && i < list.length; i++) {
- path = list[i] + File.separator + FEATURE_XML;
- plugin = new File(root, path);
- if (!plugin.exists()) {
- continue;
- }
- features.add(FEATURES + "/" + path.replace(File.separatorChar, '/'));
- }
- if (DEBUG) {
- long end = (new Date()).getTime();
- debug(resolvedURL.toString()+" located "+features.size()+" feature(s) in "+(end-start)+"ms");
- }
-
- return (String[])features.toArray(new String[0]);
- }
-
- private String[] detectPlugins() {
-
- // invalidate stamps ... we are doing discovery
- changeStampIsValid = false;
- pluginsChangeStampIsValid = false;
- parent.changeStampIsValid = false;
- parent.pluginsChangeStampIsValid = false;
-
- plugins = new ArrayList();
-
- if (!supportsDetection(resolvedURL))
- return new String[0];
-
- // locate plugin entries on site
- long start = 0;
- if (DEBUG)
- start = (new Date()).getTime();
- File root =
- new File(resolvedURL.getFile().replace('/', File.separatorChar) + PLUGINS);
- String[] list = root.list();
- String path;
- File plugin;
- for (int i = 0; list != null && i < list.length; i++) {
- path = list[i] + File.separator + PLUGIN_XML;
- plugin = new File(root, path);
- if (!plugin.exists()) {
- path = list[i] + File.separator + FRAGMENT_XML;
- plugin = new File(root, path);
- if (!plugin.exists())
- continue;
- }
- plugins.add(PLUGINS + "/" + path.replace(File.separatorChar, '/'));
- }
- if (DEBUG) {
- long end = (new Date()).getTime();
- debug(resolvedURL.toString()+" located "+plugins.size()+" plugin(s) in "+(end-start)+"ms");
- }
-
- return (String[])plugins.toArray(new String[0]);
- }
-
- private synchronized String[] getDetectedFeatures() {
- if (features == null)
- return detectFeatures();
- else
- return (String[])features.toArray(new String[0]);
- }
-
- private synchronized String[] getDetectedPlugins() {
- if (plugins == null)
- return detectPlugins();
- else
- return (String[])plugins.toArray(new String[0]);
- }
-
- private URL getResolvedURL() {
- return resolvedURL;
- }
-
- private void computeChangeStamp() {
- computeFeaturesChangeStamp();
- computePluginsChangeStamp();
- changeStamp = resolvedURL.hashCode() ^ featuresChangeStamp ^ pluginsChangeStamp;
- changeStampIsValid = true;
- }
-
- private synchronized void computeFeaturesChangeStamp() {
- if (featuresChangeStampIsValid)
- return;
-
- String[] features = getFeatures();
- featuresChangeStamp = computeStamp(features);
- featuresChangeStampIsValid = true;
- if (DEBUG)
- debug(resolvedURL.toString()+" feature stamp: "+featuresChangeStamp+((featuresChangeStamp==lastFeaturesChangeStamp)?" [no changes]":" [was "+lastFeaturesChangeStamp+"]"));
- }
-
- private synchronized void computePluginsChangeStamp() {
- if (pluginsChangeStampIsValid)
- return;
-
- String[] plugins = getPlugins();
- pluginsChangeStamp = computeStamp(plugins);
- pluginsChangeStampIsValid = true;
- if (DEBUG)
- debug(resolvedURL.toString()+" plugin stamp: "+pluginsChangeStamp+((pluginsChangeStamp==lastPluginsChangeStamp)?" [no changes]":" [was "+lastPluginsChangeStamp+"]"));
- }
-
- private long computeStamp(String[] targets) {
-
- long result = 0;
- if (!supportsDetection(resolvedURL)) {
- // FIXME: this path should not be executed until we support running
- // from an arbitrary URL (in particular from http server). For
- // now just compute stamp across the list of names. Eventually
- // when general URLs are supported we need to do better (factor
- // in at least the existence of the target). However, given this
- // code executes early on the startup sequence we need to be
- // extremely mindful of performance issues.
- for (int i=0; i<targets.length; i++)
- result ^= targets[i].hashCode();
- if (DEBUG)
- debug("*WARNING* computing stamp using URL hashcodes only");
- } else {
- // compute stamp across local targets
- String rootPath = resolvedURL.getFile().replace('/',File.separatorChar);
- if (!rootPath.endsWith(File.separator))
- rootPath += File.separator;
- File rootFile = new File(rootPath);
- if (rootFile.exists()) {
- File f = null;
- for (int i=0; i<targets.length; i++) {
- f = new File(rootFile,targets[i]);
- if (f.exists())
- result ^= f.getAbsolutePath().hashCode() ^ f.lastModified() ^ f.length();
- }
- }
- }
-
- return result;
- }
-
- private boolean isExternallyLinkedSite() {
- return (linkFileName!=null && !linkFileName.trim().equals(""));
- }
-
- private synchronized void refresh() {
- // reset computed values. Will be updated on next access.
- lastChangeStamp = changeStamp;
- lastFeaturesChangeStamp = featuresChangeStamp;
- lastPluginsChangeStamp = pluginsChangeStamp;
- changeStampIsValid = false;
- featuresChangeStampIsValid = false;
- pluginsChangeStampIsValid = false;
- features = null;
- plugins = null;
- }
- }
-
- public class SitePolicy implements IPlatformConfiguration.ISitePolicy {
-
- private int type;
- private String[] list;
-
- private SitePolicy() {
- }
- private SitePolicy(int type, String[] list) {
- if (type != ISitePolicy.USER_INCLUDE
- && type != ISitePolicy.USER_EXCLUDE)
- throw new IllegalArgumentException();
- this.type = type;
-
- if (list == null)
- this.list = new String[0];
- else
- this.list = list;
- }
-
- /*
- * @see ISitePolicy#getType()
- */
- public int getType() {
- return type;
- }
-
- /*
- * @see ISitePolicy#getList()
- */
- public String[] getList() {
- return list;
- }
-
- /*
- * @see ISitePolicy#setList(String[])
- */
- public synchronized void setList(String[] list) {
- if (list == null)
- this.list = new String[0];
- else
- this.list = list;
- }
-
- }
-
- private class FeatureEntry implements IPlatformConfiguration.IFeatureEntry {
- private String id;
- private String version;
- private String application;
- private URL root;
-
- private FeatureEntry(String id, String version, String application, URL root) {
- if (id == null)
- throw new IllegalArgumentException();
- this.id = id;
- this.version = version;
- this.application = application;
- this.root = root;
- }
-
- /*
- * @see IFeatureEntry#getFeatureIdentifier()
- */
- public String getFeatureIdentifier() {
- return id;
- }
-
- /*
- * @see IFeatureEntry#getFeatureVersion()
- */
- public String getFeatureVersion() {
- return version;
- }
-
- /*
- * @see IFeatureEntry#getFeatureApplication()
- */
- public String getFeatureApplication() {
- return application;
- }
-
- /*
- * @see IFeatureEntry#getFeatureRootURL()
- */
- public URL getFeatureRootURL() {
- return root;
- }
- }
-
- private class VersionedIdentifier {
- private String identifier = "";
- private int major = 0;
- private int minor = 0;
- private int service = 0;
- private String qualifier = "";
-
- private static final String VER_SEPARATOR = ".";
- private static final String ID_SEPARATOR = "_";
-
- public VersionedIdentifier(String s) {
- if (s==null || (s=s.trim()).equals(""))
- return;
-
- int loc = s.lastIndexOf(ID_SEPARATOR);
- if (loc != -1) {
- this.identifier = s.substring(0, loc);
- String version = s.substring(loc+1);
- parseVersion(version);
- } else
- this.identifier = s;
- }
-
- public boolean identifierEquals(String id) {
- if (id == null)
- return identifier == null;
- else
- return id.equals(identifier);
- }
-
- public int compareVersion(VersionedIdentifier id) {
-
- if (id == null) {
- if (major==0 && minor==0 && service==0) return -1;
- else return 1;
- }
-
- if (major > id.major) return 1;
- if (major < id.major) return -1;
- if (minor > id.minor) return 1;
- if (minor < id.minor) return -1;
- if (service > id.service) return 1;
- if (service < id.service) return -1;
- return compareQualifiers(qualifier, id.qualifier);
- }
-
- private int compareQualifiers(String q1, String q2) {
- int result = q1.compareTo(q2);
- if (result<0)
- return -1;
- else if (result>0)
- return 1;
- else
- return 0;
- }
-
- private void parseVersion(String v) {
- if( v == null || (v=v.trim()).equals(""))
- return;
-
- try{
- StringTokenizer st = new StringTokenizer(v, VER_SEPARATOR);
- ArrayList elements = new ArrayList(4);
-
- while(st.hasMoreTokens()) {
- elements.add(st.nextToken());
- }
-
- if (elements.size()>=1) this.major = (new Integer((String)elements.get(0))).intValue();
- if (elements.size()>=2) this.minor = (new Integer((String)elements.get(1))).intValue();
- if (elements.size()>=3) this.service = (new Integer((String)elements.get(2))).intValue();
- if (elements.size()>=4) this.qualifier = removeWhiteSpace((String)elements.get(3));
-
- } catch (Exception e) { // use what we got so far
- }
- }
-
- private String removeWhiteSpace(String s) {
- char[] chars = s.trim().toCharArray();
- boolean whitespace = false;
- for(int i=0; i<chars.length; i++) {
- if (Character.isWhitespace(chars[i])) {
- chars[i] = '_';
- whitespace = true;
- }
- }
- return whitespace ? new String(chars) : s;
- }
- }
-
- private PlatformConfiguration(String configArg) throws IOException {
- this.sites = new HashMap();
- this.externalLinkSites = new HashMap();
- this.cfgdFeatures = new HashMap();
- this.bootPlugins = new HashMap();
-
- // Determine configuration URL to use (based on command line argument)
- URL configURL = getConfigurationURL(configArg);
-
- // initialize configuration
- initializeCurrent(configURL);
-
- // pick up any first-time default settings relative to selected config location
- loadInitializationAttributes(configLocation);
-
- // FIXME: support for "safe mode"
-
- // Detect external links. These are "soft link" to additional sites. The link
- // files are usually provided by external installation programs. They are located
- // relative to this configuration URL.
- configureExternalLinks();
-
- // compute differences between configuration and actual content of the sites
- // (base sites and link sites)
- computeChangeStamp();
- }
-
- PlatformConfiguration(URL url) throws IOException {
- this.sites = new HashMap();
- this.externalLinkSites = new HashMap();
- this.cfgdFeatures = new HashMap();
- this.bootPlugins = new HashMap();
- initialize(url);
- }
-
- /*
- * @see IPlatformConfiguration#createSiteEntry(URL, ISitePolicy)
- */
- public ISiteEntry createSiteEntry(URL url, ISitePolicy policy) {
- return new PlatformConfiguration.SiteEntry(url, policy, this);
- }
-
- /*
- * @see IPlatformConfiguration#createSitePolicy(int, String[])
- */
- public ISitePolicy createSitePolicy(int type, String[] list) {
- return new PlatformConfiguration.SitePolicy(type, list);
- }
-
- /*
- * @see IPlatformConfiguration#createFeatureEntry(String, String, String, URL)
- */
- public IFeatureEntry createFeatureEntry(
- String id,
- String version,
- String application,
- URL root) {
- return new PlatformConfiguration.FeatureEntry(id, version, application, root);
- }
-
- /*
- * @see IPlatformConfiguration#configureSite(ISiteEntry)
- */
- public void configureSite(ISiteEntry entry) {
- configureSite(entry, false);
- }
-
- /*
- * @see IPlatformConfiguration#configureSite(ISiteEntry, boolean)
- */
- public synchronized void configureSite(ISiteEntry entry, boolean replace) {
-
- if (entry == null)
- return;
-
- URL url = entry.getURL();
- if (url == null)
- return;
- String key = url.toExternalForm();
-
- if (sites.containsKey(key) && !replace)
- return;
-
- sites.put(key, entry);
- }
-
- /*
- * @see IPlatformConfiguration#unconfigureSite(ISiteEntry)
- */
- public synchronized void unconfigureSite(ISiteEntry entry) {
- if (entry == null)
- return;
-
- URL url = entry.getURL();
- if (url == null)
- return;
- String key = url.toExternalForm();
-
- sites.remove(key);
- }
-
- /*
- * @see IPlatformConfiguration#getConfiguredSites()
- */
- public ISiteEntry[] getConfiguredSites() {
- if (sites.size() == 0)
- return new ISiteEntry[0];
-
- return (ISiteEntry[]) sites.values().toArray(new ISiteEntry[0]);
- }
-
- /*
- * @see IPlatformConfiguration#findConfiguredSite(URL)
- */
- public ISiteEntry findConfiguredSite(URL url) {
- if (url == null)
- return null;
- String key = url.toExternalForm();
-
- ISiteEntry result = (ISiteEntry) sites.get(key);
- if (result == null) // retry with decoded URL string
- result = (ISiteEntry) sites.get(URLDecoder.decode(key));
- return result;
- }
-
- /*
- * @see IPlatformConfiguration#configureFeatureEntry(IFeatureEntry)
- */
- public synchronized void configureFeatureEntry(IFeatureEntry entry) {
- if (entry == null)
- return;
-
- String key = entry.getFeatureIdentifier();
- if (key == null)
- return;
-
- cfgdFeatures.put(key, entry);
- }
-
- /*
- * @see IPlatformConfiguration#unconfigureFeatureEntry(IFeatureEntry)
- */
- public synchronized void unconfigureFeatureEntry(IFeatureEntry entry) {
- if (entry == null)
- return;
-
- String key = entry.getFeatureIdentifier();
- if (key == null)
- return;
-
- cfgdFeatures.remove(key);
- }
-
- /*
- * @see IPlatformConfiguration#getConfiguredFeatureEntries()
- */
- public IFeatureEntry[] getConfiguredFeatureEntries() {
- if (cfgdFeatures.size() == 0)
- return new IFeatureEntry[0];
-
- return (IFeatureEntry[]) cfgdFeatures.values().toArray(new IFeatureEntry[0]);
- }
-
- /*
- * @see IPlatformConfiguration#findConfiguredFeatureEntry(String)
- */
- public IFeatureEntry findConfiguredFeatureEntry(String id) {
- if (id == null)
- return null;
-
- return (IFeatureEntry) cfgdFeatures.get(id);
- }
-
- /*
- * @see IPlatformConfiguration#getConfigurationLocation()
- */
- public URL getConfigurationLocation() {
- return configLocation;
- }
-
- /*
- * @see IPlatformConfiguration#getChangeStamp()
- */
- public long getChangeStamp() {
- if (!changeStampIsValid)
- computeChangeStamp();
- return changeStamp;
- }
-
- /*
- * @see IPlatformConfiguration#getFeaturesChangeStamp()
- */
- public long getFeaturesChangeStamp() {
- if (!featuresChangeStampIsValid)
- computeFeaturesChangeStamp();
- return featuresChangeStamp;
- }
-
- /*
- * @see IPlatformConfiguration#getPluginsChangeStamp()
- */
- public long getPluginsChangeStamp() {
- if (!pluginsChangeStampIsValid)
- computePluginsChangeStamp();
- return pluginsChangeStamp;
- }
-
- /*
- * @see IPlatformConfiguration#getApplicationIdentifier()
- */
- public String getApplicationIdentifier() {
-
- if (featuresChangeStamp != lastFeaturesChangeStamp) {
- // we have detected feature changes ... see if we need to reconcile
- boolean update = !(cmdNoUpdate || (cmdDev && !cmdUpdate));
- if (update)
- return RECONCILER_APP;
- }
-
- // "normal" startup ... run specified application
- return getApplicationIdentifierInternal();
- }
-
- private String getApplicationIdentifierInternal() {
-
- if (cmdApplication != null) // application was specified
- return cmdApplication;
- else {
- // if -feature was not specified use the default feature
- String feature = cmdFeature;
- if (feature == null)
- feature = defaultFeature;
-
- // lookup application for feature (specified or defaulted)
- if (feature != null) {
- IFeatureEntry fe = findConfiguredFeatureEntry(feature);
- if (fe != null) {
- if (fe.getFeatureApplication() != null)
- return fe.getFeatureApplication();
- }
- }
- }
-
- // return hardcoded default if we failed
- return DEFAULT_FEATURE_APPLICATION;
- }
-
- /*
- * @see IPlatformConfiguration#getPrimaryFeatureIdentifier()
- */
- public String getPrimaryFeatureIdentifier() {
-
- if (cmdFeature != null) // -feature was specified on command line
- return cmdFeature;
-
- // feature was not specified on command line
- if (defaultFeature != null)
- return defaultFeature; // return customized default if set
- else
- return DEFAULT_FEATURE_ID; // return hardcoded default
- }
-
- /*
- * @see IPlatformConfiguration#getPluginPath()
- */
- public URL[] getPluginPath() {
- ArrayList path = new ArrayList();
- if (DEBUG)
- debug("computed plug-in path:");
-
- ISiteEntry[] sites = getConfiguredSites();
- URL pathURL;
- for (int i=0; i<sites.length; i++) {
- String[] plugins = sites[i].getPlugins();
- for (int j=0; j<plugins.length; j++) {
- try {
- pathURL = new URL(((SiteEntry)sites[i]).getResolvedURL(),plugins[j]);
- path.add(pathURL);
- if (DEBUG)
- debug(" "+pathURL.toString());
- } catch(MalformedURLException e) {
- if (DEBUG)
- debug(" bad URL: "+e);
- }
- }
- }
- return (URL[])path.toArray(new URL[0]);
- }
-
- /*
- * @see IPlatformConfiguration#getBootstrapPluginIdentifiers()
- */
- public String[] getBootstrapPluginIdentifiers() {
- return BOOTSTRAP_PLUGINS;
- }
-
- /*
- * @see IPlatformConfiguration#setBootstrapPluginLocation(String, URL)
- */
- public void setBootstrapPluginLocation(String id, URL location) {
- String[] ids = getBootstrapPluginIdentifiers();
- for (int i=0; i<ids.length; i++) {
- if (ids[i].equals(id)) {
- bootPlugins.put(id, location.toExternalForm());
- break;
- }
- }
- }
-
- /*
- * @see IPlatformConfiguration#isUpdateable()
- */
- public boolean isUpdateable() {
- // FIXME: support r/o configuration
- return true;
- }
-
- /*
- * @see IPlatformConfiguration#isTransient()
- */
- public boolean isTransient() {
- return transientConfig;
- }
-
- /*
- * @see IPlatformConfiguration#isTransient(boolean)
- */
- public void isTransient(boolean value) {
- if (this != BootLoader.getCurrentPlatformConfiguration())
- transientConfig = value;
- }
-
- /*
- * @see IPlatformConfiguration#refresh()
- */
- public synchronized void refresh() {
- // Reset computed values. Will be lazily refreshed
- // on next access
- ISiteEntry[] sites = getConfiguredSites();
- for (int i = 0; i < sites.length; i++) {
- // reset site entry
- ((SiteEntry)sites[i]).refresh();
- }
- // reset configuration entry.
- lastChangeStamp = changeStamp;
- lastFeaturesChangeStamp = featuresChangeStamp;
- lastPluginsChangeStamp = pluginsChangeStamp;
- changeStampIsValid = false;
- featuresChangeStampIsValid = false;
- pluginsChangeStampIsValid = false;
- }
-
- /*
- * @see IPlatformConfiguration#save()
- */
- public void save() throws IOException {
- if (isUpdateable())
- save(configLocation);
- }
-
- /*
- * @see IPlatformConfiguration#save(URL)
- */
- public synchronized void save(URL url) throws IOException {
- if (url == null)
- throw new IOException(Policy.bind("cfig.unableToSave.noURL"));
-
- URLConnection uc = url.openConnection();
- uc.setDoOutput(true);
- OutputStream os = null;
- try {
- os = uc.getOutputStream();
- } catch (UnknownServiceException e) {
- // retry with direct file i/o
- if (!url.getProtocol().equals("file"))
- throw e;
- File cfigFile = new File(url.getFile().replace('/',File.separatorChar));
- File cfigDir = cfigFile.getParentFile();
- if (cfigDir!=null) {
- cfigDir.mkdirs();
- }
- os = new FileOutputStream(cfigFile);
- }
- PrintWriter w = new PrintWriter(os);
- try {
- write(w);
- } finally {
- w.close();
- }
- }
-
- URL getPluginPath(String pluginId) {
- return getPluginPath(pluginId, null);
- }
-
- // This method is currently public because it is called by InternalPlatform.
- // However, it is NOT intended as API
- // FIXME: restructure the code so that InternalBootLoader passes the
- // required information to InternalPlatform
- public URL getPluginPath(String pluginId, String versionId) {
- // return the plugin path element for the specified plugin. This method
- // is used during boot processing to obtain "kernel" plugins whose
- // class loaders must be created prior to the plugin registry being
- // available (ie. loaders needed to create the plugin registry)
- // must be created
-
- ISiteEntry[] sites = getConfiguredSites();
- if (sites == null || sites.length == 0)
- return null;
-
- // for now look for the "latest" version of the requested plugin
- // using naming convention of the installer and the policy set for
- // the site
- // FIXME: the current code in this method implements the R1.0 "best guess"
- // algorithm
- VersionedIdentifier savedVid = new VersionedIdentifier(null);
- String savedEntry = null;
- URL savedURL = null;
- for (int j=0; j<sites.length; j++) {
- String[] plugins = sites[j].getPlugins();
- for (int i=0; plugins!=null && i<plugins.length; i++) {
- // look for best match.
- // The entries are in the form <path>/<pluginDir>/plugin.xml
- // look for -------------------------^
- int ix = findEntrySeparator(plugins[i],2); // second from end
- if (ix == -1)
- continue; // bad entry ... skip
- String pluginDir = plugins[i].substring(ix+1);
- ix = pluginDir.indexOf("/");
- if (ix != -1)
- pluginDir = pluginDir.substring(0,ix);
- if (pluginDir.equals(""))
- continue; // bad entry ... skip
-
- VersionedIdentifier vid = new VersionedIdentifier(pluginDir);
- if (vid.identifierEquals(pluginId)) {
- if (vid.compareVersion(savedVid) >= 0) {
- savedVid = vid;
- savedEntry = plugins[i];
- savedURL = ((SiteEntry)sites[j]).getResolvedURL();
- }
- }
- }
- }
-
- if (savedEntry == null)
- return null;
-
- // callers are expecting a directory URL
- if (!savedEntry.endsWith("/")) {
- int ix = savedEntry.lastIndexOf("/");
- if (ix == -1)
- return null; // bad entry
- savedEntry = savedEntry.substring(0,ix+1); // include trailing separator
- }
-
- try {
- return new URL(savedURL,savedEntry);
- } catch(MalformedURLException e) {
- return null;
- }
- }
-
- static PlatformConfiguration getCurrent() {
- return currentPlatformConfiguration;
- }
-
- /**
- * Create and initialize the current platform configuration
- * @param cmdArgs command line arguments (startup and boot arguments are
- * already consumed)
- * @param r10plugins plugin-path URL as passed on the BootLoader.run(...)
- * or BootLoader.startup(...) method. Supported for R1.0 compatibility
- * @param r10apps application identifies as passed on the BootLoader.run(...)
- * method. Supported for R1.0 compatibility.
- */
- static synchronized String[] startup(String[] cmdArgs, URL r10plugins, String r10app) throws Exception {
-
- // initialize command line settings
- cmdConfiguration = null;
- cmdFeature = null;
- cmdApplication = null;
- cmdPlugins = null;
- cmdPlugins = r10plugins; // R1.0 compatibility
- cmdApplication = r10app; // R1.0 compatibility
-
- String[] passthruArgs = processCommandLine(cmdArgs);
-
- // determine launch mode
- if (cmdPlugins != null) {
- // R1.0 compatibility mode ... explicit plugin-path was specified.
- // Convert the plugins path into a configuration
- try {
- cmdConfiguration = createConfigurationFromPlugins(cmdPlugins, cmdConfiguration);
- } catch (Exception e) {
- if (DEBUG)
- debug("Unable to use specified plugin-path: "+e);
- }
- }
-
- // create current configuration
- if (currentPlatformConfiguration == null)
- currentPlatformConfiguration = new PlatformConfiguration(cmdConfiguration);
-
- // check if we will be forcing reconciliation
- passthruArgs = checkForFeatureChanges(passthruArgs, currentPlatformConfiguration);
-
- return passthruArgs;
- }
-
- static synchronized void shutdown() throws IOException {
-
- // save platform configuration
- PlatformConfiguration config = getCurrent();
- if (config != null) {
- try {
- config.save();
- } catch(IOException e) {
- if (DEBUG)
- debug("Unable to save configuration "+e.toString());
- // will recover on next startup
- }
- }
- }
-
- private void initializeCurrent(URL url) throws IOException {
-
- // !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
- // NOTE:
- // Due to Eclipse class loader structure and class
- // visibility, the configuration file search is
- // implemented in 2 different classes:
- // org.eclipse.core.internal.boot.PlatformConfiguration
- // getConfigurationURL(String)
- // initializeCurrent(URL)
- // org.eclipse.core.launcher.Main
- // getConfigurationURL(String)
- // loadConfiguration(URL)
- // If you are making changes to this method make sure
- // the change is applied in both places
- // !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
-
- // URL of configuration file was specified ... just use it, or create one in specified
- // location if it does not exist
- if (url != null) {
- try {
- load(url);
- if (DEBUG)
- debug("Using configuration " + url.toString());
- } catch(IOException e) {
- ISitePolicy defaultPolicy = createSitePolicy(DEFAULT_POLICY_TYPE, DEFAULT_POLICY_LIST);
- ISiteEntry defaultSite = createSiteEntry(BootLoader.getInstallURL(), defaultPolicy);
- configureSite(defaultSite);
- if (DEBUG)
- debug("Creating configuration " + url.toString());
- }
- configLocation = url;
- verifyPath(configLocation);
- return;
- }
-
- // URL was not specified. Default behavior is to look for configuration file in
- // USER.DIR then USER.HOME then COMMON
-
- URL userdirURL = null;
- try {
- String tmp = System.getProperty("user.dir");
- if (!tmp.endsWith(File.separator))
- tmp += File.separator;
- userdirURL = new URL("file:" + tmp.replace(File.separatorChar,'/') + ECLIPSEDIR + "/" + INSTALL + "/" + CONFIG_FILE);
- load(userdirURL);
- configLocation = userdirURL;
- if (DEBUG)
- debug("Using configuration " + configLocation.toString());
- return;
- } catch (IOException e) {
- if (DEBUG)
- debug("Unable to load configuration from USER.DIR " + e);
- }
-
- URL userhomeURL = null;
- try {
- String tmp = System.getProperty("user.home");
- if (!tmp.endsWith(File.separator))
- tmp += File.separator;
- userhomeURL = new URL("file:" + tmp.replace(File.separatorChar,'/') + ECLIPSEDIR + "/" + INSTALL + "/" + CONFIG_FILE);
- load(userhomeURL);
- configLocation = userhomeURL;
- if (DEBUG)
- debug("Using configuration " + configLocation.toString());
- return;
- } catch (IOException e) {
- if (DEBUG)
- debug("Unable to load configuration from USER.HOME " + e);
- }
-
- URL commonURL = null;
- try {
- commonURL = new URL(BootLoader.getInstallURL(), INSTALL + "/" + CONFIG_FILE);
- load(commonURL);
- configLocation = commonURL;
- if (DEBUG)
- debug("Using configuration " + configLocation.toString());
- return;
- } catch (IOException e) {
- if (DEBUG)
- debug("Unable to load configuration from COMMON " + e);
- }
-
- // No configuration files found. Assume COMMON (note: this may not be a r/w
- // location so we may not be able to save the configuration on shutdown. This is OK
- // for the default case)
-
- ISitePolicy defaultPolicy = createSitePolicy(DEFAULT_POLICY_TYPE, DEFAULT_POLICY_LIST);
- URL siteURL = null;
- try {
- siteURL = new URL(PlatformURLBaseConnection.PLATFORM_URL_STRING); // try using platform-relative URL
- } catch (MalformedURLException e) {
- siteURL = BootLoader.getInstallURL(); // ensure we come up ... use absolute file URL
- }
- ISiteEntry defaultSite = createSiteEntry(siteURL, defaultPolicy);
- configureSite(defaultSite);
- configLocation = commonURL;
- verifyPath(configLocation);
- if (DEBUG)
- debug("Creating configuration " + configLocation.toString());
- }
-
- private void initialize(URL url) throws IOException {
- if (url == null) {
- if (DEBUG)
- debug("Creating empty configuration");
- return;
- }
-
- load(url);
- configLocation = url;
- if (DEBUG)
- debug("Using configuration " + configLocation.toString());
- }
-
- private void computeChangeStamp() {
- computeFeaturesChangeStamp();
- computePluginsChangeStamp();
- changeStamp = featuresChangeStamp ^ pluginsChangeStamp;
- changeStampIsValid = true;
- }
-
- private void computeFeaturesChangeStamp() {
- if (featuresChangeStampIsValid)
- return;
-
- long result = 0;
- ISiteEntry[] sites = getConfiguredSites();
- for (int i=0; i<sites.length; i++) {
- result ^= sites[i].getFeaturesChangeStamp();
- }
- featuresChangeStamp = result;
- featuresChangeStampIsValid = true;
- }
-
- private void computePluginsChangeStamp() {
- if (pluginsChangeStampIsValid)
- return;
-
- long result = 0;
- ISiteEntry[] sites = getConfiguredSites();
- for (int i=0; i<sites.length; i++) {
- result ^= sites[i].getPluginsChangeStamp();
- }
- pluginsChangeStamp = result;
- pluginsChangeStampIsValid = true;
- }
-
- private void configureExternalLinks() {
- if (!supportsDetection(configLocation))
- return;
-
- File cfigFile = new File(configLocation.getFile());
- File linkDir = new File(cfigFile.getParentFile(),LINKS+File.separator);
- File[] links = linkDir.listFiles();
- if (links==null || links.length==0) {
- if (DEBUG)
- debug("No links detected in "+linkDir.getAbsolutePath());
- return;
- }
-
- for (int i=0; i<links.length; i++) {
- if (links[i].isDirectory())
- continue;
- if (DEBUG)
- debug("Link file "+links[i].getAbsolutePath());
- Properties props = new Properties();
- FileInputStream is = null;
- try {
- is = new FileInputStream(links[i]);
- props.load(is);
- configureExternalLinkSites(links[i],props);
- } catch(IOException e) {
- if (DEBUG)
- debug(" unable to load link file "+e);
- continue;
- } finally {
- if (is != null) {
- try {
- is.close();
- } catch(IOException e) {
- }
- }
- }
- }
- }
-
- private void configureExternalLinkSites(File linkFile, Properties props) {
- String path = props.getProperty(LINK_PATH);
- if (path==null) {
- if (DEBUG)
- debug(" no path definition");
- return;
- }
-
- String[] links = stringListToArray(path,",");
-
- String link;
- boolean updateable;
- URL siteURL;
- SiteEntry linkSite;
- ISitePolicy linkSitePolicy = createSitePolicy(DEFAULT_POLICY_TYPE, DEFAULT_POLICY_LIST);
- for (int i=0; i<links.length; i++) {
- updateable = false;
- if (links[i].startsWith(LINK_READ+" ")) {
- link = links[i].substring(2).trim();
- } else if (links[i].startsWith(LINK_READ_WRITE+" ")) {
- updateable = true;
- link = links[i].substring(3).trim();
- } else {
- link = links[i];
- }
- try {
- link = "file:"+link;
- siteURL = new URL(link);
- } catch(MalformedURLException e) {
- if (DEBUG)
- debug(" bad URL "+e);
- continue;
- }
- linkSite = (SiteEntry) createSiteEntry(siteURL, linkSitePolicy);
- linkSite.updateable = updateable;
- linkSite.linkFileName = linkFile.getAbsolutePath();
- SiteEntry lastLinkSite = (SiteEntry) externalLinkSites.get(siteURL);
- if (lastLinkSite != null) {
- // restore previous change stamps
- linkSite.lastChangeStamp = lastLinkSite.lastChangeStamp;
- linkSite.lastFeaturesChangeStamp = lastLinkSite.lastFeaturesChangeStamp;
- linkSite.lastPluginsChangeStamp = lastLinkSite.lastPluginsChangeStamp;
- }
- configureSite(linkSite);
- if (DEBUG)
- debug(" "+(updateable?"R/W -> ":"R/O -> ")+siteURL.toString());
- }
- }
-
- private void load(URL url) throws IOException {
-
- if (url == null)
- throw new IOException(Policy.bind("cfig.unableToLoad.noURL"));
-
-
- // try to load saved configuration file
- Properties props = new Properties();
- InputStream is = null;
- try {
- is = url.openStream();
- props.load(is);
- // check to see if we have complete config file
- if (!EOF.equals(props.getProperty(EOF))) {
- throw new IOException(Policy.bind("cfig.unableToLoad.incomplete",url.toString()));
- }
- } finally {
- if (is!=null) {
- try {
- is.close();
- } catch(IOException e) {
- }
- }
- }
-
- // check version
- String v = props.getProperty(CFG_VERSION);
- if (!VERSION.equals(v)) {
- throw new IOException(Policy.bind("cfig.badVersion",v));
- }
-
- // load simple properties
- defaultFeature = loadAttribute(props, CFG_FEATURE_ENTRY_DEFAULT, null);
-
- String flag = loadAttribute(props, CFG_TRANSIENT, null);
- if (flag != null) {
- if (flag.equals("true"))
- transientConfig = true;
- else
- transientConfig = false;
- }
-
- String stamp = loadAttribute(props, CFG_STAMP, null);
- if (stamp != null) {
- try {
- lastChangeStamp = Long.parseLong(stamp);
- } catch(NumberFormatException e) {
- }
- }
-
- stamp = loadAttribute(props, CFG_FEATURE_STAMP, null);
- if (stamp != null) {
- try {
- lastFeaturesChangeStamp = Long.parseLong(stamp);
- } catch(NumberFormatException e) {
- }
- }
-
- stamp = loadAttribute(props, CFG_PLUGIN_STAMP, null);
- if (stamp != null) {
- try {
- lastPluginsChangeStamp = Long.parseLong(stamp);
- } catch(NumberFormatException e) {
- }
- }
-
- // load bootstrap entries
- String[] ids = getBootstrapPluginIdentifiers();
- for (int i=0; i<ids.length; i++) {
- bootPlugins.put(ids[i], loadAttribute(props, CFG_BOOT_PLUGIN + "." + ids[i], null));
- }
-
- // load feature entries
- IFeatureEntry fe = loadFeatureEntry(props, CFG_FEATURE_ENTRY+".0", null);
- for (int i=1; fe != null; i++) {
- configureFeatureEntry(fe);
- fe = loadFeatureEntry(props, CFG_FEATURE_ENTRY+"."+i, null);
- }
-
- // load site properties
- SiteEntry se = (SiteEntry) loadSite(props, CFG_SITE+".0", null);
- for (int i=1; se != null; i++) {
- if (!se.isExternallyLinkedSite())
- configureSite(se);
- else
- // remember external link site state, but do not configure
- externalLinkSites.put(se.getURL(),se);
- se = (SiteEntry) loadSite(props, CFG_SITE+"."+i, null);
- }
- }
-
- private ISiteEntry loadSite(Properties props, String name, ISiteEntry dflt) {
-
- String urlString = loadAttribute(props, name+"."+CFG_URL, null);
- if (urlString == null)
- return dflt;
-
- URL url = null;
- try {
- url = new URL(urlString);
- } catch(MalformedURLException e) {
- return dflt;
- }
-
- int policyType;
- String[] policyList;
- String typeString = loadAttribute(props, name+"."+CFG_POLICY, null);
- if (typeString == null) {
- policyType = DEFAULT_POLICY_TYPE;
- policyList = DEFAULT_POLICY_LIST;
- } else {
- int i;
- for (i=0; i<CFG_POLICY_TYPE.length; i++) {
- if (typeString.equals(CFG_POLICY_TYPE[i])) {
- break;
- }
- }
- if (i>=CFG_POLICY_TYPE.length) {
- policyType = DEFAULT_POLICY_TYPE;
- policyList = DEFAULT_POLICY_LIST;
- } else {
- policyType = i;
- policyList = loadListAttribute(props, name+"."+CFG_LIST, new String[0]);
- }
- }
-
- ISitePolicy sp = createSitePolicy(policyType, policyList);
- SiteEntry site = (SiteEntry) createSiteEntry(url,sp);
-
- String stamp = loadAttribute(props, name+"."+CFG_STAMP, null);
- if (stamp != null) {
- try {
- site.lastChangeStamp = Long.parseLong(stamp);
- } catch(NumberFormatException e) {
- }
- }
-
- stamp = loadAttribute(props, name+"."+CFG_FEATURE_STAMP, null);
- if (stamp != null) {
- try {
- site.lastFeaturesChangeStamp = Long.parseLong(stamp);
- } catch(NumberFormatException e) {
- }
- }
-
- stamp = loadAttribute(props, name+"."+CFG_PLUGIN_STAMP, null);
- if (stamp != null) {
- try {
- site.lastPluginsChangeStamp = Long.parseLong(stamp);
- } catch(NumberFormatException e) {
- }
- }
-
- String flag = loadAttribute(props, name+"."+CFG_UPDATEABLE, null);
- if (flag != null) {
- if (flag.equals("true"))
- site.updateable = true;
- else
- site.updateable = false;
- }
-
- String linkname = loadAttribute(props, name+"."+CFG_LINK_FILE, null);
- if (linkname != null && !linkname.equals("")) {
- site.linkFileName = linkname.replace('/',File.separatorChar);
- }
-
- return site;
- }
-
- private IFeatureEntry loadFeatureEntry(Properties props, String name, IFeatureEntry dflt) {
- String id = loadAttribute(props, name+"."+CFG_FEATURE_ENTRY_ID, null);
- if (id == null)
- return dflt;
- String version = loadAttribute(props, name+"."+CFG_FEATURE_ENTRY_VERSION, null);
- String application = loadAttribute(props, name+"."+CFG_FEATURE_ENTRY_APPLICATION, null);
- String rootString = loadAttribute(props, name+"."+CFG_FEATURE_ENTRY_ROOT, null);
- URL root = null;
- if (rootString != null)
- try {
- root = new URL(rootString);
- } catch (MalformedURLException e) {
- }
- return createFeatureEntry(id, version, application, root);
- }
-
- private String[] loadListAttribute(Properties props, String name, String[] dflt) {
- ArrayList list = new ArrayList();
- String value = loadAttribute(props, name+".0",null);
- if (value == null)
- return dflt;
-
- for (int i=1; value != null; i++) {
- loadListAttributeSegment(list, value);
- value = loadAttribute(props, name+"."+i, null);
- }
- return (String[])list.toArray(new String[0]);
- }
-
- private void loadListAttributeSegment(ArrayList list,String value) {
-
- if (value==null) return;
-
- StringTokenizer tokens = new StringTokenizer(value, ",");
- String token;
- while (tokens.hasMoreTokens()) {
- token = tokens.nextToken().trim();
- if (!token.equals(""))
- list.add(token);
- }
- return;
- }
-
- private String loadAttribute(Properties props, String name, String dflt) {
- String prop = props.getProperty(name);
- if (prop == null)
- return dflt;
- else
- return prop.trim();
- }
-
- private void loadInitializationAttributes(URL url) {
-
- if (url == null)
- return;
- if (defaultFeature != null)
- return; // already set
-
- // load any initialization attributes. These become the initial default settings
- // for critical attributes (eg. default primary feature) supplied by the packaging team.
- // Once these are reflected in the configuration they cannot be changed via the
- // initialization mechanism
- Properties initProps = new Properties();
- InputStream is = null;
- try {
- URL initURL = new URL(url, CONFIG_FILE_INIT);
- is = initURL.openStream();
- initProps.load(is);
- } catch(IOException e) {
- return; // could not load "first-time" settings
- } finally {
- if (is!=null) {
- try {
- is.close();
- } catch(IOException e) {
- }
- }
- }
-
- // use "first-time" settings if not already set
- defaultFeature = loadAttribute(initProps, INIT_DEFAULT_FEATURE_ID, null);
- if (defaultFeature != null) {
- String application = loadAttribute(initProps, INIT_DEFAULT_FEATURE_APPLICATION, null);
- IFeatureEntry fe = createFeatureEntry(defaultFeature, null, application, null);
- configureFeatureEntry(fe);
- }
- }
-
- private boolean isReadWriteLocation(URL url) {
- if (!url.getProtocol().equals("file"))
- return false;
-
- File f = new File(url.getFile());
- return f.canWrite();
- }
-
- private void write(PrintWriter w) {
- // write header
- w.println("# "+(new Date()).toString());
- writeAttribute(w, CFG_VERSION, VERSION);
- if (transientConfig)
- writeAttribute(w,CFG_TRANSIENT,"true");
- w.println("");
-
- // write global attributes
- writeAttribute(w,CFG_STAMP,Long.toString(getChangeStamp()));
- writeAttribute(w,CFG_FEATURE_STAMP,Long.toString(getFeaturesChangeStamp()));
- writeAttribute(w,CFG_PLUGIN_STAMP,Long.toString(getPluginsChangeStamp()));
-
- // write out bootstrap entries
- String[] ids = getBootstrapPluginIdentifiers();
- for (int i=0; i<ids.length; i++) {
- String location = (String) bootPlugins.get(ids[i]);
- if (location != null)
- writeAttribute(w, CFG_BOOT_PLUGIN + "." + ids[i], location);
- }
-
- // write out feature entries
- w.println("");
- writeAttribute(w,CFG_FEATURE_ENTRY_DEFAULT,defaultFeature);
- IFeatureEntry[] feats = getConfiguredFeatureEntries();
- for (int i=0; i<feats.length; i++) {
- writeFeatureEntry(w, CFG_FEATURE_ENTRY + "." + Integer.toString(i), feats[i]);
- }
-
- // write out site entries
- SiteEntry[] list = (SiteEntry[]) sites.values().toArray(new SiteEntry[0]);
- for (int i = 0; i < list.length; i++) {
- writeSite(w, CFG_SITE + "." + Integer.toString(i), list[i]);
- }
-
- // write end-of-file marker
- writeAttribute(w, EOF, EOF);
- }
-
- private void writeSite(PrintWriter w, String id, SiteEntry entry) {
-
- // write site separator
- w.println("");
-
- // write out site settings
- writeAttribute(w, id + "." + CFG_URL, entry.getURL().toString());
- writeAttribute(w, id + "." + CFG_STAMP,Long.toString(entry.getChangeStamp()));
- writeAttribute(w, id + "." + CFG_FEATURE_STAMP,Long.toString(entry.getFeaturesChangeStamp()));
- writeAttribute(w, id + "." + CFG_PLUGIN_STAMP,Long.toString(entry.getPluginsChangeStamp()));
- writeAttribute(w, id + "." + CFG_UPDATEABLE, entry.updateable?"true":"false");
- if (entry.linkFileName != null && !entry.linkFileName.trim().equals(""))
- writeAttribute(w, id + "." + CFG_LINK_FILE, entry.linkFileName.trim().replace(File.separatorChar,'/'));
-
- // write out site policy
- int type = entry.getSitePolicy().getType();
- String typeString = CFG_POLICY_TYPE_UNKNOWN;
- try {
- typeString = CFG_POLICY_TYPE[type];
- } catch (IndexOutOfBoundsException e) {
- }
- writeAttribute(w, id + "." + CFG_POLICY, typeString);
- writeListAttribute(w, id + "." + CFG_LIST, entry.getSitePolicy().getList());
- }
-
- private void writeFeatureEntry(PrintWriter w, String id, IFeatureEntry entry) {
-
- // write feature entry separator
- w.println("");
-
- // write out feature entry settings
- writeAttribute(w, id + "." + CFG_FEATURE_ENTRY_ID, entry.getFeatureIdentifier());
- writeAttribute(w, id + "." + CFG_FEATURE_ENTRY_VERSION, entry.getFeatureVersion());
- writeAttribute(w, id + "." + CFG_FEATURE_ENTRY_APPLICATION, entry.getFeatureApplication());
- writeAttribute(w, id + "." + CFG_FEATURE_ENTRY_ROOT, entry.getFeatureRootURL()==null ? null : entry.getFeatureRootURL().toExternalForm());
- }
-
- private void writeListAttribute(PrintWriter w, String id, String[] list) {
- if (list == null || list.length == 0)
- return;
-
- String value = "";
- int listLen = 0;
- int listIndex = 0;
- for (int i = 0; i < list.length; i++) {
- if (listLen != 0)
- value += ",";
- else
- value = "";
- value += list[i];
-
- if (++listLen >= CFG_LIST_LENGTH) {
- writeAttribute(w, id + "." + Integer.toString(listIndex++), value);
- listLen = 0;
- }
- }
- if (listLen != 0)
- writeAttribute(w, id + "." + Integer.toString(listIndex), value);
- }
-
- private void writeAttribute(PrintWriter w, String id, String value) {
- if (value==null || value.trim().equals(""))
- return;
- w.println(id + "=" + escapedValue(value));
- }
-
- private String escapedValue(String value) {
- // if required, escape property values as \\uXXXX
- StringBuffer buf = new StringBuffer(value.length()*2); // assume expansion by less than factor of 2
- for (int i=0; i<value.length(); i++) {
- char character = value.charAt(i);
- if (character == '\\'
- || character == '\t'
- || character == '\r'
- || character == '\n'
- || character == '\f') {
- // handle characters requiring leading \
- buf.append('\\');
- buf.append(character);
- } else if ((character < 0x0020) || (character > 0x007e)) {
- // handle characters outside base range (encoded)
- buf.append('\\');
- buf.append('u');
- buf.append(HEX[(character >> 12) & 0xF]); // first nibble
- buf.append(HEX[(character >> 8) & 0xF]); // second nibble
- buf.append(HEX[(character >> 4) & 0xF]); // third nibble
- buf.append(HEX[character & 0xF]); // fourth nibble
- } else {
- // handle base characters
- buf.append(character);
- }
- }
- return buf.toString();
- }
-
- private static String[] checkForFeatureChanges(String[] args, PlatformConfiguration cfg) {
- String original = cfg.getApplicationIdentifierInternal();
- String actual = cfg.getApplicationIdentifier();
-
- if (original.equals(actual))
- // base startup of specified application
- return args;
- else {
- // Will run reconciler.
- // Re-insert -application argument with original app
- String[] newArgs = new String[args.length+2];
- newArgs[0] = CMD_APPLICATION;
- newArgs[1] = original;
- System.arraycopy(args,0,newArgs,2,args.length);
- return newArgs;
- }
- }
-
- private static String[] processCommandLine(String[] args) throws Exception {
- int[] configArgs = new int[100];
- configArgs[0] = -1; // need to initialize the first element to something that could not be an index.
- int configArgIndex = 0;
- for (int i = 0; i < args.length; i++) {
- boolean found = false;
-
- // check for args without parameters (i.e., a flag arg)
-
- // look for the update flag
- if (args[i].equalsIgnoreCase(CMD_UPDATE)) {
- cmdUpdate = true;
- found = true;
- }
-
- // look for the no-update flag
- if (args[i].equalsIgnoreCase(CMD_NO_UPDATE)) {
- cmdNoUpdate = true;
- found = true;
- }
-
- // look for the development mode flag ... triggers no-update
- if (args[i].equalsIgnoreCase(CMD_DEV)) {
- cmdDev = true;
- continue; // do not remove from command line
- }
-
- if (found) {
- configArgs[configArgIndex++] = i;
- continue;
- }
-
- // check for args with parameters. If we are at the last argument or if the next one
- // has a '-' as the first character, then we can't have an arg with a parm so continue.
-
- if (i == args.length - 1 || args[i + 1].startsWith("-")) {
- continue;
- }
-
- String arg = args[++i];
-
- // look for the platform configuration to use.
- if (args[i - 1].equalsIgnoreCase(CMD_CONFIGURATION)) {
- found = true;
- cmdConfiguration = arg;
- }
-
- // look for the feature to use for customization.
- if (args[i - 1].equalsIgnoreCase(CMD_FEATURE)) {
- found = true;
- cmdFeature = arg;
- }
-
- // look for the application to run. Only use the value from the
- // command line if the application identifier was not explicitly
- // passed on BootLoader.run(...) invocation.
- if (args[i - 1].equalsIgnoreCase(CMD_APPLICATION)) {
- found = true;
- if (cmdApplication == null)
- cmdApplication = arg;
- }
-
- // R1.0 compatibility
- // look for the plugins location to use. Only use the value from the
- // command line if the plugins location was not explicitly passed on
- // BootLoader.run(...) or BootLoader.startup(...) invocation.
- if (args[i - 1].equalsIgnoreCase(CMD_PLUGINS)) {
- found = true;
- // if the arg can be made into a URL use it. Otherwise assume that
- // it is a file path so make a file URL.
- try {
- if (cmdPlugins == null)
- cmdPlugins = new URL(arg);
- } catch (MalformedURLException e) {
- try {
- cmdPlugins = new URL("file:" + arg);
- } catch (MalformedURLException e2) {
- }
- }
- }
-
- // done checking for args. Remember where an arg was found
- if (found) {
- configArgs[configArgIndex++] = i - 1;
- configArgs[configArgIndex++] = i;
- }
- }
-
- // remove all the arguments consumed by this argument parsing
- if (configArgIndex == 0)
- return args;
- String[] passThruArgs = new String[args.length - configArgIndex];
- configArgIndex = 0;
- int j = 0;
- for (int i = 0; i < args.length; i++) {
- if (i == configArgs[configArgIndex])
- configArgIndex++;
- else
- passThruArgs[j++] = args[i];
- }
- return passThruArgs;
- }
-
- private static URL getConfigurationURL(String configArg) throws MalformedURLException {
-
- // !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
- // NOTE:
- // Due to Eclipse class loader structure and class
- // visibility, the configuration file search is
- // implemented in 2 different classes:
- // org.eclipse.core.internal.boot.PlatformConfiguration
- // getConfigurationURL(String)
- // initializeCurrent(URL)
- // org.eclipse.core.launcher.Main
- // getConfigurationURL(String)
- // loadConfiguration(URL)
- // If you are making changes to this method make sure
- // the change is applied in both places
- // !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
-
- // Determine configuration URL to use (based on command line argument)
- // flag: -configuration COMMON | USER.HOME | USER.DIR | <url>
- // COMMON in <eclipse>/install/<cfig>
- // USER.HOME in <user.home>/eclipse/install/<cfig>
- // USER.DIR in <user.dir>/eclipse/install/<cfig>
- // <url> URL as specififed
- String tmp;
- URL result = null;
- if (configArg != null && !configArg.trim().equals("")) {
- if (configArg.equalsIgnoreCase(ARG_USER_DIR)) {
- tmp = System.getProperty("user.dir");
- if (!tmp.endsWith(File.separator))
- tmp += File.separator;
- result = new URL("file:" + tmp.replace(File.separatorChar,'/') + ECLIPSEDIR + "/" + INSTALL + "/" + CONFIG_FILE);
- } else if (configArg.equalsIgnoreCase(ARG_USER_HOME)) {
- tmp = System.getProperty("user.home");
- if (!tmp.endsWith(File.separator))
- tmp += File.separator;
- result = new URL("file:" + tmp.replace(File.separatorChar,'/') + ECLIPSEDIR + "/" + INSTALL + "/" + CONFIG_FILE);
- } else if (configArg.equalsIgnoreCase(ARG_COMMON)) {
- result = new URL(BootLoader.getInstallURL(), INSTALL + "/" + CONFIG_FILE);
- } else {
- try {
- result = new URL(configArg);
- } catch(MalformedURLException e) {
- throw new IllegalArgumentException(Policy.bind("cfig.badUrlArg",configArg));
- }
- }
- }
- return result;
- }
-
- /*
- * R1.0 compatibility mode ... -plugins was specified (possibly with -configuration)
- */
- private static String createConfigurationFromPlugins(URL file, String cfigCmd) throws Exception {
- // get the actual plugin path
- URL[] pluginPath = BootLoader.getPluginPath(file);
- if (pluginPath == null || pluginPath.length == 0)
- return null;
-
- // create a temp configuration and populate it based on plugin path
- PlatformConfiguration tempConfig = new PlatformConfiguration((URL)null);
- for (int i=0; i<pluginPath.length; i++) {
- String entry = pluginPath[i].toExternalForm();
- String sitePortion;
- String pluginPortion;
- int ix;
- if (entry.endsWith("/")) {
- // assume directory path in the form <site>/plugins/
- // look for -------------------------------^
- ix = findEntrySeparator(entry,2); // second from end
- sitePortion = entry.substring(0,ix+1);
- pluginPortion = entry.substring(ix+1);
- if (!pluginPortion.equals("plugins/"))
- continue; // unsupported entry ... skip it ("fragments/" are handled)
- pluginPortion = null;
- } else {
- // assume full path in the form <site>/<pluginsDir>/<some.plugin>/plugin.xml
- // look for --------------------------^
- ix = findEntrySeparator(entry, 3); // third from end
- sitePortion = entry.substring(0,ix+1);
- pluginPortion = entry.substring(ix+1);
- }
- if (ix == -1)
- continue; // bad entry ... skip it
-
- URL siteURL = null;
- try {
- siteURL = new URL(sitePortion);
- } catch (MalformedURLException e) {
- continue; // bad entry ... skip it
- }
-
- // configure existing site or create a new one for the entry
- ISiteEntry site = tempConfig.findConfiguredSite(siteURL);
- ISitePolicy policy;
- if (site == null) {
- // new site
- if (pluginPortion == null)
- policy = tempConfig.createSitePolicy(ISitePolicy.USER_EXCLUDE, null);
- else
- policy = tempConfig.createSitePolicy(ISitePolicy.USER_INCLUDE, new String[] { pluginPortion });
- site = tempConfig.createSiteEntry(siteURL,policy);
- tempConfig.configureSite(site);
- } else {
- // existing site
- policy = site.getSitePolicy();
- if (policy.getType() == ISitePolicy.USER_EXCLUDE)
- continue; // redundant entry ... skip it
- if (pluginPortion == null) {
- // directory entry ... change policy to exclusion (with empty list)
- policy = tempConfig.createSitePolicy(ISitePolicy.USER_EXCLUDE, null);
- } else {
- // explicit entry ... add it to the inclusion list
- ArrayList list = new ArrayList(Arrays.asList(policy.getList()));
- list.add(pluginPortion);
- policy = tempConfig.createSitePolicy(ISitePolicy.USER_INCLUDE,(String[])list.toArray(new String[0]));
- }
- site.setSitePolicy(policy);
- }
- }
-
- // check to see if configuration was specified. If specified, will be used to
- // persist the new configuration. Otherwise a transient configuration will be
- // created in temp space.
- URL tmpURL = null;
- if (cfigCmd != null && !cfigCmd.trim().equals("")) {
- try {
- tmpURL = getConfigurationURL(cfigCmd);
- try {
- // attemp to load the specified configuration. If found, merge
- // it with the newly computed one. The merge algorithm includes
- // sites from the old configuration that are not part of the new
- // configuration. Note, that this does not provide for a complete
- // merge, but the assumption is that if -plugins was specified,
- // the sites included in the specification are explicitly
- // controlled.
- PlatformConfiguration oldConfig = new PlatformConfiguration(tmpURL);
- ISiteEntry[] oldSites = oldConfig.getConfiguredSites();
- for (int i=0; i<oldSites.length; i++) {
- tempConfig.configureSite(oldSites[i], false /*do not replace*/);
- }
- } catch(IOException e) {
- }
- } catch(MalformedURLException e) {
- }
- }
-
- if (tmpURL == null) {
- // save the configuration in temp location
- String tmpDirName = System.getProperty("java.io.tmpdir");
- if (!tmpDirName.endsWith(File.separator))
- tmpDirName += File.separator;
- tmpDirName += Long.toString((new Date()).getTime()) + File.separator;
- File tmpDir = new File(tmpDirName);
- tmpDir.mkdirs();
- tmpDir.deleteOnExit();
- File tmpCfg = File.createTempFile("platform",".cfg",tmpDir);
- tmpCfg.deleteOnExit();
- tmpURL = new URL("file:" + tmpCfg.getAbsolutePath().replace(File.separatorChar, '/'));
- tempConfig.transientConfig = true;
- }
-
- // force writing null stamps
- ISiteEntry[] se = tempConfig.getConfiguredSites();
- for (int i=0; i<se.length; i++) {
- ((SiteEntry)se[i]).changeStampIsValid = true;
- ((SiteEntry)se[i]).pluginsChangeStampIsValid = true;
- ((SiteEntry)se[i]).featuresChangeStampIsValid = true;
- }
- tempConfig.changeStampIsValid = true;
- tempConfig.pluginsChangeStampIsValid = true;
- tempConfig.featuresChangeStampIsValid = true;
-
- // write out configuration
- tempConfig.save(tmpURL); // write the temporary configuration we just created
-
-
- // return reference to new configuration
- return tmpURL.toExternalForm();
- }
-
- private static int findEntrySeparator(String pathEntry, int cnt) {
- for (int i=pathEntry.length()-1; i>=0; i--) {
- if (pathEntry.charAt(i) == '/') {
- if (--cnt == 0)
- return i;
- }
- }
- return -1;
- }
-
- private static String[] stringListToArray(String prop, String separator) {
- if (prop == null || prop.trim().equals(""))
- return new String[0];
- ArrayList list = new ArrayList();
- StringTokenizer tokens = new StringTokenizer(prop, separator);
- while (tokens.hasMoreTokens()) {
- String token = tokens.nextToken().trim();
- if (!token.equals(""))
- list.add(token);
- }
- return list.isEmpty() ? new String[0] : (String[]) list.toArray(new String[0]);
- }
-
- private static boolean supportsDetection(URL url) {
- String protocol = url.getProtocol();
- if (protocol.equals("file"))
- return true;
- else if (protocol.equals(PlatformURLHandler.PROTOCOL)) {
- URL resolved = null;
- try {
- resolved = ((PlatformURLConnection)url.openConnection()).getResolvedURL();
- } catch(IOException e) {
- return false; // we tried but failed to resolve the platform URL
- }
- return resolved.getProtocol().equals("file");
- } else
- return false;
- }
-
- private static void verifyPath(URL url) {
- String protocol = url.getProtocol();
- String path = null;
- if (protocol.equals("file"))
- path = url.getFile();
- else if (protocol.equals(PlatformURLHandler.PROTOCOL)) {
- URL resolved = null;
- try {
- resolved = ((PlatformURLConnection)url.openConnection()).getResolvedURL();
- if (resolved.getProtocol().equals("file"))
- path = resolved.getFile();
- } catch(IOException e) {
- }
- }
-
- if (path != null) {
- File dir = new File(path).getParentFile();
- if (dir != null)
- dir.mkdirs();
- }
- }
-
- private static void debug(String s) {
- System.out.println("PlatformConfig: " + s);
- }
-}
\ No newline at end of file
diff --git a/bundles/org.eclipse.core.boot/src/org/eclipse/core/internal/boot/PlatformURLBaseConnection.java b/bundles/org.eclipse.core.boot/src/org/eclipse/core/internal/boot/PlatformURLBaseConnection.java
deleted file mode 100644
index 79b584e..0000000
--- a/bundles/org.eclipse.core.boot/src/org/eclipse/core/internal/boot/PlatformURLBaseConnection.java
+++ /dev/null
@@ -1,47 +0,0 @@
-package org.eclipse.core.internal.boot;
-
-/*
- * (c) Copyright IBM Corp. 2000, 2001.
- * All Rights Reserved.
- */
-
-/**
- * Platform URL support
- * platform:/base/ maps to platform installation location
- */
-
-import java.net.*;
-import java.io.*;
-import java.util.*;
-
-public class PlatformURLBaseConnection extends PlatformURLConnection {
-
- // platform/ protocol
- public static final String PLATFORM = "base";
- public static final String PLATFORM_URL_STRING = PlatformURLHandler.PROTOCOL+PlatformURLHandler.PROTOCOL_SEPARATOR+"/"+PLATFORM+"/";
-
- private static URL installURL;
-public PlatformURLBaseConnection(URL url) {
- super(url);
-}
-protected boolean allowCaching() {
- return true;
-}
-protected URL resolve() throws IOException {
- String spec = url.getFile().trim();
- if (spec.startsWith("/"))
- spec = spec.substring(1);
- if (!spec.startsWith(PLATFORM+"/")) {
- String message = Policy.bind("url.badVariant", url.toString());
- throw new IOException(message);
- }
- return spec.length()==PLATFORM.length()+1 ? installURL : new URL(installURL,spec.substring(PLATFORM.length()+1));
-}
-public static void startup(URL url) {
-
- // register connection type for platform:/base/ handling
- if (installURL!=null) return;
- installURL = url;
- PlatformURLHandler.register(PLATFORM, PlatformURLBaseConnection.class);
-}
-}
diff --git a/bundles/org.eclipse.core.boot/src/org/eclipse/core/internal/boot/PlatformURLConnection.java b/bundles/org.eclipse.core.boot/src/org/eclipse/core/internal/boot/PlatformURLConnection.java
deleted file mode 100644
index 68dde5e..0000000
--- a/bundles/org.eclipse.core.boot/src/org/eclipse/core/internal/boot/PlatformURLConnection.java
+++ /dev/null
@@ -1,454 +0,0 @@
-package org.eclipse.core.internal.boot;
-
-/*
- * (c) Copyright IBM Corp. 2000, 2001.
- * All Rights Reserved.
- */
-
-/**
- * Platform URL support
- */
-
-import java.net.*;
-import java.io.*;
-import java.util.*;
-
-public abstract class PlatformURLConnection extends URLConnection {
-
- // URL access
- private boolean isInCache = false;
- private boolean isJar = false;
-
-// protected URL url; // declared in super (platform: URL)
- private URL resolvedURL = null; // resolved file URL (eg. http: URL)
- private URL cachedURL = null; // file URL in cache (file: URL)
-
- private URLConnection connection = null; // actual connection
-
- // local cache
- private static Properties cacheIndex = new Properties();
- private static String cacheLocation;
- private static String indexName;
- private static String filePrefix;
-
- // constants
- private static final int BUF_SIZE = 32768;
- private static final Object NOT_FOUND = new Object(); // marker
- private static final String CACHE_PROP = ".cache.properties";
- private static final String CACHE_LOCATION_PROP = "location";
- private static final String CACHE_INDEX_PROP = "index";
- private static final String CACHE_PREFIX_PROP = "prefix";
- private static final String CACHE_INDEX = ".index.properties";
- private static final String CACHE_DIR = PlatformURLHandler.PROTOCOL + File.separator;
-
- // debug tracing
- public static boolean DEBUG = false;
- public static boolean DEBUG_CONNECT = true;
- public static boolean DEBUG_CACHE_LOOKUP = true;
- public static boolean DEBUG_CACHE_COPY = true;
-protected PlatformURLConnection(URL url) {
- super(url);
-}
-protected boolean allowCaching() {
- return false;
-}
-public void connect() throws IOException {
- connect(false);
-}
-private synchronized void connect(boolean asLocal) throws IOException {
- if (!connected) {
- if (shouldCache(asLocal)) {
- try {
- URL inCache = getURLInCache();
- if (inCache!=null) connection = inCache.openConnection();
- } catch(IOException e) {
- // failed to cache ... will use resolved URL instead
- }
- }
-
- // use resolved URL
- if (connection==null) connection = resolvedURL.openConnection();
- connected = true;
- if (DEBUG && DEBUG_CONNECT)
- debug("Connected as "+connection.getURL());
- }
-}
-private void copyToCache() throws IOException {
-
- if (isInCache | cachedURL==null) return;
- String tmp;
- int ix;
-
- // cache entry key
- String key;
- if (isJar) {
- tmp = url.getFile();
- ix = tmp.lastIndexOf(PlatformURLHandler.JAR_SEPARATOR);
- if (ix!=-1) tmp = tmp.substring(0,ix);
- key = tmp;
- }
- else key = url.getFile();
-
- // source url
- URL src;
- if (isJar) {
- tmp = resolvedURL.getFile();
- ix = tmp.lastIndexOf(PlatformURLHandler.JAR_SEPARATOR);
- if (ix!=-1) tmp = tmp.substring(0,ix);
- src = new URL(tmp);
- }
- else src = resolvedURL;
- InputStream srcis = null;
-
- // cache target
- String tgt;
- if (isJar) {
- tmp = cachedURL.getFile();
- ix = tmp.indexOf(PlatformURLHandler.PROTOCOL_SEPARATOR);
- if (ix!=-1) tmp = tmp.substring(ix+1);
- ix = tmp.lastIndexOf(PlatformURLHandler.JAR_SEPARATOR);
- if (ix!=-1) tmp = tmp.substring(0,ix);
- tgt = tmp;
- }
- else tgt = cachedURL.getFile();
- File tgtFile = null;
- FileOutputStream tgtos = null;
-
- boolean error = false;
- long total = 0;
-
- try {
- if (DEBUG && DEBUG_CACHE_COPY) {
- if (isJar) debug ("Caching jar as "+tgt);
- else debug("Caching as "+tgt);
- }
-
- srcis = src.openStream();
- byte[] buf = new byte[BUF_SIZE];
- int count = srcis.read(buf);
-
- tgtFile = new File(tgt);
- tgtos = new FileOutputStream(tgtFile);
-
- while(count!=-1) {
- total += count;
- tgtos.write(buf,0,count);
- count = srcis.read(buf);
- }
-
- srcis.close();
- srcis=null;
- tgtos.close();
- tgtos=null;
-
- // add cache entry
- cacheIndex.put(key,tgt);
- isInCache = true;
- }
- catch(IOException e) {
- error = true;
- cacheIndex.put(key,NOT_FOUND); // mark cache entry for this execution
- if (DEBUG && DEBUG_CACHE_COPY)
- debug("Failed to cache due to "+e);
- throw e;
- }
- finally {
- if (!error && DEBUG && DEBUG_CACHE_COPY)
- debug(total + " bytes copied");
- if (srcis!=null) srcis.close();
- if (tgtos!=null) tgtos.close();
- }
-}
-protected void debug(String s) {
-
- System.out.println("URL "+getURL().toString()+"^"+Integer.toHexString(Thread.currentThread().hashCode())+" "+s);
-}
-private static void debugStartup(String s) {
-
- System.out.println("URL "+s);
-}
-public URL[] getAuxillaryURLs () throws IOException {
- return null;
-}
-public synchronized InputStream getInputStream() throws IOException {
- if (!connected) connect();
- return connection.getInputStream();
-}
-public URL getResolvedURL() {
- return resolvedURL;
-}
-public URL getURLAsLocal() throws IOException {
- connect(true); // connect and force caching if necessary
- URL u = connection.getURL();
- String up = u.getProtocol();
- if (!up.equals(PlatformURLHandler.FILE) && !up.equals(PlatformURLHandler.JAR) && !up.equals(PlatformURLHandler.VA)) throw new IOException("Unable to access URL as local "+url.toString());
- return u;
-}
-private URL getURLInCache() throws IOException {
-
- if (!allowCaching()) return null; // target should not be cached
-
- if (isInCache) return cachedURL;
-
- if (cacheLocation==null | cacheIndex==null) return null; // not caching
-
- // check if we are dealing with a .jar/ .zip
- String file = "";
- String jarEntry = null;
- if (isJar) {
- file = url.getFile();
- int ix = file.lastIndexOf(PlatformURLHandler.JAR_SEPARATOR);
- if (ix!=-1) {
- jarEntry = file.substring(ix+PlatformURLHandler.JAR_SEPARATOR.length());
- file = file.substring(0,ix);
- }
- }
- else {
- file = url.getFile();
- jarEntry = null;
- }
-
- // check for cached entry
- String tmp = (String)cacheIndex.get(file);
-
- // check for "not found" marker
- if (tmp!=null && tmp==NOT_FOUND) throw new IOException();
-
- // validate cache entry
- if (tmp!=null && !(new File(tmp)).exists()) {
- tmp = null;
- cacheIndex.remove(url.getFile());
- }
-
- // found in cache
- if (tmp!=null) {
- if (isJar) {
- if (DEBUG && DEBUG_CACHE_LOOKUP)
- debug("Jar located in cache as "+tmp);
- tmp = PlatformURLHandler.FILE + PlatformURLHandler.PROTOCOL_SEPARATOR + tmp + PlatformURLHandler.JAR_SEPARATOR + jarEntry;
- cachedURL = new URL(PlatformURLHandler.JAR,null,-1,tmp);
- }
- else {
- if (DEBUG && DEBUG_CACHE_LOOKUP)
- debug("Located in cache as "+tmp);
- cachedURL = new URL(PlatformURLHandler.FILE,null,-1,tmp);
- }
- isInCache = true;
- }
- else {
- // attemp to cache
- int ix = file.lastIndexOf("/");
- tmp = file.substring(ix+1);
- tmp = cacheLocation + filePrefix + Long.toString((new java.util.Date()).getTime()) + "_" + tmp;
- tmp = tmp.replace(File.separatorChar,'/');
- if (isJar) {
- tmp = PlatformURLHandler.FILE + PlatformURLHandler.PROTOCOL_SEPARATOR + tmp + PlatformURLHandler.JAR_SEPARATOR + jarEntry;
- cachedURL = new URL(PlatformURLHandler.JAR,null,-1,tmp);
- }
- else cachedURL = new URL(PlatformURLHandler.FILE,null,-1,tmp);
- copyToCache();
- }
-
- return cachedURL;
-}
-/*
- * to be implemented by subclass
- * @return URL resolved URL
- */
-
-protected URL resolve() throws IOException {
- throw new IOException();
-}
-
-private String resolvePath(String spec) {
- if (spec.length() == 0 || spec.charAt(0) != '$')
- return spec;
- int i = spec.indexOf('/', 1);
- String first = "";
- String rest = "";
- if (i == -1)
- first = spec;
- else {
- first = spec.substring(0, i);
- rest = spec.substring(i);
- }
- if (first.equalsIgnoreCase("$ws$"))
- return "ws/" + InternalBootLoader.getWS() + rest;
- if (first.equalsIgnoreCase("$os$"))
- return "os/" + InternalBootLoader.getOS() + rest;
- if (first.equalsIgnoreCase("$nl$")) {
- String nl = InternalBootLoader.getNL();
- nl = nl.replace('_', '/');
- return "nl/" + nl + rest;
- }
- return spec;
-}
-
-protected String getId(String spec) {
- int i = spec.lastIndexOf('_');
- return i >= 0 ? spec.substring(0, i) : spec;
-}
-
-protected String getVersion(String spec) {
- int i = spec.lastIndexOf('_');
- return i >= 0 ? spec.substring(i + 1, spec.length()) : "";
-}
-
-void setResolvedURL(URL url) throws IOException {
- if (resolvedURL==null) {
- int ix = url.getFile().lastIndexOf(PlatformURLHandler.JAR_SEPARATOR);
- isJar = -1 != ix;
- // Resolved URLs containing !/ separator are assumed to be jar URLs.
- // If the resolved protocol is not jar, new jar URL is created.
- if (isJar && !url.getProtocol().equals(PlatformURLHandler.JAR))
- url = new URL(PlatformURLHandler.JAR,"",-1,url.toExternalForm());
- resolvedURL=url;
- }
-}
-private boolean shouldCache(boolean asLocal) {
-
- // don't cache files that are known to be local
- String rp = resolvedURL.getProtocol();
- String rf = resolvedURL.getFile();
- if (rp.equals(PlatformURLHandler.FILE) || rp.equals(PlatformURLHandler.VA)) return false;
- if (rp.equals(PlatformURLHandler.JAR) && (rf.startsWith(PlatformURLHandler.FILE) || rf.startsWith(PlatformURLHandler.VA) )) return false;
-
- // for other files force caching if local connection was requested
- if (asLocal) return true;
-
- // for now cache all files
- // XXX: add cache policy support
- return true;
-}
-static void shutdown() {
- if (indexName!=null && cacheLocation!=null) {
- // weed out "not found" entries
- Enumeration keys = cacheIndex.keys();
- String key;
- Object value;
- while (keys.hasMoreElements()) {
- key = (String) keys.nextElement();
- value = cacheIndex.get(key);
- if (value==NOT_FOUND) cacheIndex.remove(key);
- }
- //if the cache index is empty we don't need to save it
- if (cacheIndex.size() == 0)
- return;
- try {
- // try to save cache index
- FileOutputStream fos = null;
- fos = new FileOutputStream(cacheLocation+indexName);
- try {
- cacheIndex.store(fos,null);
- } finally {
- fos.close();
- }
- }
- catch(IOException e) {
- // failed to store cache index ... ignore
- }
- }
-}
-static void startup(String location) {
-
-
- verifyLocation(location); // check for platform location, ignore errors
- String cacheProps = location.trim();
- if (!cacheProps.endsWith(File.separator)) cacheProps += File.separator;
- cacheProps += CACHE_PROP;
- File cachePropFile = new File(cacheProps);
- Properties props = null;
- FileInputStream fis;
-
- if (cachePropFile.exists()) {
- // load existing properties
- try {
- props = new Properties();
- fis = new FileInputStream(cachePropFile);
- try {
- props.load(fis);
- }
- finally {
- fis.close();
- }
- }
- catch(IOException e) {
- props = null;
- }
- }
-
- if (props==null) {
- // first time up, or failed to load previous settings
- props = new Properties();
- String tmp = System.getProperty("java.io.tmpdir");
- if (!tmp.endsWith(File.separator)) tmp += File.separator;
- tmp += CACHE_DIR;
- props.put(CACHE_LOCATION_PROP,tmp);
-
- tmp = Long.toString((new java.util.Date()).getTime());
- props.put(CACHE_PREFIX_PROP,tmp);
-
- tmp += CACHE_INDEX;
- props.put(CACHE_INDEX_PROP,tmp);
-
- // save for next time around
- FileOutputStream fos = null;
- try {
- fos = new FileOutputStream(cachePropFile);
- try {
- props.store(fos,null);
- }
- finally {
- fos.close();
- }
- }
- catch(IOException e) {
- // failed to store cache location metadata ... ignore
- }
- }
-
- // remember settings for shutdown processing
- filePrefix = (String)props.get(CACHE_PREFIX_PROP);
- indexName = (String)props.get(CACHE_INDEX_PROP);
- cacheLocation = (String)props.get(CACHE_LOCATION_PROP);
-
- if (DEBUG) {
- debugStartup("Cache location: " + cacheLocation);
- debugStartup("Cache index: " + indexName);
- debugStartup("Cache file prefix: " + filePrefix);
- }
-
- // create cache directory structure if needed
- if (!verifyLocation(cacheLocation)) {
- indexName = null;
- cacheLocation = null;
- if (DEBUG)
- debugStartup("Failed to create cache directory structure. Caching suspended");
- return;
- }
-
- // attempt to initialize cache index
- if (cacheLocation!=null && indexName!=null) {
- try {
- fis = new FileInputStream(cacheLocation+indexName);
- try {
- cacheIndex.load(fis);
- }
- finally {
- fis.close();
- }
- }
- catch(IOException e) {
- if (DEBUG)
- debugStartup("Failed to initialize cache");
- }
- }
-}
-private static boolean verifyLocation(String location) {
- // verify cache directory exists. Create if needed
- File cacheDir = new File(location);
- if (cacheDir.exists())
- return true;
- return cacheDir.mkdirs();
-}
-}
diff --git a/bundles/org.eclipse.core.boot/src/org/eclipse/core/internal/boot/PlatformURLHandler.java b/bundles/org.eclipse.core.boot/src/org/eclipse/core/internal/boot/PlatformURLHandler.java
deleted file mode 100644
index 65c33d2..0000000
--- a/bundles/org.eclipse.core.boot/src/org/eclipse/core/internal/boot/PlatformURLHandler.java
+++ /dev/null
@@ -1,67 +0,0 @@
-package org.eclipse.core.internal.boot;
-
-/*
- * (c) Copyright IBM Corp. 2000, 2001.
- * All Rights Reserved.
- */
-
-import java.net.*;
-import java.io.IOException;
-import java.util.Hashtable;
-import java.lang.reflect.Constructor;
-
- /**
- * URL handler for the "platform" protocol
- */
-public class PlatformURLHandler extends URLStreamHandler {
-
- private static Hashtable connectionType = new Hashtable();
-
- // URL protocol designations
- public static final String PROTOCOL = "platform";
- public static final String FILE = "file";
- public static final String JAR = "jar";
- public static final String VA = "valoader";
- public static final String JAR_SEPARATOR = "!/";
- public static final String PROTOCOL_SEPARATOR = ":";
-protected PlatformURLHandler() {
- super();
-}
-public URLConnection openConnection(URL url) throws IOException {
- // Note: openConnection() method is made public (rather than protected)
- // to enable request delegation from proxy handlers
-
- String spec = url.getFile().trim();
- if (spec.startsWith("/")) spec = spec.substring(1);
- int ix = spec.indexOf("/");
- if (ix==-1) {
- String message = Policy.bind("url.invalidURL", url.toString());
- throw new MalformedURLException(message);
- }
-
- String type = spec.substring(0,ix);
- Constructor construct = (Constructor) connectionType.get(type);
- if (construct==null) {
- String message = Policy.bind("url.badVariant", url.toString());
- throw new MalformedURLException(message);
- }
-
- PlatformURLConnection c = null;
- try {
- c = (PlatformURLConnection) construct.newInstance(new Object[] { url });
- }
- catch(Exception e) {
- String message = Policy.bind("url.createConnection", url.toString());
- throw new IOException(message);
- }
- c.setResolvedURL(c.resolve());
- return c;
-}
-public static void register(String type, Class connectionClass) {
- try {
- Constructor c = connectionClass.getConstructor(new Class[] { URL.class });
- connectionType.put(type, c);
- }
- catch(NoSuchMethodException e) {}
-}
-}
diff --git a/bundles/org.eclipse.core.boot/src/org/eclipse/core/internal/boot/PlatformURLHandlerFactory.java b/bundles/org.eclipse.core.boot/src/org/eclipse/core/internal/boot/PlatformURLHandlerFactory.java
deleted file mode 100644
index f35581c..0000000
--- a/bundles/org.eclipse.core.boot/src/org/eclipse/core/internal/boot/PlatformURLHandlerFactory.java
+++ /dev/null
@@ -1,84 +0,0 @@
-package org.eclipse.core.internal.boot;
-
-/*
- * (c) Copyright IBM Corp. 2000, 2001.
- * All Rights Reserved.
- */
-
-import java.net.URL;
-import java.net.URLStreamHandler;
-import java.net.URLStreamHandlerFactory;
-import java.util.Hashtable;
-import java.util.Properties;
-
-import org.eclipse.core.boot.BootLoader;
-
-public class PlatformURLHandlerFactory implements URLStreamHandlerFactory {
-
- private static Hashtable handlers = new Hashtable();
-
- private static final String ECLIPSE_HANDLER_FACTORY = "org.eclipse.protocol.handler.factory";
-
-public PlatformURLHandlerFactory() {
- super();
-
- // register eclipse handler
- handlers.put(PlatformURLHandler.PROTOCOL, new PlatformURLHandler());
-}
-public URLStreamHandler createURLStreamHandler(String protocol) {
-
- URLStreamHandler handler = null;
-
- // check for cached handler
- Object element = handlers.get(protocol);
- if (element==null) return null;
- if (element instanceof URLStreamHandler) handler = (URLStreamHandler)element;
- else {
- // convert registered factory to a handler
- URLStreamHandlerFactory f = (URLStreamHandlerFactory) element;
- handler = f.createURLStreamHandler(protocol);
- if (handler!=null) handlers.put(protocol, handler);
- else handlers.remove(protocol); // bad entry
- }
- return handler;
-}
-public static void register(String protocol, URLStreamHandlerFactory factory) {
- if (protocol.equals(PlatformURLHandler.PROTOCOL)) return; // just in case ...
- handlers.put(protocol,factory);
-}
-public static void shutdown() {
-
- PlatformURLHandlerFactoryProxy p = PlatformURLHandlerFactoryProxy.getFactoryProxy();
- if (p!=null) p.setFactory(null);
- PlatformURLConnection.shutdown();
-}
-public static void startup(String location) {
-
- PlatformURLHandlerFactoryProxy p = PlatformURLHandlerFactoryProxy.getFactoryProxy();
- if (p==null) {
- p = new PlatformURLHandlerFactoryProxy();
- try {
- URL.setURLStreamHandlerFactory(p);
- } catch(Error e) {
- // Application has already set the factory. This is, for example,
- // the case when Eclipse is running as part of a servlet on
- // some web application servers. In this case we come up in
- // "toleration" mode where Eclipse URL protocols are handled
- // via explicitly supplied protocol proxy handlers using the base
- // Java convention. Eclipse "registers" its stream factory
- // using a system property. The explicit proxy handlers
- // then delegate to the Eclipse handlers via the factory looked
- // up as a Java property.
- Properties props = System.getProperties();
- props.put(ECLIPSE_HANDLER_FACTORY, p);
- System.setProperties(props);
- if (BootLoader.inDebugMode()){
- System.out.println("WARNING: Unable to set URLStreamHandlerFactory.");
- System.out.println("WARNING: Starting in toleration mode.");
- }
- }
- }
- p.setFactory(new PlatformURLHandlerFactory());
- PlatformURLConnection.startup(location);
-}
-}
diff --git a/bundles/org.eclipse.core.boot/src/org/eclipse/core/internal/boot/PlatformURLHandlerFactoryProxy.java b/bundles/org.eclipse.core.boot/src/org/eclipse/core/internal/boot/PlatformURLHandlerFactoryProxy.java
deleted file mode 100644
index 590bda5..0000000
--- a/bundles/org.eclipse.core.boot/src/org/eclipse/core/internal/boot/PlatformURLHandlerFactoryProxy.java
+++ /dev/null
@@ -1,32 +0,0 @@
-package org.eclipse.core.internal.boot;
-
-/*
- * (c) Copyright IBM Corp. 2000, 2001.
- * All Rights Reserved.
- */
-
-import java.net.*;
-
-public class PlatformURLHandlerFactoryProxy implements URLStreamHandlerFactory {
-
- private static PlatformURLHandlerFactoryProxy p = null; // singleton - set into URL as factory
- private PlatformURLHandlerFactory f = null; // current actual factory
-PlatformURLHandlerFactoryProxy() {
- super();
- if (p==null) p = this;
-}
-public URLStreamHandler createURLStreamHandler(String protocol) {
-
- if (f==null) return null;
- else return f.createURLStreamHandler(protocol);
-}
-PlatformURLHandlerFactory getFactory() {
- return f;
-}
-static PlatformURLHandlerFactoryProxy getFactoryProxy() {
- return p;
-}
-void setFactory(PlatformURLHandlerFactory factory) {
- f = factory;
-}
-}
diff --git a/bundles/org.eclipse.core.boot/src/org/eclipse/core/internal/boot/Policy.java b/bundles/org.eclipse.core.boot/src/org/eclipse/core/internal/boot/Policy.java
deleted file mode 100644
index b52f066..0000000
--- a/bundles/org.eclipse.core.boot/src/org/eclipse/core/internal/boot/Policy.java
+++ /dev/null
@@ -1,91 +0,0 @@
-package org.eclipse.core.internal.boot;
-
-/*
- * (c) Copyright IBM Corp. 2000, 2001.
- * All Rights Reserved.
- */
-
-import java.util.*;
-
-public class Policy {
- private static ResourceBundle bundle;
- private static String bundleName = "org.eclipse.core.internal.boot.messages";
-
- static {
- relocalize();
- }
-
-/**
- * Lookup the message with the given ID in this catalog
- */
-public static String bind(String id) {
- return bind(id, (String[])null);
-}
-/**
- * Lookup the message with the given ID in this catalog and bind its
- * substitution locations with the given string.
- */
-public static String bind(String id, String binding) {
- return bind(id, new String[] {binding});
-}
-/**
- * Lookup the message with the given ID in this catalog and bind its
- * substitution locations with the given strings.
- */
-public static String bind(String id, String binding1, String binding2) {
- return bind(id, new String[] {binding1, binding2});
-}
-
-/**
- * Lookup the message with the given ID in this catalog and bind its
- * substitution locations with the given string values.
- */
-public static String bind(String id, String[] bindings) {
- if (id == null)
- return "No message available";
- String message = null;
- try {
- message = bundle.getString(id);
- } catch (MissingResourceException e) {
- // If we got an exception looking for the message, fail gracefully by just returning
- // the id we were looking for. In most cases this is semi-informative so is not too bad.
- return "Missing message: " + id + " in: " + bundleName;
- }
- if (bindings == null)
- return message;
- int length = message.length();
- int start = -1;
- int end = length;
- StringBuffer output = new StringBuffer(80);
- while (true) {
- if ((end = message.indexOf('{', start)) > -1) {
- output.append(message.substring(start + 1, end));
- if ((start = message.indexOf('}', end)) > -1) {
- int index = -1;
- try {
- index = Integer.parseInt(message.substring(end + 1, start));
- output.append(bindings[index]);
- } catch (NumberFormatException nfe) {
- output.append(message.substring(end + 1, start + 1));
- } catch (ArrayIndexOutOfBoundsException e) {
- output.append("{missing " + Integer.toString(index) + "}");
- }
- } else {
- output.append(message.substring(end, length));
- break;
- }
- } else {
- output.append(message.substring(start + 1, length));
- break;
- }
- }
- return output.toString();
-}
-
-/**
- * Creates a NLS catalog for the given locale.
- */
-public static void relocalize() {
- bundle = ResourceBundle.getBundle(bundleName, Locale.getDefault());
-}
-}
diff --git a/bundles/org.eclipse.core.boot/src/org/eclipse/core/internal/boot/ResourceEnumeration.java b/bundles/org.eclipse.core.boot/src/org/eclipse/core/internal/boot/ResourceEnumeration.java
deleted file mode 100644
index 558cc9d..0000000
--- a/bundles/org.eclipse.core.boot/src/org/eclipse/core/internal/boot/ResourceEnumeration.java
+++ /dev/null
@@ -1,74 +0,0 @@
-package org.eclipse.core.internal.boot;
-
-/*
- * (c) Copyright IBM Corp. 2000, 2001.
- * All Rights Reserved.
- */
-
-import java.util.*;
-import java.net.URL;
-
-/**
- * Compound enumeration with visibility filtering.
- * Used in implementation of ClassLoader.getResources()
- */
-
-class ResourceEnumeration implements Enumeration {
- private Vector enums = new Vector();
- private String name;
- private int ix = 0;
- private Object nextElement = null;
- private DelegatingURLClassLoader current;
- private DelegatingURLClassLoader requestor;
-public ResourceEnumeration(String name, Enumeration e, DelegatingURLClassLoader current, DelegatingURLClassLoader requestor) {
- this.name = name;
- if (e == null)
- e = new Enumeration() {
- public boolean hasMoreElements() {
- return false;
- }
- public Object nextElement() {
- return null;
- }
- };
- enums.add(e);
- this.current = current;
- this.requestor = requestor;
-}
-public void add(Enumeration e) {
- if (e == null)
- return;
- enums.add(e);
-}
-public boolean hasMoreElements() {
- if (nextElement != null)
- return true;
- nextElement = nextVisibleElement();
- return nextElement != null;
-}
-public Object nextElement() {
- if (nextElement != null) {
- Object result = nextElement;
- nextElement = null;
- return result;
- } else
- return nextVisibleElement();
-}
-private Object nextVisibleElement() {
- Enumeration e;
- Object element = null;
- while (element == null && ix < enums.size()) {
- e = (Enumeration) enums.elementAt(ix);
- while (element == null && e.hasMoreElements()) {
- element = e.nextElement();
- if (ix == 0) {
- if (!current.isResourceVisible(name, (URL) element, requestor))
- element = null;
- }
- }
- if (element == null)
- ix++;
- }
- return element;
-}
-}
diff --git a/bundles/org.eclipse.core.boot/src/org/eclipse/core/internal/boot/ResourceLoader.java b/bundles/org.eclipse.core.boot/src/org/eclipse/core/internal/boot/ResourceLoader.java
deleted file mode 100644
index 9d562aa..0000000
--- a/bundles/org.eclipse.core.boot/src/org/eclipse/core/internal/boot/ResourceLoader.java
+++ /dev/null
@@ -1,28 +0,0 @@
-package org.eclipse.core.internal.boot;
-
-/*
- * (c) Copyright IBM Corp. 2000, 2001.
- * All Rights Reserved.
- */
-
-import java.net.*;
-
-public class ResourceLoader extends URLClassLoader {
-public ResourceLoader(URL[] resourcePath) {
- super(resourcePath, null);
-}
-/**
- * Looks for a given class. Resource loaders can never find classes and
- * so always throw <code>ClassNotFoundException</code>.
- */
-protected Class findClass(final String name) throws ClassNotFoundException {
- throw new ClassNotFoundException(name);
-}
-/**
- * Looks for a given class. Resource loaders can never find classes and
- * so always throw <code>ClassNotFoundException</code>.
- */
-protected Class loadClass(String name, boolean resolve) throws ClassNotFoundException {
- throw new ClassNotFoundException();
-}
-}
diff --git a/bundles/org.eclipse.core.boot/src/org/eclipse/core/internal/boot/URLContentFilter.java b/bundles/org.eclipse.core.boot/src/org/eclipse/core/internal/boot/URLContentFilter.java
deleted file mode 100644
index 3bbd6d2..0000000
--- a/bundles/org.eclipse.core.boot/src/org/eclipse/core/internal/boot/URLContentFilter.java
+++ /dev/null
@@ -1,85 +0,0 @@
-package org.eclipse.core.internal.boot;
-
-/*
- * (c) Copyright IBM Corp. 2000, 2001.
- * All Rights Reserved.
- */
-
-import java.util.*;
-
-/**
- * Represents class name filter for a given classpath entry. The filter
- * elements use the mask convention used by Java import statements.
- * Mask element "*" implies the full content is public.
- */
-public class URLContentFilter {
- private Hashtable filterTable = null;
- private boolean isPublic = false;
- private boolean isExported = false;
-public URLContentFilter(String[] filter) {
- if (filter==null || filter.length==0) return;
-
- String entry;
- for(int i=0; i<filter.length; i++) {
- entry = filter[i].trim();
- if (!entry.equals("")) {
- isExported = true;
- if (entry.equals("*")) isPublic = true;
- else addMask(entry);
- }
- }
-}
-public URLContentFilter(boolean isPublic) {
- if (isPublic) {
- this.isExported = true;
- this.isPublic = true;
- }
-}
-private void addMask(String name) {
-
- if (filterTable==null) filterTable = new Hashtable();
- filterTable.put(name,this);
-}
-private boolean classMatchesFilter(String name) {
-
- int i = name.lastIndexOf(".");
- if (i!=-1 && filterTable.get(name.substring(0,i)+".*")!=null) return true;
- else if(filterTable.get(name)!=null) return true;
- else return false;
-}
-boolean isClassVisible(Class clazz, DelegatingURLClassLoader current, DelegatingURLClassLoader requestor) {
- return isClassVisible(clazz.getName(), current, requestor);
-}
-boolean isClassVisible(String className, DelegatingURLClassLoader current, DelegatingURLClassLoader requestor) {
- if (requestor==current) return true; // request from own loader ... full access
- if (isPublic) return true; // public library ... full access from other loaders
- if (!isExported) return false; // private library ... no access from other loaders
- else return classMatchesFilter(className); // exported library ... match against filters
-}
-boolean isResourceVisible(String resName, DelegatingURLClassLoader current, DelegatingURLClassLoader requestor) {
- if (requestor==current) return true; // request from own loader ... full access
- if (isPublic) return true; // public library ... full access from other loaders
- if (!isExported) return false; // private library ... no access from other loaders
- else return resourceMatchesFilter(resName); // exported library ... match against filters
-}
-private boolean resourceMatchesFilter(String name) {
-
- int i = name.lastIndexOf("/");
- String tmp = name.replace('/','.');
- if (i!=-1 && filterTable.get(tmp.substring(0,i)+".*")!=null) return true;
- else if(filterTable.get(tmp)!=null) return true;
- else return false;
-}
-public String toString() {
- if (isPublic) return "*";
- if (!isExported) return "<private>";
- Enumeration keys = filterTable.keys();
- String mask = "";
- String sep = "";
- while(keys.hasMoreElements()) {
- mask += sep+(String)keys.nextElement();
- sep = " + ";
- }
- return mask;
-}
-}
diff --git a/bundles/org.eclipse.core.boot/src/org/eclipse/core/internal/boot/messages.properties b/bundles/org.eclipse.core.boot/src/org/eclipse/core/internal/boot/messages.properties
deleted file mode 100644
index 2b185eb..0000000
--- a/bundles/org.eclipse.core.boot/src/org/eclipse/core/internal/boot/messages.properties
+++ /dev/null
@@ -1,26 +0,0 @@
-### Boot plugin message catalog
-
-ok = OK
-
-### URL
-url.badVariant=Unsupported "platform:" protocol variation {0}
-url.invalidURL=Invalid "platform:" URL {0}
-url.createConnection=Unable to create connection {0}
-
-### Update
-update.expecting=Expecting {0}
-update.expectingEnd=Expecting end element </{0}>
-update.resourceNotFound=Resource not found {0}
-update.conflicts={0} {1} cannot be installed because of conflicts
-update.conflictsWith={0} {1} cannot be installed because of conflicts with {2} {3}
-update.conflictsId=\ {0} version {1}
-update.unableToOpen=Unable to open file
-update.unableToWrite=Unable to write to file
-update.endOfLine=Unexpected end of line
-
-### Platform Configuration
-cfig.badUrlArg=Bad -configuration argument \"{0}\"
-cfig.unableToLoad.incomplete=Unable to load {0}
-cfig.unableToLoad.noURL=Configuration file location not specified
-cfig.unableToSave.noURL=Configuration file save location not specified
-cfig.badVersion=Unsupported configuration version \"{0}\"
diff --git a/bundles/org.eclipse.core.runtime/src/org/eclipse/core/internal/runtime/PlatformLogReader.java b/bundles/org.eclipse.core.runtime/src/org/eclipse/core/internal/runtime/PlatformLogReader.java
index 6cc558b..3535e5c 100644
--- a/bundles/org.eclipse.core.runtime/src/org/eclipse/core/internal/runtime/PlatformLogReader.java
+++ b/bundles/org.eclipse.core.runtime/src/org/eclipse/core/internal/runtime/PlatformLogReader.java
@@ -1,69 +1,47 @@
+/*******************************************************************************
+ * Copyright (c) 2000,2002 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Common Public License v0.5
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/cpl-v05.html
+ *
+ * Contributors:
+ * IBM - Initial API and implementation
+ ******************************************************************************/
package org.eclipse.core.internal.runtime;
import java.io.*;
-import java.util.*;
-
-import org.apache.xerces.parsers.SAXParser;
-import org.eclipse.core.internal.boot.DelegatingURLClassLoader;
-import org.eclipse.core.internal.boot.PlatformClassLoader;
+import java.util.ArrayList;
+import java.util.StringTokenizer;
+import org.eclipse.core.internal.runtime.*;
import org.eclipse.core.runtime.*;
-import org.xml.sax.*;
-import org.xml.sax.helpers.AttributesImpl;
-import org.xml.sax.helpers.DefaultHandler;
/**
* Reads a structured log from disk and reconstructs status and exception objects.
* General strategy: log entries that are malformed in any way are skipped, and an extra
* status is returned mentioned that there were problems.
*/
-public class PlatformLogReader extends DefaultHandler {
- private static final String NULL_STRING = "" + null;
- private ArrayList result = null;
- private Stack objectStack = null;
+public class PlatformLogReader {
+ private ArrayList list = null;
+ private String currentLine = "";
+ private BufferedReader reader;
-/**
- * Returns a severity given its string representation.
- * Converse of PlatformLogReader#encodeSeverity.
- */
-protected int decodeSeverity(String severity) {
- if (severity == null)
- return -1;
- if (severity.equals("ERROR"))
- return IStatus.ERROR;
- if (severity.equals("INFO"))
- return IStatus.INFO;
- if (severity.equals("WARNING"))
- return IStatus.WARNING;
- if (severity.equals("OK"))
- return IStatus.OK;
- try {
- return Integer.parseInt(severity);
- } catch (NumberFormatException e) {
- return -1;
- }
-}
-public void endElement(String uri, String elementName, String qName) {
- if (elementName.equals(PlatformLogWriter.ELEMENT_LOG_ENTRY)) {
- readLogEntry();
- } else if (elementName.equals(PlatformLogWriter.ELEMENT_STATUS)) {
- readStatus();
- } else if (elementName.equals(PlatformLogWriter.ELEMENT_EXCEPTION)) {
- readException();
- }
-}
-/**
- * @see org.xml.sax.ErrorHandler#error.
- */
-public void error(SAXParseException ex) {
- log(ex);
-}
-/**
- * @see org.xml.sax.ErrorHandler#fatalError
- */
-public void fatalError(SAXParseException ex) throws SAXException {
- log(ex);
- throw ex;
-}
+ // constants copied from the PlatformLogWriter (since they are private
+ // to that class and this class should be used only in test suites)
+ private static final String KEYWORD_SESSION = "!SESSION";
+ private static final String KEYWORD_ENTRY = "!ENTRY";
+ private static final String KEYWORD_SUBENTRY = "!SUBENTRY";
+ private static final String KEYWORD_MESSAGE = "!MESSAGE";
+ private static final String KEYWORD_STACK = "!STACK";
+
+ private static final int NULL = -2;
+ private static final int SESSION = 1;
+ private static final int ENTRY = 2;
+ private static final int SUBENTRY = 4;
+ private static final int MESSAGE = 8;
+ private static final int STACK = 16;
+ private static final int UNKNOWN = 32;
+
/**
* Given a stack trace without carriage returns, returns a pretty-printed stack.
*/
@@ -91,101 +69,78 @@
writer.close();
return sWriter.toString();
}
-protected String getString(Attributes attributes, String attributeName) {
- return attributes.getValue(attributeName);
-}
protected void log(Exception ex) {
String msg = Policy.bind("meta.exceptionParsingLog", ex.getMessage());
- result.add(new Status(IStatus.WARNING, Platform.PI_RUNTIME, Platform.PARSE_PROBLEM, msg, ex));
+ list.add(new Status(IStatus.WARNING, Platform.PI_RUNTIME, Platform.PARSE_PROBLEM, msg, ex));
}
-protected void readException() {
- Attributes attributes = (Attributes)objectStack.pop();
- String message = getString(attributes, PlatformLogWriter.ATTRIBUTE_MESSAGE);
- if (NULL_STRING.equals(message)) {
- message = null;
- }
- String stack = getString(attributes, PlatformLogWriter.ATTRIBUTE_TRACE);
- objectStack.push(new FakeException(message, formatStack(stack)));
-}
-protected void readLogEntry() {
- while (!objectStack.isEmpty()) {
- Object o = objectStack.pop();
- if (o instanceof IStatus) {
- result.add(o);
- }
- }
+protected Throwable readException(String message) throws IOException {
+ if (currentLine == null || getLineType() != STACK)
+ return null;
+ StringBuffer buffer = new StringBuffer();
+ buffer.append(currentLine.substring(KEYWORD_STACK.length()+1, currentLine.length()));
+ currentLine = reader.readLine();
+ buffer.append(readText());
+ String stack = buffer.toString();
+ return new FakeException(null, formatStack(stack));
}
/**
* Reads the given log file and returns the contained status objects.
* If the log file could not be read, a status object indicating this fact
* is returned.
*/
-public IStatus[] readLogFile(String path) {
- result = new ArrayList();
- objectStack = new Stack();
- //XXX workaround. See Bug 5801.
- DelegatingURLClassLoader xmlClassLoader = (DelegatingURLClassLoader)Platform.getPluginRegistry().getPluginDescriptor("org.apache.xerces").getPluginClassLoader();
- PlatformClassLoader.getDefault().setImports(new DelegatingURLClassLoader[] { xmlClassLoader });
+public synchronized IStatus[] readLogFile(String path) {
+ list = new ArrayList();
+ InputStream input = null;
try {
- Reader reader = new BufferedReader(new FileReader(path));
- SAXParser parser = new SAXParser();
- parser.setContentHandler(this);
- parser.setErrorHandler(this);
- parser.parse(new InputSource(reader));
- } catch (IllegalStateException e) {
- log(e);
+ input = new FileInputStream(path);
+ reader = new BufferedReader(new InputStreamReader(input, "UTF-8"));//$NON-NLS-1$
+ currentLine = reader.readLine();
+ while (currentLine != null) {
+ switch (getLineType()) {
+ case ENTRY:
+ IStatus status = readEntry();
+ if (status != null)
+ list.add(status);
+ break;
+ case SUBENTRY:
+ case MESSAGE:
+ case STACK:
+ case SESSION:
+ case UNKNOWN:
+ currentLine = reader.readLine();
+ break;
+ }
+ }
} catch (IOException e) {
log(e);
- }catch (SAXException e) {
- log(e);
- }finally {
- PlatformClassLoader.getDefault().setImports(null);
- }
- return (IStatus[]) result.toArray(new IStatus[result.size()]);
-}
-protected void readStatus() {
- //status children are either child statii or an exception
- Attributes attributes = null;
- Throwable exception = null;
- ArrayList children = new ArrayList();
- while (!objectStack.isEmpty()) {
- Object o = objectStack.pop();
- if (o instanceof IStatus) {
- //stacking reversed order, so reverse order on pop
- children.add(0, o);
- } else if (o instanceof Throwable) {
- exception = (Throwable)o;
- } else {
- attributes = (Attributes)o;
- break;
+ } finally {
+ try {
+ if (input != null)
+ input.close();
+ } catch (IOException e) {
+ log(e);
}
}
- if (attributes == null)
- throw new IllegalStateException("Status missing attributes");//$NON-NLS$
- int severity = decodeSeverity(getString(attributes, PlatformLogWriter.ATTRIBUTE_SEVERITY));
- String pluginID = getString(attributes, PlatformLogWriter.ATTRIBUTE_PLUGIN_ID);
- String s = getString(attributes, PlatformLogWriter.ATTRIBUTE_CODE);
- int code = s == null ? -1 : Integer.parseInt(s);
- String message = getString(attributes, PlatformLogWriter.ATTRIBUTE_MESSAGE);
- if (severity == -1 || pluginID == null || code == -1 || message == null)
- throw new IllegalStateException();
+ return (IStatus[]) list.toArray(new IStatus[list.size()]);
+}
+protected int getLineType() {
+ if (currentLine == null)
+ return NULL;
+ StringTokenizer tokenizer = new StringTokenizer(currentLine);
+ String token = tokenizer.nextToken();
+ if (token.equals(KEYWORD_SESSION))
+ return SESSION;
+ if (token.equals(KEYWORD_ENTRY))
+ return ENTRY;
+ if (token.equals(KEYWORD_SUBENTRY))
+ return SUBENTRY;
+ if (token.equals(KEYWORD_MESSAGE))
+ return MESSAGE;
+ if (token.equals(KEYWORD_STACK))
+ return STACK;
+ return UNKNOWN;
+}
- if (children.size() > 0) {
- IStatus[] childStatii = (IStatus[]) children.toArray(new IStatus[children.size()]);
- objectStack.push(new MultiStatus(pluginID, code, childStatii, message, exception));
- } else {
- objectStack.push(new Status(severity, pluginID, code, message, exception));
- }
-}
-public void startElement(String uri, String elementName, String qName, Attributes attributes) {
- objectStack.push(new AttributesImpl(attributes));
-}
-/**
- * @see org.xml.sax.ErrorHandler#warning.
- */
-public void warning(SAXParseException ex) {
- log(ex);
-}
/**
* A reconsituted exception that only contains a stack trace and a message.
*/
@@ -209,5 +164,94 @@
stream.println(stackTrace);
}
}
+protected IStatus readEntry() throws IOException {
+ if (currentLine == null || getLineType() != ENTRY)
+ return null;
+ StringTokenizer tokens = new StringTokenizer(currentLine);
+ // skip over the ENTRY keyword
+ tokens.nextToken();
+ String pluginID = tokens.nextToken();
+ int severity = Integer.parseInt(tokens.nextToken());
+ int code = Integer.parseInt(tokens.nextToken());
+ // ignore the rest of the line since its the date
+ currentLine = reader.readLine();
+ String message = readMessage();
+ Throwable exception = readException(message);
+ if (currentLine == null || getLineType() != SUBENTRY)
+ return new Status(severity, pluginID, code, message, exception);
+ MultiStatus parent = new MultiStatus(pluginID, code, message, exception);
+ readSubEntries(parent);
+ return parent;
}
+protected void readSubEntries(MultiStatus parent) throws IOException {
+ while (getLineType() == SUBENTRY) {
+ StringTokenizer tokens = new StringTokenizer(currentLine);
+ // skip over the subentry keyword
+ tokens.nextToken();
+ int currentDepth = Integer.parseInt(tokens.nextToken());
+ String pluginID = tokens.nextToken();
+ int severity = Integer.parseInt(tokens.nextToken());
+ int code = Integer.parseInt(tokens.nextToken());
+ // ignore the rest of the line since its the date
+ currentLine = reader.readLine();
+ String message = readMessage();
+ Throwable exception = readException(message);
+
+ IStatus current = new Status(severity, pluginID, code, message, exception);
+ if (currentLine == null || getLineType() != SUBENTRY) {
+ parent.add(current);
+ return;
+ }
+ tokens = new StringTokenizer(currentLine);
+ tokens.nextToken();
+ int depth = Integer.parseInt(tokens.nextToken());
+ if (currentDepth == depth) {
+ // next sub-entry is a sibling
+ parent.add(current);
+ } else if (currentDepth == (depth - 1)) {
+ // next sub-entry is a child
+ current = new MultiStatus(pluginID, code, message, exception);
+ readSubEntries((MultiStatus) current);
+ parent.add(current);
+ } else {
+ parent.add(current);
+ return;
+ }
+ }
+}
+protected int readDepth() throws IOException {
+ StringTokenizer tokens = new StringTokenizer(currentLine);
+ // skip the keyword
+ tokens.nextToken();
+ return Integer.parseInt(tokens.nextToken());
+}
+protected String readMessage() throws IOException {
+ if (currentLine == null || getLineType() != MESSAGE)
+ return "";
+ StringBuffer buffer = new StringBuffer();
+ buffer.append(currentLine.substring(KEYWORD_MESSAGE.length()+1, currentLine.length()));
+ currentLine = reader.readLine();
+ buffer.append(readText());
+ return buffer.toString();
+}
+protected String readText() throws IOException {
+ StringBuffer buffer = new StringBuffer();
+ if (currentLine == null || getLineType() != UNKNOWN)
+ return "";
+ else buffer.append(currentLine);
+ boolean done = false;
+ while (!done) {
+ currentLine = reader.readLine();
+ if (currentLine == null) {
+ done = true;
+ continue;
+ }
+ if (getLineType() == UNKNOWN)
+ buffer.append(currentLine);
+ else
+ done = true;
+ }
+ return buffer.toString();
+}
+}
diff --git a/bundles/org.eclipse.core.runtime/src/org/eclipse/core/internal/runtime/PlatformLogWriter.java b/bundles/org.eclipse.core.runtime/src/org/eclipse/core/internal/runtime/PlatformLogWriter.java
index 7c5b72a..11796b3 100644
--- a/bundles/org.eclipse.core.runtime/src/org/eclipse/core/internal/runtime/PlatformLogWriter.java
+++ b/bundles/org.eclipse.core.runtime/src/org/eclipse/core/internal/runtime/PlatformLogWriter.java
@@ -1,11 +1,17 @@
+/*******************************************************************************
+ * Copyright (c) 2000,2002 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Common Public License v0.5
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/cpl-v05.html
+ *
+ * Contributors:
+ * IBM - Initial API and implementation
+ ******************************************************************************/
package org.eclipse.core.internal.runtime;
-/*
- * (c) Copyright IBM Corp. 2000, 2001.
- * All Rights Reserved.
- */
-
import java.io.*;
+import java.text.DateFormat;
import java.util.*;
import org.eclipse.core.runtime.ILogListener;
@@ -17,112 +23,42 @@
public class PlatformLogWriter implements ILogListener {
protected File logFile = null;
protected Writer log = null;
- protected int tabDepth;
-
- protected static final String LINE_SEPARATOR;
- protected static final String TAB_STRING = " ";
-
- protected static final String XML_VERSION = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>";
+ protected boolean newSession = true;
- protected static final String ATTRIBUTE_DATE = "date";
- protected static final String ATTRIBUTE_SEVERITY = "severity";
- protected static final String ATTRIBUTE_PLUGIN_ID = "plugin-id";
- protected static final String ATTRIBUTE_CODE = "code";
- protected static final String ATTRIBUTE_MESSAGE = "message";
- protected static final String ATTRIBUTE_TRACE = "trace";
-
- protected static final String ELEMENT_LOG = "log";
- protected static final String ELEMENT_LOG_ENTRY = "log-entry";
- protected static final String ELEMENT_STATUS = "status";
- protected static final String ELEMENT_EXCEPTION = "exception";
+ protected static final String SESSION = "!SESSION";//$NON-NLS-1$
+ protected static final String ENTRY = "!ENTRY";//$NON-NLS-1$
+ protected static final String SUBENTRY = "!SUBENTRY";//$NON-NLS-1$
+ protected static final String MESSAGE = "!MESSAGE";//$NON-NLS-1$
+ protected static final String STACK = "!STACK";//$NON-NLS-1$
+
+ protected static final String LINE_SEPARATOR;
+ protected static final String TAB_STRING = "\t";//$NON-NLS-1$
static {
- String s = System.getProperty("line.separator");
- LINE_SEPARATOR = s == null ? "\n" : s;
+ String s = System.getProperty("line.separator");//$NON-NLS-1$
+ LINE_SEPARATOR = s == null ? "\n" : s;//$NON-NLS-1$
}
public PlatformLogWriter(File file) {
this.logFile = file;
- // remove old log file
- logFile.delete();
}
/**
* This constructor should only be used to pass System.out .
*/
public PlatformLogWriter(OutputStream out) {
- log = new OutputStreamWriter(out);
-}
-protected static void appendEscapedChar(StringBuffer buffer, char c) {
- String replacement = getReplacement(c);
- if (replacement != null) {
- buffer.append('&');
- buffer.append(replacement);
- buffer.append(';');
- } else {
- buffer.append(c);
- }
-}
-protected static String getEscaped(String s) {
- StringBuffer result = new StringBuffer(s.length() + 10);
- for (int i = 0; i < s.length(); ++i)
- appendEscapedChar(result, s.charAt(i));
- return result.toString();
-}
-protected static String getReplacement(char c) {
- // Encode special XML characters into the equivalent character references.
- // These five are defined by default for all XML documents.
- switch (c) {
- case '<' :
- return "lt";
- case '>' :
- return "gt";
- case '"' :
- return "quot";
- case '\'' :
- return "apos";
- case '&' :
- return "amp";
- }
- return null;
+ this.log = logForStream(out);
}
protected void closeLogFile() throws IOException {
try {
- log.flush();
- log.close();
+ if (log != null) {
+ log.flush();
+ log.close();
+ }
} finally {
log = null;
}
}
/**
- * Returns a string representation of the given severity.
- */
-protected String encodeSeverity(int severity) {
- switch (severity) {
- case IStatus.ERROR :
- return "ERROR";
- case IStatus.INFO :
- return "INFO";
- case IStatus.OK:
- return "OK";
- case IStatus.WARNING :
- return "WARNING";
- }
- //unknown severity, just print the integer
- return Integer.toString(severity);
-}
-protected String encodeStackTrace(Throwable t) {
- StringWriter sWriter = new StringWriter();
- PrintWriter pWriter = new PrintWriter(sWriter);
- pWriter.println();
- t.printStackTrace(pWriter);
- pWriter.flush();
- return sWriter.toString();
-}
-protected void endTag(String name) throws IOException {
- tabDepth--;
- printTag('/' + name, null);
-}
-/**
* @see ILogListener#logging.
*/
public synchronized void logging(IStatus status, String plugin) {
@@ -130,25 +66,27 @@
if (logFile != null)
openLogFile();
if (log == null)
- log = new OutputStreamWriter(System.err);
+ log = logForStream(System.err);
try {
try {
- writeLogEntry(status);
+ write(status, 0);
} finally {
if (logFile != null)
closeLogFile();
+ else
+ log.flush();
}
} catch (Exception e) {
- System.err.println("An exception occurred while writing to the platform log:");
+ System.err.println("An exception occurred while writing to the platform log:");//$NON-NLS-1$
System.err.println(e.getClass().getName() + ": " + e.getMessage());
- System.err.println("Logging to the console instead.");
+ System.err.println("Logging to the console instead.");//$NON-NLS-1$
//we failed to write, so dump log entry to console instead
try {
- log = new OutputStreamWriter(System.err);
- writeLogEntry(status);
+ log = logForStream(System.err);
+ write(status, 0);
log.flush();
} catch (Exception e2) {
- System.err.println("An exception occurred while logging to the console:");
+ System.err.println("An exception occurred while logging to the console:");//$NON-NLS-1$
System.err.println(e.getClass().getName() + ": " + e.getMessage());
}
} finally {
@@ -157,50 +95,29 @@
}
protected void openLogFile() {
try {
- boolean newLog = !logFile.exists();
- log =new BufferedWriter(new FileWriter(logFile.getAbsolutePath(), true));
- if (newLog) {
- println(XML_VERSION);
- startTag(ELEMENT_LOG, null);
+ log = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(logFile.getAbsolutePath(), true), "UTF-8"));
+ if (newSession) {
+ writeln(SESSION);
+ newSession = false;
}
} catch (IOException e) {
// there was a problem opening the log file so log to the console
- log = new OutputStreamWriter(System.err);
+ log = logForStream(System.err);
+ }
+}
+protected Writer logForStream(OutputStream output) {
+ try {
+ return new BufferedWriter(new OutputStreamWriter(output, "UTF-8"));//$NON-NLS-1$
+ } catch (UnsupportedEncodingException e) {
+ return new BufferedWriter(new OutputStreamWriter(output));
}
}
/**
* Writes the given string to the log, followed by the line terminator string.
*/
-protected void println(String s) throws IOException {
- log.write(s);
- log.write(LINE_SEPARATOR);
-}
-protected void printTabulation() throws IOException {
- for (int i = 0; i < tabDepth; i++)
- log.write(TAB_STRING);
-}
-
-protected void printTag(String name, HashMap parameters) throws IOException {
- printTabulation();
- log.write('<');
- log.write(name);
- tabDepth++;
- if (parameters != null)
- for (Enumeration enum = Collections.enumeration(parameters.keySet()); enum.hasMoreElements();) {
- //new line for each attribute if there's more than one
- if (parameters.size() > 1) {
- log.write(LINE_SEPARATOR);
- printTabulation();
- }
- log.write(" ");
- String key = (String) enum.nextElement();
- log.write(key);
- log.write("=\"");
- log.write(getEscaped(String.valueOf(parameters.get(key))));
- log.write("\"");
- }
- tabDepth--;
- println(">");
+protected void writeln(String s) throws IOException {
+ write(s);
+ writeln();
}
/**
* Shuts down the platform log.
@@ -208,13 +125,8 @@
public synchronized void shutdown() {
try {
if (logFile != null) {
- try {
- openLogFile();
- endTag(ELEMENT_LOG);
- } finally {
- closeLogFile();
- logFile = null;
- }
+ closeLogFile();
+ logFile = null;
} else {
if (log != null) {
Writer old = log;
@@ -228,43 +140,59 @@
e.printStackTrace();
}
}
-protected void startTag(String name, HashMap parameters) throws IOException {
- printTag(name, parameters);
- tabDepth++;
-}
+
protected void write(Throwable throwable) throws IOException {
if (throwable == null)
return;
- HashMap attributes = new HashMap();
- attributes.put(ATTRIBUTE_MESSAGE, throwable.getMessage());
- attributes.put(ATTRIBUTE_TRACE, encodeStackTrace(throwable));
- startTag(ELEMENT_EXCEPTION, attributes);
- endTag(ELEMENT_EXCEPTION);
+ write(STACK);
+ writeSpace();
+ StringBuffer buffer = new StringBuffer();
+ throwable.printStackTrace(new PrintWriter(log));
}
-protected void write(IStatus status) throws IOException {
- HashMap attributes = new HashMap();
- attributes.put(ATTRIBUTE_SEVERITY, encodeSeverity(status.getSeverity()));
- attributes.put(ATTRIBUTE_PLUGIN_ID, status.getPlugin());
- attributes.put(ATTRIBUTE_CODE, Integer.toString(status.getCode()));
- attributes.put(ATTRIBUTE_MESSAGE, status.getMessage());
- startTag(ELEMENT_STATUS, attributes); {
- write(status.getException());
- if (status.isMultiStatus()) {
- IStatus[] children = status.getChildren();
- for (int i = 0; i < children.length; i++) {
- write(children[i]);
- }
+
+
+protected void write(IStatus status, int depth) throws IOException {
+ if (depth == 0)
+ write(ENTRY);
+ else
+ write(SUBENTRY);
+ if (depth != 0) {
+ writeSpace();
+ write(Integer.toString(depth));
+ }
+ writeSpace();
+ write(status.getPlugin());
+ writeSpace();
+ write(Integer.toString(status.getSeverity()));
+ writeSpace();
+ write(Integer.toString(status.getCode()));
+ writeSpace();
+ write(new Date().toString());
+ writeln();
+
+ write(MESSAGE);
+ writeSpace();
+ writeln(status.getMessage());
+
+ write(status.getException());
+
+ if (status.isMultiStatus()) {
+ IStatus[] children = status.getChildren();
+ for (int i = 0; i < children.length; i++) {
+ write(children[i], depth+1);
}
}
- endTag(ELEMENT_STATUS);
}
-protected void writeLogEntry(IStatus status) throws IOException {
- tabDepth = 0;
- HashMap attributes = new HashMap();
- attributes.put(ATTRIBUTE_DATE, new Date());
- startTag(ELEMENT_LOG_ENTRY, attributes);
- write(status);
- endTag(ELEMENT_LOG_ENTRY);
+
+protected void writeln() throws IOException {
+ write(LINE_SEPARATOR);
}
+protected void write(String message) throws IOException {
+ log.write(message);
+}
+protected void writeSpace() throws IOException {
+ write(" ");//$NON-NLS-1$
+}
+
}
diff --git a/tests/org.eclipse.core.tests.harness/.classpath b/tests/org.eclipse.core.tests.harness/.classpath
deleted file mode 100644
index 0e4f7ab..0000000
--- a/tests/org.eclipse.core.tests.harness/.classpath
+++ /dev/null
@@ -1,10 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<classpath>
- <classpathentry kind="var" path="JRE_LIB" rootpath="JRE_SRCROOT" sourcepath="JRE_SRC"/>
- <classpathentry kind="src" path="/org.eclipse.core.boot"/>
- <classpathentry kind="src" path="/org.eclipse.core.runtime"/>
- <classpathentry kind="src" path="/org.eclipse.core.resources"/>
- <classpathentry kind="src" path="src"/>
- <classpathentry kind="src" path="/org.junit"/>
- <classpathentry kind="output" path="bin"/>
-</classpath>
diff --git a/tests/org.eclipse.core.tests.harness/.cvsignore b/tests/org.eclipse.core.tests.harness/.cvsignore
deleted file mode 100644
index c5e82d7..0000000
--- a/tests/org.eclipse.core.tests.harness/.cvsignore
+++ /dev/null
@@ -1 +0,0 @@
-bin
\ No newline at end of file
diff --git a/tests/org.eclipse.core.tests.harness/.project b/tests/org.eclipse.core.tests.harness/.project
deleted file mode 100644
index 056a443..0000000
--- a/tests/org.eclipse.core.tests.harness/.project
+++ /dev/null
@@ -1,22 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<projectDescription>
- <name>org.eclipse.core.tests.harness</name>
- <comment></comment>
- <projects>
- <project>org.eclipse.core.boot</project>
- <project>org.eclipse.core.resources</project>
- <project>org.eclipse.core.runtime</project>
- <project>org.junit</project>
- </projects>
- <buildSpec>
- <buildCommand>
- <name>org.eclipse.jdt.core.javabuilder</name>
- <arguments>
- </arguments>
- </buildCommand>
- </buildSpec>
- <natures>
- <nature>org.eclipse.jdt.core.javanature</nature>
- <nature>org.eclipse.team.cvs.core.cvsnature</nature>
- </natures>
-</projectDescription>
diff --git a/tests/org.eclipse.core.tests.harness/about.html b/tests/org.eclipse.core.tests.harness/about.html
deleted file mode 100644
index bc976dd..0000000
--- a/tests/org.eclipse.core.tests.harness/about.html
+++ /dev/null
@@ -1,30 +0,0 @@
-<html>
-<head>
-<title>About</title>
-<style type="text/css">
-p, table, td, th { font-family: arial, helvetica, geneva; font-size: 10pt}
-pre { font-family: "Courier New", Courier, mono; font-size: 10pt}
-h2 { font-family: arial, helvetica, geneva; font-size: 18pt; font-weight: bold ; line-height: 14px}
-code { font-family: "Courier New", Courier, mono; font-size: 10pt}
-sup { font-family: arial,helvetica,geneva; font-size: 10px}
-h3 { font-family: arial, helvetica, geneva; font-size: 14pt; font-weight: bold}
-li { font-family: arial, helvetica, geneva; font-size: 10pt}
-h1 { font-family: arial, helvetica, geneva; font-size: 28px; font-weight: bold}
-body { font-family: arial, helvetica, geneva; font-size: 10pt; clip: rect( ); margin-top: 5mm; margin-left: 3mm}
-</style>
-</head>
-<body>
-<body lang=EN-US link=blue vlink=purple>
-<table border=0 cellspacing=5 cellpadding=2 width="100%" >
- <tr>
- <td align=LEFT valign=TOP colspan="2" bgcolor="#0080C0"><b><font color="#FFFFFF" face="Arial,Helvetica">About This Plug-in</font></b></td>
- </tr>
- <tr>
- <td>
-<p>1st November, 2001</p>
-<h3>License</h3>
-<p>Eclipse.org makes available all content in this plug-in. The plug-in is provided to you under the terms and conditions of the
-<a href="http://www.eclipse.org/legal/cpl-v05.html">Common Public License Version 0.5</a>. For purposes of the Common Public License, "Program" will mean the plug-in.</p>
-</td></tr></table>
-</body>
-</html>
\ No newline at end of file
diff --git a/tests/org.eclipse.core.tests.harness/build-tests.xml b/tests/org.eclipse.core.tests.harness/build-tests.xml
deleted file mode 100644
index 1956227..0000000
--- a/tests/org.eclipse.core.tests.harness/build-tests.xml
+++ /dev/null
@@ -1,67 +0,0 @@
-<?xml version="1.0"?>
-<project name="Build Core Sniff" basedir="." default="init">
-
- <property name="root" value="${basedir}/.."/>
- <property name="temp" value="${root}/__temp"/>
- <property name="plugins" value="${temp}/eclipse/plugins"/>
-
- <target name="init">
- <tstamp/>
-
- <delete dir="${temp}"/>
- <mkdir dir="${plugins}"/>
-
- <antcall target="buildPlugin">
- <param name="pluginName" value="org.eclipse.core.tests.resources" />
- <param name="jarName" value="resourcestests.jar" />
- </antcall>
-
- <antcall target="buildPlugin">
- <param name="pluginName" value="org.eclipse.core.tests.resources.saveparticipant" />
- <param name="jarName" value="saveparticipant.jar" />
- </antcall>
-
- <antcall target="buildPlugin">
- <param name="pluginName" value="org.eclipse.core.tests.resources.saveparticipant1" />
- <param name="jarName" value="saveparticipant1.jar" />
- </antcall>
-
- <antcall target="buildPlugin">
- <param name="pluginName" value="org.eclipse.core.tests.resources.saveparticipant2" />
- <param name="jarName" value="saveparticipant2.jar" />
- </antcall>
-
- <antcall target="buildPlugin">
- <param name="pluginName" value="org.eclipse.core.tests.resources.saveparticipant3" />
- <param name="jarName" value="saveparticipant3.jar" />
- </antcall>
-
- <antcall target="buildPlugin">
- <param name="pluginName" value="org.eclipse.core.tests.runtime" />
- <param name="jarName" value="runtimetests.jar" />
- </antcall>
-
- <antcall target="buildPlugin">
- <param name="pluginName" value="org.eclipse.core.tests.harness" />
- <param name="jarName" value="testharness.jar" />
- </antcall>
-
- <zip zipfile="${basedir}/coreSniff${DSTAMP}.zip"
- basedir="${temp}"
- />
-
- <delete dir="${temp}"/>
- <eclipse.refreshLocal resource="org.eclipse.core.tests.harness"/>
- </target>
-
- <target name="buildPlugin">
- <copy todir="${plugins}/${pluginName}">
- <fileset dir="${root}/${pluginName}"/>
- </copy>
- <jar jarfile="${plugins}/${pluginName}/${jarName}"
- basedir="${plugins}/${pluginName}/bin"
- />
- <delete dir="${plugins}/${pluginName}/bin"/>
- </target>
-
-</project>
\ No newline at end of file
diff --git a/tests/org.eclipse.core.tests.harness/build.properties b/tests/org.eclipse.core.tests.harness/build.properties
deleted file mode 100644
index 99b381f..0000000
--- a/tests/org.eclipse.core.tests.harness/build.properties
+++ /dev/null
@@ -1,3 +0,0 @@
-source.testharness.jar=src/
-bin.includes=plugin.xml,*.jar,test.xml,about.xml
-
diff --git a/tests/org.eclipse.core.tests.harness/plugin.xml b/tests/org.eclipse.core.tests.harness/plugin.xml
deleted file mode 100644
index 806d2a9..0000000
--- a/tests/org.eclipse.core.tests.harness/plugin.xml
+++ /dev/null
@@ -1,45 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<plugin
- name="Eclipse Core Tests Harness"
- id="org.eclipse.core.tests.harness"
- version="2.0"
- provider-name="Object Technology International, Inc.">
-
- <requires>
- <import plugin="org.eclipse.core.resources"/>
- <import plugin="org.junit"/>
- </requires>
-
- <runtime>
- <library name="testharness.jar">
- <export name="*"/>
- </library>
- </runtime>
-
- <extension-point name="Tests" id="tests"/>
-
- <extension point="org.eclipse.core.tests.harness.tests">
- <test id="ExampleTest">
- <run class="org.eclipse.core.tests.harness.ExampleTest"/>
- </test>
- </extension>
-
- <extension point="org.eclipse.core.tests.harness.tests">
- <test id="ExampleWorkspaceTest">
- <run class="org.eclipse.core.tests.harness.ExampleWorkspaceTest"/>
- </test>
- </extension>
-
- <extension id="testapplication" point="org.eclipse.core.runtime.applications">
- <application>
- <run class="org.eclipse.core.tests.harness.EclipseTestHarnessApplication"/>
- </application>
- </extension>
- <extension id="sessiontestapplication" point="org.eclipse.core.runtime.applications">
- <application>
- <run class="org.eclipse.core.tests.harness.SessionTestApplication"/>
- </application>
- </extension>
-
-
-</plugin>
diff --git a/tests/org.eclipse.core.tests.harness/readme.txt b/tests/org.eclipse.core.tests.harness/readme.txt
deleted file mode 100644
index 1bb41ac..0000000
--- a/tests/org.eclipse.core.tests.harness/readme.txt
+++ /dev/null
@@ -1,10 +0,0 @@
-README for org.eclipse.core.tests.harness
-
-This plug-in works as a library for core tests. It also holds the script
-to launch the core automated tests after the a build.
-In order to execute launch the tests, the test framework plug-ins have
-to available.
-
-Command line (from the eclipse home directory) for executing tests:
-
-java -cp startup.jar org.eclipse.core.launcher.Main -application org.eclipse.ant.core.antRunner -file plugins\org.eclipse.core.tests.harness\test.xml run -dev bin
\ No newline at end of file
diff --git a/tests/org.eclipse.core.tests.harness/src/org/eclipse/core/tests/harness/CancelingProgressMonitor.java b/tests/org.eclipse.core.tests.harness/src/org/eclipse/core/tests/harness/CancelingProgressMonitor.java
deleted file mode 100644
index da595dc..0000000
--- a/tests/org.eclipse.core.tests.harness/src/org/eclipse/core/tests/harness/CancelingProgressMonitor.java
+++ /dev/null
@@ -1,10 +0,0 @@
-package org.eclipse.core.tests.harness;
-
-public class CancelingProgressMonitor extends TestProgressMonitor {
-/**
- * @see IProgressMonitor#isCanceled
- */
-public boolean isCanceled() {
- return true;
-}
-}
diff --git a/tests/org.eclipse.core.tests.harness/src/org/eclipse/core/tests/harness/CorePerformanceTest.java b/tests/org.eclipse.core.tests.harness/src/org/eclipse/core/tests/harness/CorePerformanceTest.java
deleted file mode 100644
index 241954c..0000000
--- a/tests/org.eclipse.core.tests.harness/src/org/eclipse/core/tests/harness/CorePerformanceTest.java
+++ /dev/null
@@ -1,124 +0,0 @@
-package org.eclipse.core.tests.harness;
-
-import org.eclipse.core.tests.harness.EclipseWorkspaceTest;
-import java.io.*;
-import java.lang.reflect.*;
-import junit.framework.*;
-
-/**
- * This class is the common superclass for all performance tests for
- * the Core project. It provides extensions to the JUnit infrastructure
- * to incorporate timers into test cases.
- *
- * There are two distinct sets of timing mechanisms available, depending
- * on the type of operation being testing. For long running operations
- * with noticeable delays, use startTimer() and stopTimer(). This is
- * a more heavy-weight mechanism that allows logging, multiple
- * timers, and overlapping timers.
- *
- * For benchmarking operations that should be instantaneous, use the
- * startBench(), stopBench() methods. Here is an example:
- *
- * <code>
- * String benchName = "myOperation";
- * int repeat = 500;
- * startBench();
- * for (int i = 0; i < repeat; i++) {
- * //run the operation to be tested here
- * }
- * stopBench(benchName, repeat);
- * </code>
- * Note that only one operation can be tested at a time with this mechanism.
- *
- * If an instance of this class is run using a LoggingPerformanceTestResult,
- * an HTML log file will be maintained of all timing and garbage collecting,
- * in addition to any messages added using the log() method. In the absence
- * of a logging test result, all log events are written to the standard output.
- */
-public abstract class CorePerformanceTest extends EclipseWorkspaceTest {
- public static String fLogFile;
-
- protected LoggingPerformanceTestResult fLogger = null;
- protected PerformanceTestResult fResult = null;
- protected File fTempDir;
- protected File fDir;
-
- protected long benchStart;
-public CorePerformanceTest() {
-}
-public CorePerformanceTest(String name) {
- super(name);
-}
- protected PerformanceTestResult defaultTest() {
- return new PerformanceTestResult();
- }
- /**
- * Logs or writes string to console.
- */
- public void perfLog(String s) {
- if (fLogger != null) {
- fLogger.log(s);
- } else {
- System.out.println(s);
- }
- }
- /**
- * A convenience method to run this test, collecting the results with a
- * default PerformanceTestResult object.
- *
- * @see PerformanceTestResult
- */
- public TestResult run() {
- PerformanceTestResult test = defaultTest();
- run(test);
- return test;
- }
- /**
- * Runs the test case and collects the results in a PerformanceTestResult.
- * This is the template method that defines the control flow
- * for running a test case.
- */
- public void run(PerformanceTestResult test) {
- fResult = test;
-
- if (test instanceof LoggingPerformanceTestResult) {
- fLogger = (LoggingPerformanceTestResult)test;
- }
-
- super.run(test);
- }
-protected void startBench() {
- for (int i = 0; i < 20; ++i) {
- System.gc();
- }
- benchStart = System.currentTimeMillis();
-}
-/**
- * Tell the result to start a timer with the given name.
- * If no timer exists with that name, result creates a new timer
- * and starts it running.
- */
-protected void startTimer(String timerName) {
- fResult.startTimer(timerName);
-}
-protected void stopBench(String benchName, int numOperations) {
- long duration = System.currentTimeMillis() - benchStart;
- double perOp = (double) duration / (double) numOperations;
-
- String opString;
- if (perOp > 100.0) {
- opString = "(" + perOp + "ms per operation)";
- } else {
- //Note us == microseconds
- opString = "(" + (perOp * 1000.0) + "us per operation)";
- }
-
- System.out.println(benchName + " took " + duration + "ms " + opString);
-}
-/**
- * Tell the result to stop the timer with the given name.
- */
-protected void stopTimer(String timerName) {
- fResult.stopTimer(timerName);
-}
-}
diff --git a/tests/org.eclipse.core.tests.harness/src/org/eclipse/core/tests/harness/DeltaDebugListener.java b/tests/org.eclipse.core.tests.harness/src/org/eclipse/core/tests/harness/DeltaDebugListener.java
deleted file mode 100644
index 447aa76..0000000
--- a/tests/org.eclipse.core.tests.harness/src/org/eclipse/core/tests/harness/DeltaDebugListener.java
+++ /dev/null
@@ -1,59 +0,0 @@
-package org.eclipse.core.tests.harness;
-
-/*
- * (c) Copyright IBM Corp. 2000, 2001.
- * All Rights Reserved.
- */
-
-import org.eclipse.core.internal.events.ResourceDelta;
-import org.eclipse.core.resources.*;
-import org.eclipse.core.runtime.CoreException;
-
-
-public class DeltaDebugListener implements IResourceChangeListener {
-/**
- * @see IResourceChangeListener#closing(IProject)
- */
-public void closing(IProject project) {
-}
-/**
- * @see IResourceChangeListener#deleting(IProject)
- */
-
-public void deleting(IProject project) {
-}
-/**
- * @see IResourceChangeListener#resourceChanged
- */
-public void resourceChanged(IResourceChangeEvent event) {
- IResourceDelta delta = event.getDelta();
- if (delta == null)
- return;
- try {
- System.out.println();
- visitingProcess(delta);
- } catch (CoreException e) {
- // XXX: dropping exceptions
- }
-}
-protected boolean visit(IResourceDelta change) throws CoreException {
- System.out.println(((ResourceDelta) change).toDebugString());
- return true;
-}
-/**
- * Processes the given change by traversing its nodes and calling
- * <code>visit</code> for each.
- *
- * @see #visit
- * @exception CoreException if the operation fails
- */
-protected void visitingProcess(IResourceDelta change) throws CoreException {
- if (!visit(change))
- return;
- int kind = IResourceDelta.ADDED | IResourceDelta.REMOVED | IResourceDelta.CHANGED;
- int memberFlags = IContainer.INCLUDE_TEAM_PRIVATE_MEMBERS | IContainer.INCLUDE_PHANTOMS;
- IResourceDelta[] children = change.getAffectedChildren(kind, memberFlags);
- for (int i = 0; i < children.length; i++)
- visitingProcess(children[i]);
-}
-}
diff --git a/tests/org.eclipse.core.tests.harness/src/org/eclipse/core/tests/harness/EclipseTestHarnessApplication.java b/tests/org.eclipse.core.tests.harness/src/org/eclipse/core/tests/harness/EclipseTestHarnessApplication.java
deleted file mode 100644
index 3d1f287..0000000
--- a/tests/org.eclipse.core.tests.harness/src/org/eclipse/core/tests/harness/EclipseTestHarnessApplication.java
+++ /dev/null
@@ -1,144 +0,0 @@
-package org.eclipse.core.tests.harness;
-
-/*
- * (c) Copyright IBM Corp. 2000, 2001.
- * All Rights Reserved.
- */
-
-import java.lang.reflect.InvocationTargetException;
-import java.lang.reflect.Method;
-import java.util.*;
-
-import junit.framework.Test;
-import junit.textui.TestRunner;
-import org.eclipse.core.boot.IPlatformRunnable;
-import org.eclipse.core.runtime.*;
-
-public class EclipseTestHarnessApplication implements IPlatformRunnable {
- protected List tests;
-
- /** command line arguments made available to all tests. */
- public static String[] args;
-
- /** true if workspace tests should log their deltas */
- private static boolean deltas = false;
-
- /** The id of the test harness plug-in */
- private static final String PI_TESTHARNESS = "org.eclipse.core.tests.harness";
-
- /** the simple id of the tests extension point in the test harness plug-in */
- private static final String PT_TESTS = "tests";
-public EclipseTestHarnessApplication() {
- tests = new ArrayList(5);
-}
-public static boolean deltasEnabled() {
- return deltas;
-}
-/**
- * Finds, creates and returns a prototypical test object for the test with
- * the given name/id. Returns <code>null</code> if no such test is found
- * or the class defined by the test extension could not be found.
- * In either failure case a message is output on the System console.
- */
-protected Object findTestFor(String testName) {
- IExtensionPoint point = Platform.getPluginRegistry().getExtensionPoint(PI_TESTHARNESS, PT_TESTS);
- IConfigurationElement[] elements = point.getConfigurationElements();
- for (int i = 0; i < elements.length; i++) {
- IConfigurationElement element = elements[i];
- if (element.getName().equals("test")) {
- String id = element.getAttribute("id");
- if (id != null && id.equals(testName))
- try {
- return element.createExecutableExtension("run");
- } catch (CoreException e) {
- System.out.println("Could not instantiate test: " + testName);
- return null;
- }
- }
- }
- System.out.println("Could not find test: " + testName);
- return null;
-}
-protected String[] processCommandLine(String[] args) {
- int[] configArgs = new int[100];
- configArgs[0] = -1; // need to initialize the first element to something that could not be an index.
- int configArgIndex = 0;
- for (int i = 0; i < args.length; i++) {
- boolean found = false;
- // check for args without parameters (i.e., a flag arg)
- // see if we should be logging deltas
- if (args[i].equalsIgnoreCase("-deltas")) {
- found = true;
- deltas = true;
- }
- if (found) {
- configArgs[configArgIndex++] = i;
- continue;
- }
-
- // check for args with parameters
- if (i == args.length - 1 || args[i + 1].startsWith("-")) {
- continue;
- }
- String arg = args[++i];
- // check for the which test to run
- if (args[i - 1].equalsIgnoreCase("-test")) {
- found = true;
- // fully qualified name of the test class to run
- tests.add(arg);
- }
-
- // done checking for args. Remember where an arg was found
- if (found) {
- configArgs[configArgIndex++] = i - 1;
- configArgs[configArgIndex++] = i;
- }
- }
-
- //remove all the arguments consumed by this argument parsing
- if (configArgIndex == 0)
- return args;
- String[] passThruArgs = new String[args.length - configArgIndex];
- configArgIndex = 0;
- int j = 0;
- for (int i = 0; i < args.length; i++) {
- if (i == configArgs[configArgIndex])
- configArgIndex++;
- else
- passThruArgs[j++] = args[i];
- }
- return passThruArgs;
-}
-/**
- * Runs a set of tests as defined by the given command line args.
- * This is the platform application entry point.
- * @see IPlatformRunnable
- */
-public Object run(Object userArgs) throws Exception {
- args = processCommandLine((String[]) userArgs);
- for (Iterator i = tests.iterator(); i.hasNext();)
- run((String) i.next());
- return null;
-}
-protected Object run(String testName) throws Exception {
- Object testObject = findTestFor(testName);
- if (testObject == null)
- return null;
- Class testClass = testObject.getClass();
- Method method = testClass.getDeclaredMethod("suite", new Class[0]);
- Test suite = null;
- try {
- suite = (Test) method.invoke(testClass, new Object[0]);
- } catch (InvocationTargetException e) {
- if (e.getTargetException() instanceof Error)
- throw (Error) e.getTargetException();
- else
- throw e;
- }
- run(suite);
- return null;
-}
-protected void run(Test suite) throws Exception {
- TestRunner.run(suite);
-}
-}
diff --git a/tests/org.eclipse.core.tests.harness/src/org/eclipse/core/tests/harness/EclipseWorkspaceTest.java b/tests/org.eclipse.core.tests.harness/src/org/eclipse/core/tests/harness/EclipseWorkspaceTest.java
deleted file mode 100644
index d305162..0000000
--- a/tests/org.eclipse.core.tests.harness/src/org/eclipse/core/tests/harness/EclipseWorkspaceTest.java
+++ /dev/null
@@ -1,851 +0,0 @@
-package org.eclipse.core.tests.harness;
-
-/*
- * (c) Copyright IBM Corp. 2000, 2001.
- * All Rights Reserved.
- */
-
-import java.io.*;
-
-import junit.framework.*;
-import org.eclipse.core.resources.*;
-import org.eclipse.core.runtime.*;
-
-/**
- * Tests which use the Eclipse Platform workspace.
- */
-
-public class EclipseWorkspaceTest extends TestCase {
- //constants for nature sets
- protected static final String SET_STATE = "org.eclipse.core.tests.resources.stateSet";
- protected static final String SET_OTHER = "org.eclipse.core.tests.resources.otherSet";
-
- //constants for nature ids
-
- //simpleNature
- protected static final String NATURE_SIMPLE = "org.eclipse.core.tests.resources.simpleNature";
- //snowNature, requires: waterNature, one-of: otherSet
- protected static final String NATURE_SNOW = "org.eclipse.core.tests.resources.snowNature";
- //waterNature, oneof: stateSet
- protected static final String NATURE_WATER = "org.eclipse.core.tests.resources.waterNature";
- //earthNature, oneof: stateSet
- protected static final String NATURE_EARTH = "org.eclipse.core.tests.resources.earthNature";
- //mudNature, requires: waterNature, earthNature, one-of: otherSet
- protected static final String NATURE_MUD = "org.eclipse.core.tests.resources.mudNature";
- //invalidNature
- protected static final String NATURE_INVALID = "org.eclipse.core.tests.resources.invalidNature";
- //cycle1 requires: cycle2
- protected static final String NATURE_CYCLE1 = "org.eclipse.core.tests.resources.cycle1";
- //cycle2 requires: cycle3
- protected static final String NATURE_CYCLE2 = "org.eclipse.core.tests.resources.cycle2";
- //cycle3 requires: cycle1
- protected static final String NATURE_CYCLE3 = "org.eclipse.core.tests.resources.cycle3";
- //missing nature
- protected static final String NATURE_MISSING= "no.such.nature.Missing";
- //missing pre-req nature
- protected static final String NATURE_MISSING_PREREQ= "org.eclipse.core.tests.resources.missingPrerequisiteNature";
-
- /** delta change listener if requested */
- public static IResourceChangeListener deltaListener;
-/**
- * Need a zero argument constructor to satisfy the test harness.
- * This constructor should not do any real work nor should it be
- * called by user code.
- */
-public EclipseWorkspaceTest() {
- super(null);
-}
-/**
- * Creates a new EclipseWorkspaceTest
- * @param name java.lang.String
- */
-public EclipseWorkspaceTest(String name) {
- super(name);
-}
-/**
- * Assert that each element of the resource array does not exist in the
- * local store.
- */
-public void assertDoesNotExistInFileSystem(IResource[] resources) {
- assertDoesNotExistInFileSystem("", resources);
-}
-/**
- * Assert that each element of the resource array does not exist in the
- * local store.
- */
-public void assertDoesNotExistInFileSystem(String message, IResource[] resources) {
- for (int i = 0; i < resources.length; i++) {
- assertDoesNotExistInFileSystem(message, resources[i]);
- }
-}
-/**
- * Assert that the given resource does not exist in the local store.
- */
-public void assertDoesNotExistInFileSystem(String message, IResource resource) {
- try {
- assertTrue(message, !existsInFileSystem(resource));
- } catch (CoreException e) {
- assertTrue(e.toString(), false);
- }
-}
-/**
- * Assert that the given resource does not exist in the local store.
- */
-public void assertDoesNotExistInFileSystem(IResource resource) {
- assertDoesNotExistInFileSystem("", resource);
-}
-/**
- * Assert that each element of the resource array does not exist
- * in the workspace resource info tree.
- */
-public void assertDoesNotExistInWorkspace(IResource[] resources) {
- assertDoesNotExistInWorkspace("", resources);
-}
-/**
- * Assert that each element of the resource array does not exist
- * in the workspace resource info tree.
- */
-public void assertDoesNotExistInWorkspace(String message, IResource[] resources) {
- for (int i = 0; i < resources.length; i++) {
- assertDoesNotExistInWorkspace(message, resources[i]);
- }
-}
-protected void assertEquals(String message, Object[] expected, Object[] actual) {
- if (expected == null && actual == null)
- return;
- if (expected == null || actual == null)
- fail(message);
- if (expected.length != actual.length)
- fail(message);
- for (int i = 0; i < expected.length; i++)
- assertEquals(message, expected[i], actual[i]);
-}
-/**
- * Assert that the given resource does not exist in the workspace
- * resource info tree.
- */
-public void assertDoesNotExistInWorkspace(String message, IResource resource) {
- assertTrue(message, !existsInWorkspace(resource));
-}
-/**
- * Assert that the given resource does not exist in the workspace
- * resource info tree.
- */
-public void assertDoesNotExistInWorkspace(IResource resource) {
- assertDoesNotExistInWorkspace("", resource);
-}
-/**
- * Assert that each element in the resource array exists in the local store.
- */
-public void assertExistsInFileSystem(IResource[] resources) {
- assertExistsInFileSystem("", resources);
-}
-/**
- * Assert that each element in the resource array exists in the local store.
- */
-public void assertExistsInFileSystem(String message, IResource[] resources) {
- for (int i = 0; i < resources.length; i++) {
- assertExistsInFileSystem(message, resources[i]);
- }
-}
-/**
- * Assert whether or not the given resource exists in the local
- * store. Use the resource manager to ensure that we have a
- * correct Path -> File mapping.
- */
-public void assertExistsInFileSystem(String message, IResource resource) {
- try {
- assertTrue(message, existsInFileSystem(resource));
- } catch (CoreException e) {
- assertTrue(e.toString(), false);
- }
-}
-/**
- * Assert whether or not the given resource exists in the local
- * store. Use the resource manager to ensure that we have a
- * correct Path -> File mapping.
- */
-public void assertExistsInFileSystem(IResource resource) {
- assertExistsInFileSystem("", resource);
-}
-/**
- * Assert that each element of the resource array exists in the
- * workspace resource info tree.
- */
-public void assertExistsInWorkspace(IResource[] resources) {
- assertExistsInWorkspace("", resources);
-}
-/**
- * Assert that each element of the resource array exists in the
- * workspace resource info tree.
- */
-public void assertExistsInWorkspace(IResource[] resources, boolean phantom) {
- assertExistsInWorkspace("", resources, phantom);
-}
-/**
- * Assert that each element of the resource array exists in the
- * workspace resource info tree.
- */
-public void assertExistsInWorkspace(String message, IResource[] resources) {
- for (int i = 0; i < resources.length; i++) {
- assertExistsInWorkspace(message, resources[i]);
- }
-}
-/**
- * Assert that each element of the resource array exists in the
- * workspace resource info tree.
- */
-public void assertExistsInWorkspace(String message, IResource[] resources, boolean phantom) {
- for (int i = 0; i < resources.length; i++) {
- assertExistsInWorkspace(message, resources[i], phantom);
- }
-}
-/**
- * Assert whether or not the given resource exists in the workspace
- * resource info tree.
- */
-public void assertExistsInWorkspace(String message, IResource resource) {
- assertTrue(message, existsInWorkspace(resource));
-}
-/**
- * Assert whether or not the given resource exists in the workspace
- * resource info tree.
- */
-public void assertExistsInWorkspace(String message, IResource resource, boolean phantom) {
- assertTrue(message, existsInWorkspace(resource, phantom));
-}
-/**
- * Assert whether or not the given resource exists in the workspace
- * resource info tree.
- */
-public void assertExistsInWorkspace(IResource resource) {
- assertExistsInWorkspace("", resource);
-}
-/**
- * Assert whether or not the given resource exists in the workspace
- * resource info tree.
- */
-public void assertExistsInWorkspace(IResource resource, boolean phantom) {
- assertExistsInWorkspace("", resource, phantom);
-}
-/**
- * Return a collection of resources the hierarcy defined by defineHeirarchy().
- */
-public IResource[] buildResources() {
- return buildResources(getWorkspace().getRoot(), defineHierarchy());
-}
-/**
- * Return a collection of resources for the given hierarchy at
- * the given root.
- */
-public IResource[] buildResources(IContainer root, String[] hierarchy) {
- IResource[] result = new IResource[hierarchy.length];
- for (int i = 0; i < hierarchy.length; i++) {
- IPath path = new Path(hierarchy[i]);
- IPath fullPath = root.getFullPath().append(path);
- switch (fullPath.segmentCount()) {
- case 0 :
- result[i] = getWorkspace().getRoot();
- break;
- case 1 :
- result[i] = getWorkspace().getRoot().getProject(fullPath.segment(0));
- break;
- default :
- if (hierarchy[i].charAt(hierarchy[i].length()-1) == Path.SEPARATOR)
- result[i] = (IResource) root.getFolder(path);
- else
- result[i] = (IResource) root.getFile(path);
- break;
- }
- }
- return result;
-}
-/**
- * Returns a boolean value indicating whether or not the contents
- * of the given streams are considered to be equal. Closes both input streams.
- */
-public boolean compareContent(InputStream a, InputStream b) {
- int c, d;
- if (a == null && b == null)
- return true;
- try {
- if (a == null || b == null)
- return false;
- while ((c = a.read()) == (d = b.read()) && (c != -1 && d != -1));
- return (c == -1 && d == -1);
- } catch (IOException e) {
- return false;
- } finally {
- try {
- if (a != null)
- a.close();
- } catch (IOException e) {
- }
- try {
- if (b != null)
- b.close();
- } catch (IOException e) {
- }
- }
-}
-private IPath computeDefaultLocation(IResource target) {
- switch (target.getType()) {
- case IResource.ROOT :
- return Platform.getLocation();
- case IResource.PROJECT :
- return Platform.getLocation().append(target.getFullPath());
- default :
- IPath location = computeDefaultLocation(target.getProject());
- location = location.append(target.getFullPath().removeFirstSegments(1));
- return location;
- }
-}
-private void create(final IResource resource, boolean local) throws CoreException {
- if (resource == null || resource.exists())
- return;
- if (!resource.getParent().exists())
- create(resource.getParent(), local);
- switch (resource.getType()) {
- case IResource.FILE :
- ((IFile) resource).create(local ? new ByteArrayInputStream(new byte[0]) : null, false, getMonitor());
- break;
- case IResource.FOLDER :
- ((IFolder) resource).create(false, local, getMonitor());
- break;
- case IResource.PROJECT :
- ((IProject) resource).create(getMonitor());
- ((IProject) resource).open(getMonitor());
- break;
- }
-}
-/**
- * Create the given file in the local store.
- */
-public void createFileInFileSystem(IPath path) throws CoreException {
- java.io.File file = path.toFile();
- new java.io.File(file.getParent()).mkdirs();
- FileOutputStream output = null;
- try {
- output = new FileOutputStream(file);
- output.write("".getBytes("UTF8"));
- } catch (IOException e) {
- throw new CoreException(new Status(IStatus.ERROR, "foo", 2, "Failed during write: " + path, e));
- } finally {
- try {
- if (output != null)
- output.close();
- } catch (IOException e) {
- }
- }
-}
-/**
- * Create the given file in the local store.
- */
-public void createFileInFileSystem(IPath path, InputStream contents) throws IOException {
- java.io.File file = path.toFile();
- new java.io.File(file.getParent()).mkdirs();
- FileOutputStream output = new FileOutputStream(file);
- transferData(contents, output);
-}
-public IResource[] createHierarchy() throws CoreException {
- IResource[] result = buildResources();
- ensureExistsInWorkspace(result, true);
- return result;
-}
-/**
- * Returns a collection of string paths describing the standard
- * resource hierarchy for this test. In the string forms, folders are
- * represented as having trailing separators ('/'). All other resources
- * are files. It is generally assumed that this hierarchy will be
- * inserted under some solution and project structure.
- * For example,
- * <pre>
- * return new String[] {"/", "/1/", "/1/1", "/1/2", "/1/3", "/2/", "/2/1"};
- * </pre>
- */
-public String[] defineHierarchy() {
- return new String[0];
-}
-/**
- * Delete the resources in the array from the local store.
- */
-public void ensureDoesNotExistInFileSystem(IResource[] resources) {
- for (int i = 0; i < resources.length; i++) {
- ensureDoesNotExistInFileSystem(resources[i]);
- }
-}
-protected void ensureDoesNotExistInFileSystem(java.io.File file) {
- if (!file.exists())
- return;
- if (file.isDirectory()) {
- String[] files = file.list();
- if (files != null) // be carefule since file.list() can return null
- for (int i = 0; i < files.length; ++i)
- ensureDoesNotExistInFileSystem(new java.io.File(file, files[i]));
- }
- if (!file.delete()) {
- System.out.println("WARNING: ensureDoesNotExistInFileSystem(File) could not delete: " + file.getPath());
- }
-}
-/**
- * Delete the given resource from the local store. Use the resource
- * manager to ensure that we have a correct Path -> File mapping.
- */
-public void ensureDoesNotExistInFileSystem(IResource resource) {
- IPath path = resource.getLocation();
- if (path != null)
- ensureDoesNotExistInFileSystem(path.toFile());
-}
-/**
- * Delete each element of the resource array from the workspace
- * resource info tree.
- */
-public void ensureDoesNotExistInWorkspace(final IResource[] resources) {
- IWorkspaceRunnable body = new IWorkspaceRunnable() {
- public void run(IProgressMonitor monitor) throws CoreException {
- for (int i = 0; i < resources.length; i++) {
- ensureDoesNotExistInWorkspace(resources[i]);
- }
- }
- };
- try {
- getWorkspace().run(body, null);
- } catch (CoreException e) {
- fail("#ensureDoesNotExistInWorkspace(IResource[])", e);
- }
-}
-/**
- * Delete the given resource from the workspace resource tree.
- */
-public void ensureDoesNotExistInWorkspace(IResource resource) {
- try {
- if (resource.exists())
- resource.delete(true, null);
- } catch (CoreException e) {
- fail("#ensureDoesNotExistInWorkspace(IResource): " + resource.getFullPath(), e);
- }
-}
-/**
- * Create the each resource of the array in the local store.
- */
-public void ensureExistsInFileSystem(IResource[] resources) {
- for (int i = 0; i < resources.length; i++) {
- ensureExistsInFileSystem(resources[i]);
- }
-}
-/**
- * Create the given file in the local store. Use the resource manager
- * to ensure that we have a correct Path -> File mapping.
- */
-public void ensureExistsInFileSystem(IFile file) {
- IPath path = file.getLocation();
- try {
- if (path != null)
- createFileInFileSystem(path);
- } catch (CoreException e) {
- fail("#ensureExistsInFileSystem(IFile): " + file.getFullPath(), e);
- }
-}
-/**
- * Create the given folder in the local store. Use the resource
- * manager to ensure that we have a correct Path -> File mapping.
- */
-public void ensureExistsInFileSystem(IResource resource) {
- if (resource instanceof IFile)
- ensureExistsInFileSystem((IFile) resource);
- else {
- IPath path = resource.getLocation();
- if (path != null)
- path.toFile().mkdirs();
- }
-}
-/**
- * Create each element of the resource array in the workspace resource
- * info tree.
- */
-public void ensureExistsInWorkspace(final IResource[] resources, final boolean local) {
- IWorkspaceRunnable body = new IWorkspaceRunnable() {
- public void run(IProgressMonitor monitor) throws CoreException {
- for (int i = 0; i < resources.length; i++)
- create(resources[i], local);
- }
- };
- try {
- getWorkspace().run(body, null);
- } catch (CoreException e) {
- fail("#ensureExistsInWorkspace(IResource[])", e);
- }
-}
-/**
- * Create the given file in the workspace resource info tree.
- */
-public void ensureExistsInWorkspace(final IFile resource, final InputStream contents) {
- if (resource == null)
- return;
- IWorkspaceRunnable body = new IWorkspaceRunnable() {
- public void run(IProgressMonitor monitor) throws CoreException {
- if (resource.exists()) {
- resource.setContents(contents, true, false, null);
- } else {
- ensureExistsInWorkspace(resource.getParent(), true);
- resource.create(contents, true, null);
- }
- }
- };
- try {
- getWorkspace().run(body, null);
- } catch (CoreException e) {
- fail("#ensureExistsInWorkspace(IFile, InputStream): " + resource.getFullPath(), e);
- }
-}
-/**
- * Create the given file in the workspace resource info tree.
- */
-public void ensureExistsInWorkspace(IFile resource, String contents) {
- ensureExistsInWorkspace(resource, new ByteArrayInputStream(contents.getBytes()));
-}
-/**
- * Create the given resource in the workspace resource info tree.
- */
-public void ensureExistsInWorkspace(final IResource resource, final boolean local) {
- IWorkspaceRunnable body = new IWorkspaceRunnable() {
- public void run(IProgressMonitor monitor) throws CoreException {
- create(resource, local);
- }
- };
- try {
- getWorkspace().run(body, null);
- } catch (CoreException e) {
- fail("#ensureExistsInWorkspace(IResource): " + resource.getFullPath(), e);
- }
-}
-private boolean existsInFileSystem(IResource resource) throws CoreException {
- IPath path = resource.getLocation();
- if (path == null)
- path = computeDefaultLocation(resource);
- return path.toFile().exists();
-}
-private boolean existsInWorkspace(IResource resource) {
- return resource.exists();
-}
-private boolean existsInWorkspace(IResource resource, boolean phantom) {
- IResource target = getWorkspace().getRoot().findMember(resource.getFullPath(), phantom);
- return target != null && target.getType() == resource.getType();
-}
-/**
- * Fails the test due to the given exception.
- * @param message
- * @param e
- */
-public void fail(String message, Exception e) {
- // If the exception is a CoreException with a multistatus
- // then print out the multistatus so we can see all the info.
- if (e instanceof CoreException) {
- IStatus status = ((CoreException) e).getStatus();
- if (status.getChildren().length > 0) {
- write(status, 0);
- }
- }
- fail(message + ": " + e);
-}
-protected void indent(OutputStream output, int indent) {
- for (int i=0; i<indent; i++)
- try {
- output.write("\t".getBytes());
- } catch(IOException e) {
- }
-}
-protected void write(IStatus status, int indent) {
- PrintStream output = System.out;
- indent(output, indent);
- output.println("Severity: " + status.getSeverity());
-
- indent(output, indent);
- output.println("Plugin ID: " + status.getPlugin());
-
- indent(output, indent);
- output.println("Code: " + status.getCode());
-
- indent(output, indent);
- output.println("Message: " + status.getMessage());
-
- if (status.isMultiStatus()) {
- IStatus[] children = status.getChildren();
- for (int i = 0; i < children.length; i++) {
- write(children[i], indent + 1);
- }
- }
-}
-/**
- * Does some garbage collections to free unused resources
- */
-protected static void gc() {
- /* make sure old stores get finalized so they free old files */
- for (int i = 0; i < 2; i++) {
- System.runFinalization();
- System.gc();
- }
-}
-/**
- * Returns the unqualified class name of the receiver (ie. without the package prefix).
- */
-protected String getClassName() {
- String fullClassName = getClass().getName();
- return fullClassName.substring(fullClassName.lastIndexOf(".") + 1);
-}
-public InputStream getContents(java.io.File target, String errorCode) {
- try {
- return new FileInputStream(target);
- } catch (IOException e) {
- fail(errorCode, e);
- }
- return null; // never happens
-}
-/**
- * Return an input stream with some the specified text to use
- * as contents for a file resource.
- */
-public InputStream getContents(String text) {
- return new ByteArrayInputStream(text.getBytes());
-}
-/**
- * Returns invalid sets of natures
- */
-protected String[][] getInvalidNatureSets() {
- return new String[][] {
- {NATURE_SNOW},//missing water pre-req
- {NATURE_WATER, NATURE_EARTH},//duplicates from state-set
- {NATURE_WATER, NATURE_MUD},//missing earth pre-req
- {NATURE_WATER, NATURE_EARTH, NATURE_MUD},//duplicates from state-set
- {NATURE_SIMPLE, NATURE_SNOW, NATURE_WATER, NATURE_MUD},//dups from other-set, missing pre-req
- {NATURE_MISSING},//doesn't exist
- {NATURE_SIMPLE, NATURE_MISSING},//missing doesn't exist
- {NATURE_MISSING_PREREQ},//requires nature that doesn't exist
- {NATURE_SIMPLE, NATURE_MISSING_PREREQ},//requires nature that doesn't exist
- {NATURE_CYCLE1},//missing pre-req
- {NATURE_CYCLE2, NATURE_CYCLE3},//missing pre-req
- {NATURE_CYCLE1, NATURE_SIMPLE, NATURE_CYCLE2, NATURE_CYCLE3},//cycle
- };
-}
-public IProgressMonitor getMonitor() {
- return new FussyProgressMonitor();
-}
-/**
- * Return an input stream with some random text to use
- * as contents for a file resource.
- */
-public InputStream getRandomContents() {
- return new ByteArrayInputStream(getRandomString().getBytes());
-}
-/**
- * Return String with some random text to use
- * as contents for a file resource.
- */
-public String getRandomString() {
- switch ((int) Math.round(Math.random() * 10)) {
- case 0 :
- return "este e' o meu conteudo (portuguese)";
- case 1 :
- return "ho ho ho";
- case 2 :
- return "I'll be back";
- case 3 :
- return "don't worry, be happy";
- case 4 :
- return "there is no imagination for more sentences";
- case 5 :
- return "customize yours";
- case 6 :
- return "foo";
- case 7 :
- return "bar";
- case 8 :
- return "foobar";
- case 9 :
- return "case 9";
- default :
- return "these are my contents";
- }
-}
-/**
- * Returns valid sets of natures
- */
-protected String[][] getValidNatureSets() {
- return new String[][] {
- {},
- {NATURE_SIMPLE},
- {NATURE_SNOW, NATURE_WATER},
- {NATURE_EARTH},
- {NATURE_WATER, NATURE_SIMPLE, NATURE_SNOW},
- };
-}
-public static IWorkspace getWorkspace() {
- return ResourcesPlugin.getWorkspace();
-}
-/**
- * Modifies the content of the given file in the file system by
- * appending an 'f'.
- * @param file
- */
-protected void modifyInFileSystem(IFile file) {
- String m = getClassName() + ".modifyInFileSystem(IFile): ";
- String newContent = readStringInFileSystem(file) + "f";
- java.io.File osFile = file.getLocation().toFile();
- try {
- FileOutputStream os = null;
- try {
- os = new FileOutputStream(osFile);
- os.write(newContent.getBytes("UTF8"));
- } finally {
- os.close();
- }
- } catch (IOException e) {
- fail(m + "0.0", e);
- }
-}
-/**
- * Modifies the content of the given file in the workspace by
- * appending a 'w'.
- * @param file
- */
-protected void modifyInWorkspace(IFile file) throws CoreException {
- String m = getClassName() + ".modifyInWorkspace(IFile): ";
- try {
- String newContent = readStringInWorkspace(file) + "w";
- ByteArrayInputStream is = new ByteArrayInputStream(newContent.getBytes("UTF8"));
- file.setContents(is, false, false, null);
- } catch (UnsupportedEncodingException e) {
- fail(m + "0.0");
- }
-}
-/**
- * Returns the content of the given file in the file system as a
- * byte array.
- * @param file
- */
-protected byte[] readBytesInFileSystem(IFile file){
- String m = getClassName()+".readBytesInFileSystem(IFile): ";
- try {
- java.io.File osFile = file.getLocation().toFile();
- FileInputStream is = new FileInputStream(osFile);
- ByteArrayOutputStream os = new ByteArrayOutputStream();
- transferData(is, os);
- return os.toByteArray();
- } catch(IOException e){
- fail(m+"0.0", e);
- }
- return null;
-}
-/**
- * Returns the content of the given file in the workspace as a
- * byte array.
- */
-protected byte[] readBytesInWorkspace(IFile file){
- String m = getClassName()+".readBytesInWorkspace(IFile): ";
- try {
- InputStream is = file.getContents(false);
- ByteArrayOutputStream os = new ByteArrayOutputStream();
- transferData(is, os);
- return os.toByteArray();
- } catch(CoreException e){
- fail(m+"0.0", e);
- }
- return null;
-}
-/**
- * Returns the content of the given file in the file system as a
- * String (UTF8).
- * @param file
- */
-protected String readStringInFileSystem(IFile file){
- String m = getClassName()+".readStringInFileSystem(IFile): ";
- try {
- return new String(readBytesInFileSystem(file), "UTF8");
- } catch(UnsupportedEncodingException e){
- fail(m+"0.0", e);
- }
- return null;
-}
-/**
- * Returns the content of the given file in the workspace as a
- * String (UTF8).
- * @param file
- */
-protected String readStringInWorkspace(IFile file){
- String m = getClassName()+".readStringInWorkspace(IFile): ";
- try {
- return new String(readBytesInWorkspace(file), "UTF8");
- } catch(UnsupportedEncodingException e){
- fail(m+"0.0", e);
- }
- return null;
-}
-/**
- * The environment should be set-up in the main method.
- */
-protected void setUp() throws Exception {
- assertNotNull("Workspace was not setup", getWorkspace());
- if (EclipseTestHarnessApplication.deltasEnabled() && deltaListener == null) {
- deltaListener = new DeltaDebugListener();
- getWorkspace().addResourceChangeListener(deltaListener);
- }
-}
-/**
- * Returns the test suite for this test class.
- */
-public static Test suite() {
- TestSuite suite = new TestSuite();
- return suite;
-}
-/**
- * Copy the data from the input stream to the output stream.
- * Close both streams when finished.
- */
-public void transferData(InputStream input, OutputStream output) {
- try {
- try {
- int c = 0;
- while ((c = input.read()) != -1) {
- output.write(c);
- }
- } finally {
- input.close();
- output.close();
- }
- } catch (IOException e) {
- e.printStackTrace();
- assertTrue(e.toString(), false);
- }
-}
-/**
- * Copy the data from the input stream to the output stream.
- * Do not close either of the streams.
- */
-public void transferDataWithoutClose(InputStream input, OutputStream output) {
- try {
- int c = 0;
- while ((c = input.read()) != -1) {
- output.write(c);
- }
- } catch (IOException e) {
- e.printStackTrace();
- assertTrue(e.toString(), false);
- }
-}
-/**
- * Log messages if we are in debug mode.
- */
-public static void log(String message) {
- String id = "org.eclipse.core.tests.harness";
- Plugin plugin = Platform.getPlugin(id);
- if (plugin.isDebugging())
- System.out.println(message);
-}
-protected void tearDown() throws Exception {
- super.tearDown();
- // Ensure everything is in a clean state for next one.
- // Session tests should overwrite it.
- ensureDoesNotExistInWorkspace(getWorkspace().getRoot());
- getWorkspace().save(true, null);
-}
-}
\ No newline at end of file
diff --git a/tests/org.eclipse.core.tests.harness/src/org/eclipse/core/tests/harness/ExampleTest.java b/tests/org.eclipse.core.tests.harness/src/org/eclipse/core/tests/harness/ExampleTest.java
deleted file mode 100644
index b05bda4..0000000
--- a/tests/org.eclipse.core.tests.harness/src/org/eclipse/core/tests/harness/ExampleTest.java
+++ /dev/null
@@ -1,48 +0,0 @@
-package org.eclipse.core.tests.harness;
-
-/*
- * (c) Copyright IBM Corp. 2000, 2001.
- * All Rights Reserved.
- */
-
-import java.util.Arrays;
-import java.util.Comparator;
-
-import junit.framework.*;
-import org.eclipse.core.runtime.IPluginDescriptor;
-import org.eclipse.core.runtime.Platform;
-
-/**
- * Tests which use the Eclipse Platform runtime only.
- */
-public class ExampleTest extends TestCase {
-/**
- * Need a zero argument constructor to satisfy the test harness.
- * This constructor should not do any real work nor should it be
- * called by user code.
- */
-public ExampleTest() {
- super(null);
-}
-public ExampleTest(String name) {
- super(name);
-}
-public static Test suite() {
- return new TestSuite(ExampleTest.class);
-}
-public void testPluginRegistry() throws Throwable {
- System.out.println();
- IPluginDescriptor[] descriptors = Platform.getPluginRegistry().getPluginDescriptors();
- Comparator c = new Comparator() {
- public int compare(Object a, Object b) {
- return ((IPluginDescriptor) a).getLabel().compareTo(((IPluginDescriptor) b).getLabel());
- }
- };
- Arrays.sort(descriptors, c);
- for (int i = 0; i < descriptors.length; i++) {
- IPluginDescriptor descriptor = descriptors[i];
- System.out.print(descriptor.isPluginActivated() ? "+\t" : "-\t");
- System.out.println(descriptor.getLabel() + " (" + descriptor.getUniqueIdentifier() + ") [" + descriptor.getVersionIdentifier() + "]");
- }
-}
-}
diff --git a/tests/org.eclipse.core.tests.harness/src/org/eclipse/core/tests/harness/ExampleWorkspaceTest.java b/tests/org.eclipse.core.tests.harness/src/org/eclipse/core/tests/harness/ExampleWorkspaceTest.java
deleted file mode 100644
index c671ef5..0000000
--- a/tests/org.eclipse.core.tests.harness/src/org/eclipse/core/tests/harness/ExampleWorkspaceTest.java
+++ /dev/null
@@ -1,130 +0,0 @@
-package org.eclipse.core.tests.harness;
-
-/*
- * (c) Copyright IBM Corp. 2000, 2001.
- * All Rights Reserved.
- */
-
-import java.io.InputStream;
-
-import junit.framework.Test;
-import junit.framework.TestSuite;
-import org.eclipse.core.resources.*;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.Path;
-
-/**
- * Tests which use the Eclipse Platform workspace.
- */
-public class ExampleWorkspaceTest extends EclipseWorkspaceTest {
-/**
- * Need a zero argument constructor to satisfy the test harness.
- * This constructor should not do any real work nor should it be
- * called by user code.
- */
-public ExampleWorkspaceTest() {
- super();
-}
-public ExampleWorkspaceTest(String name) {
- super(name);
-}
-protected IProject getTestProject() {
- return getWorkspace().getRoot().getProject("testProject");
-}
-/**
- * Returns the test suite for this test class.
- */
-public static Test suite() {
- TestSuite suite = new TestSuite();
- suite.addTest(new ExampleWorkspaceTest("testProjectCreation"));
- suite.addTest(new ExampleWorkspaceTest("testFolderCreation"));
- suite.addTest(new ExampleWorkspaceTest("testFileCreation"));
- suite.addTest(new ExampleWorkspaceTest("testFileInFolderCreation"));
- suite.addTest(new ExampleWorkspaceTest("testSetContents"));
- suite.addTest(new ExampleWorkspaceTest("testFileOverFolder"));
- suite.addTest(new ExampleWorkspaceTest("testFolderOverFile"));
- suite.addTest(new ExampleWorkspaceTest("testFolderDeletion"));
- suite.addTest(new ExampleWorkspaceTest("testFileDeletion"));
- suite.addTest(new ExampleWorkspaceTest("testProjectDeletion"));
- return suite;
-}
-public void testFileCreation() throws Throwable {
- IFile target = getTestProject().getFile("testFile");
- target.create(null, true, getMonitor());
- assertTrue(target.exists());
-}
-public void testFileDeletion() throws Throwable {
- IFile target = getTestProject().getFile("testFileForDelete");
- target.create(null, true, getMonitor());
- assertTrue(target.exists());
- target.delete(true, getMonitor());
- assertTrue(!target.exists());
-}
-public void testFileInFolderCreation() throws Throwable {
- IFile target = getTestProject().getFile(new Path("testFolder/testFile2"));
- target.create(getRandomContents(), true, getMonitor());
- assertTrue(target.exists());
-}
-public void testFileOverFolder() throws Throwable {
- IFolder existing = getTestProject().getFolder("testFolder");
- assertTrue(existing.exists());
- IFile target = getWorkspace().getRoot().getFile(existing.getFullPath());
- try {
- target.create(null, true, getMonitor());
- } catch (CoreException e) {
- assertTrue(existing.exists());
- return;
- }
- fail("Should not be able to create file over folder");
-}
-public void testFolderCreation() throws Throwable {
- IFolder target = getTestProject().getFolder("testFolder");
- target.create(true, true, getMonitor());
- assertTrue(target.exists());
-}
-public void testFolderDeletion() throws Throwable {
- IProject project = getTestProject();
- IResource[] before = buildResources(project, new String[] {"c/", "c/b/", "c/x", "c/b/y", "c/b/z"});
- ensureExistsInWorkspace(before, true);
- //
- assertExistsInWorkspace(before);
- project.getFolder("c").delete(true, getMonitor());
- assertDoesNotExistInWorkspace(before);
-}
-public void testFolderOverFile() throws Throwable {
- IFile existing = getTestProject().getFile("testFile");
- assertTrue(existing.exists());
- IFolder target = getWorkspace().getRoot().getFolder(existing.getFullPath());
- try {
- target.create(true, true, getMonitor());
- } catch (CoreException e) {
- assertTrue(existing.exists());
- return;
- }
- fail("Should not be able to create folder over a file");
-}
-public void testProjectCreation() throws Throwable {
- IProject target = getTestProject();
- target.create(null, getMonitor());
- assertTrue(target.exists());
- target.open(getMonitor());
- assertTrue(target.isOpen());
-}
-public void testProjectDeletion() throws Throwable {
- IProject target = getTestProject();
- target.delete(true, getMonitor());
- assertTrue("Project Deletion failed", !target.exists());
-}
-public void testSetContents() throws Throwable {
- IFile target = getTestProject().getFile("testFile");
- String testString = getRandomString();
- target.setContents(getContents(testString), true, false, getMonitor());
- InputStream content = null;
- try {
- content = target.getContents();
- assertTrue("get not equal set", compareContent(content, getContents(testString)));
- } finally {
- content.close();
- }
-}
-}
diff --git a/tests/org.eclipse.core.tests.harness/src/org/eclipse/core/tests/harness/FussyProgressMonitor.java b/tests/org.eclipse.core.tests.harness/src/org/eclipse/core/tests/harness/FussyProgressMonitor.java
deleted file mode 100644
index 3159240..0000000
--- a/tests/org.eclipse.core.tests.harness/src/org/eclipse/core/tests/harness/FussyProgressMonitor.java
+++ /dev/null
@@ -1,144 +0,0 @@
-package org.eclipse.core.tests.harness;
-
-/*
- * (c) Copyright IBM Corp. 2000, 2001.
- * All Rights Reserved.
- */
-
-import junit.framework.AssertionFailedError;
-
-/**
- * This class can be used for testing progress monitoring.
- * If you want to reuse one instance of this class for several
- * invocations, make sure that you call prepare() before every
- * invocation.
- * Call sanityCheck() after the operation whose progress monitoring
- * you are testing.
- */
-
-public class FussyProgressMonitor extends TestProgressMonitor {
- private static final double EPS_FACTOR = 0.01;
- private String taskName;
- private int totalWork;
- private double workedSoFar = 0;
- private boolean beginTaskCalled = false;
- private long beginTime;
- private static final long NOTICEABLE_DELAY = 1000; // milliseconds
- private int doneCalls = 0;
- private boolean sanityCheckCalled = true;
- private boolean hasFailed = false;
- public class FussyProgressAssertionFailed extends AssertionFailedError {
- FussyProgressAssertionFailed(String name) {
- super(name);
- }
- }
-public FussyProgressMonitor() {
- prepare();
-}
-/**
- *
- * @param reason java.lang.String
- * @param condition boolean
- */
-private void assert(String reason, boolean condition) {
- // silently ignore follow-up failures
- if (hasFailed)
- return;
- if (!condition) {
- hasFailed = true;
- throw new FussyProgressAssertionFailed(reason);
- }
- //Assert.assert(reason, condition);
-}
-/**
- * @see IProgressMonitor#beginTask
- */
-public void beginTask(String name, int totalWork) {
- //if (beginTaskCalled && doneCalls > 0) {
- // this is a second call to beginTask which is allowed because
- // the previous task is done.
- //prepare();
- //}
- assert("beginTask may only be called once (old name=" + taskName + ")", beginTaskCalled == false);
- beginTaskCalled = true;
- taskName = name;
- assert("total work must be positive or UNKNOWN", totalWork > 0 || totalWork == UNKNOWN);
- this.totalWork = totalWork;
-}
-/**
- * @see IProgressMonitor#done
- */
-public void done() {
- assert("done must be called after beginTask", beginTaskCalled);
- assert("done can only be called once", doneCalls==0);
- //assert("done is called before all work is done", totalWork==UNKNOWN || totalWork==workedSoFar);
- workedSoFar = totalWork;
- doneCalls++;
-}
-public void internalWorked(double work) {
- assert("can accept calls to worked/internalWorked only after beginTask", beginTaskCalled);
- assert("can accept calls to worked/internalWorked only before done is called", doneCalls == 0);
- assert("amount worked should be positive, not " + work, work >= 0);
- if(work==0) EclipseWorkspaceTest.log("INFO: amount worked should be positive, not " + work);
- workedSoFar += work;
- assert("worked " + (workedSoFar - totalWork) + " more than totalWork", totalWork == UNKNOWN || workedSoFar <= totalWork + (totalWork * EPS_FACTOR));
-}
-/**
- * @see IProgressMonitor#isCanceled
- */
-public boolean isCanceled() {
- return false;
-}
-/**
- * should be called before every use of a FussyProgressMonitor
- */
-public void prepare() {
- //if (!sanityCheckCalled)
- //EclipseWorkspaceTest.log("sanityCheck has not been called for previous use");
- sanityCheckCalled = false;
- taskName = null;
- totalWork = 0;
- workedSoFar = 0;
- beginTaskCalled = false;
- doneCalls = 0;
- hasFailed = false;
- beginTime = System.currentTimeMillis();
-}
-/**
- * should be called after every use of a FussyProgressMonitor
- */
-public void sanityCheck() {
- if (sanityCheckCalled)
- EclipseWorkspaceTest.log("sanityCheck has already been called");
- sanityCheckCalled = true;
-// EclipseWorkspaceTest.log("sanity checking: " + taskName + " : " + (System.currentTimeMillis() - beginTime) + " ms, " + workedSoFar);
- if (System.currentTimeMillis() - beginTime > NOTICEABLE_DELAY) {
- assert("this operation took a long time, it should report progress", workedSoFar > 0);
- }
- assert("done has not been called on ProgressMonitor", hasFailed || !beginTaskCalled || doneCalls > 0);
-}
-/**
- * @see IProgressMonitor#setCanceled
- */
-public void setCanceled(boolean b) {
- assert("1FV0BJL: Who might be calling this method?", false);
-}
-/**
- * @see IProgressMonitor#setTaskName
- */
-public void setTaskName(String name) {
- taskName = name;
-}
-/**
- * @see IProgressMonitor#subTask
- */
-public void subTask(String name) {
- // do nothing
-}
-/**
- * @see IProgressMonitor#worked
- */
-public void worked(int work) {
- internalWorked(work);
-}
-}
diff --git a/tests/org.eclipse.core.tests.harness/src/org/eclipse/core/tests/harness/LoggingPerformanceTestResult.java b/tests/org.eclipse.core.tests.harness/src/org/eclipse/core/tests/harness/LoggingPerformanceTestResult.java
deleted file mode 100644
index 426ae25..0000000
--- a/tests/org.eclipse.core.tests.harness/src/org/eclipse/core/tests/harness/LoggingPerformanceTestResult.java
+++ /dev/null
@@ -1,127 +0,0 @@
-package org.eclipse.core.tests.harness;
-
-/*
- * (c) Copyright IBM Corp. 2000, 2001.
- * All Rights Reserved.
- */
-
-import java.io.*;
-import java.util.Enumeration;
-
-import junit.framework.TestFailure;
-/**
- * A LoggingPerformanceTestResult adds the ability to create an HTML or
- * other output file, and have test results written to that file instead
- * of the standard output.
- */
-public class LoggingPerformanceTestResult extends PerformanceTestResult {
- PrintWriter fLog;
-/**
- * LoggingPerformanceTestResult constructor comment.
- */
-public LoggingPerformanceTestResult(File logFile) {
- super();
- try {
- fLog = new PrintWriter(new FileOutputStream(logFile));
- printHTMLHeader(fLog);
- } catch (IOException e) {
- System.out.println("Unable to open log output file: " + logFile);
- fLog = new PrintWriter(System.out);
- }
-}
- /**
- * Logs the given string in the test log file
- */
- public synchronized void log(String s) {
- fLog.println(s);
- }
- /**
- * Prints the test result
- */
- public synchronized void print() {
- stopTimers();
- printHeader(fLog);
- printTimings(fLog);
- printErrors(fLog);
- printHTMLTrailer(fLog);
- }
-/**
- * Prints the errors to the standard output
- */
-protected void printErrors(PrintWriter out) {
- out.println("<h3>Error summary</h3>");
- int count = errorCount();
- if (count != 0) {
- if (count == 1)
- out.println("There was " + count + " error:<p>");
- else
- out.println("There were " + count + " errors:<p>");
- int i = 1;
- for (Enumeration e = errors(); e.hasMoreElements(); i++) {
- TestFailure failure = (TestFailure) e.nextElement();
- out.println(i + ") " + failure.failedTest() + "<p>");
- failure.thrownException().printStackTrace();
- out.println("<p>");
- }
- } else {
- out.println("No errors reported.");
- }
-}
- /**
- * Prints the header of the report
- */
- protected void printHeader(PrintWriter out) {
- }
- /**
- * Prints the header of the report
- */
- protected void printHTMLHeader(PrintWriter out) {
- StringBuffer buf = new StringBuffer();
- buf.append("<html>\n<head>\n<title>Leapfrog Performance Test Output Page</title>");
- buf.append("<author>AutoGen imagebuilder.tests.LoggingPerformanceTestResult</author>\n");
- buf.append("</head>\n<body>\n");
- out.println(buf.toString());
- }
- /**
- * Prints the header of the report
- */
- protected void printHTMLTrailer(PrintWriter out) {
- out.println("</body>");
- out.println("</html>");
- }
- /**
- * Prints the timings of the result.
- */
-
- protected void printTimings(PrintWriter out) {
- out.println("<h3>Timing summary</h3>");
- out.println("<ul>");
-
- // print out all timing results to the console
- Enumeration enum = fTimerList.elements();
- while (enum.hasMoreElements()) {
- PerformanceTimer timer = (PerformanceTimer)enum.nextElement();
- out.println("<li>" + timer.getName() + " : " + timer.getElapsedTime() + " ms</li>");
- }
- out.println("</ul>");
- }
-/**
- * Start the timer with the given name. If the timer has already
- * been created, send it a startTiming message. If not, create it
- * and send the new timer the startTiming message.
- */
-
- public synchronized void startTimer(String timerName) {
- super.startTimer(timerName);
- //log("Starting timer: " + timerName);
- }
-/**
- * Look up the timer with the given name and send it a stopTiming
- * message. If the timer does not exist, report an error.
- */
-
- public synchronized void stopTimer(String timerName) {
- super.stopTimer(timerName);
- //log("Stopping timer: " + timerName);
- }
-}
diff --git a/tests/org.eclipse.core.tests.harness/src/org/eclipse/core/tests/harness/PerformanceTestResult.java b/tests/org.eclipse.core.tests.harness/src/org/eclipse/core/tests/harness/PerformanceTestResult.java
deleted file mode 100644
index 2c4c597..0000000
--- a/tests/org.eclipse.core.tests.harness/src/org/eclipse/core/tests/harness/PerformanceTestResult.java
+++ /dev/null
@@ -1,138 +0,0 @@
-package org.eclipse.core.tests.harness;
-
-/*
- * (c) Copyright IBM Corp. 2000, 2001.
- * All Rights Reserved.
- */
-
-import java.io.PrintStream;
-import java.util.*;
-
-import junit.framework.*;
-
-/**
- * Test result for a performance test. Keeps track of all timers that
- * have been created within the test.
- */
-
-public class PerformanceTestResult extends TestResult {
- Hashtable fTimers = new Hashtable();
- Vector fTimerList = new Vector();
-/**
- * PerformanceTestResult constructor comment.
- */
-public PerformanceTestResult() {
- super();
-}
-/**
- * Informs the result that a test was completed.
- */
-public synchronized void endTest(Test test) {
- print();
-}
-/**
- * Prints the test result
- */
-
-
-public synchronized void print() {
- stopTimers();
- printHeader(System.out);
- printErrors(System.out);
- printTimings(System.out);
-}
-/**
- * Prints the errors to the standard output
- */
-protected void printErrors(PrintStream out) {
- int count = errorCount();
- if (count != 0) {
- if (count == 1)
- out.println("There was " + count + " error:");
- else
- out.println("There were " + count + " errors:");
- int i = 1;
- for (Enumeration e = errors(); e.hasMoreElements(); i++) {
- TestFailure failure = (TestFailure) e.nextElement();
- out.println(i + ") " + failure.failedTest());
- failure.thrownException().printStackTrace();
- }
- }
-}
-/**
- * Prints the header of the report
- */
-protected void printHeader(PrintStream out) {
- if (wasSuccessful()) {
- out.println();
- out.print("OK");
- out.println(" (" + runCount() + " tests)");
- } else {
- out.println();
- out.println("!!!FAILURES!!!");
- out.println("Test Results:");
- out.println("Run: " + runCount() + " Failures: " + failureCount() + " Errors: " + errorCount());
- }
-}
- /**
- * Prints the timings of the result.
- */
-
- protected void printTimings(PrintStream out) {
-
- // print out all timing results to the console
- Enumeration enum = fTimerList.elements();
- while (enum.hasMoreElements()) {
- PerformanceTimer timer = (PerformanceTimer)enum.nextElement();
- out.println("Timing " + timer.getName() + " : " + timer.getElapsedTime() + " ms ");
- }
- }
-/**
- * Start the test
- */
-
-public synchronized void startTest(Test test) {
- super.startTest(test);
- System.out.print(".");
-}
-/**
- * Start the timer with the given name. If the timer has already
- * been created, send it a startTiming message. If not, create it
- * and send the new timer the startTiming message.
- */
-
- public synchronized void startTimer(String timerName) {
- PerformanceTimer timer = (PerformanceTimer) fTimers.get(timerName);
- if( timer == null) {
- timer = new PerformanceTimer(timerName);
- fTimers.put(timerName, timer);
- fTimerList.addElement(timer);
- }
- timer.startTiming();
- }
-/**
- * Look up the timer with the given name and send it a stopTiming
- * message. If the timer does not exist, report an error.
- */
-
- public synchronized void stopTimer(String timerName) {
- PerformanceTimer timer = (PerformanceTimer) fTimers.get(timerName);
- if (timer == null) {
- throw new Error(timerName + " is not a valid timer name ");
- }
- timer.stopTiming();
- }
- /**
- * Stops all timers
- */
-
- protected void stopTimers() {
-
- Enumeration enum = fTimerList.elements();
- PerformanceTimer timer = null;
-
- while (enum.hasMoreElements()) {
- ((PerformanceTimer) enum.nextElement()).stopTiming();
- }
- }
-}
diff --git a/tests/org.eclipse.core.tests.harness/src/org/eclipse/core/tests/harness/PerformanceTimer.java b/tests/org.eclipse.core.tests.harness/src/org/eclipse/core/tests/harness/PerformanceTimer.java
deleted file mode 100644
index 0682671..0000000
--- a/tests/org.eclipse.core.tests.harness/src/org/eclipse/core/tests/harness/PerformanceTimer.java
+++ /dev/null
@@ -1,53 +0,0 @@
-package org.eclipse.core.tests.harness;
-
-/*
- * (c) Copyright IBM Corp. 2000, 2001.
- * All Rights Reserved.
- */
-
-import java.util.*;
-
-/**
- * The timer class used by performance tests.
- */
-
-class PerformanceTimer {
- private String fName;
- private long fElapsedTime;
- private long fStartTime;
-/**
- *
- */
-public PerformanceTimer(String name) {
- fName = name;
- fElapsedTime = 0;
- fStartTime = 0;
-}
-/**
- * Return the elapsed time.
- */
-public long getElapsedTime() {
- return fElapsedTime;
-}
-/**
- * Return the timer name.
- */
-public String getName() {
- return fName;
-}
-/**
- * Start the timer.
- */
-public void startTiming() {
- fStartTime = System.currentTimeMillis();
-}
-/**
- * Stop the timer, add the elapsed time to the total.
- */
-public void stopTiming() {
- if (fStartTime == 0) return;
- long timeNow = System.currentTimeMillis();
- fElapsedTime += (timeNow - fStartTime);
- fStartTime = 0;
-}
-}
diff --git a/tests/org.eclipse.core.tests.harness/src/org/eclipse/core/tests/harness/SessionTestApplication.java b/tests/org.eclipse.core.tests.harness/src/org/eclipse/core/tests/harness/SessionTestApplication.java
deleted file mode 100644
index aab6fca..0000000
--- a/tests/org.eclipse.core.tests.harness/src/org/eclipse/core/tests/harness/SessionTestApplication.java
+++ /dev/null
@@ -1,48 +0,0 @@
-package org.eclipse.core.tests.harness;
-
-import java.lang.reflect.InvocationTargetException;
-import java.lang.reflect.Method;
-
-import junit.framework.Test;
-import junit.framework.TestCase;
-
-/**
- * Harness for running eclipse workspace session tests. See the class comments in
- * the class WorkspaceSessionTest for more information.
- */
-public class SessionTestApplication extends EclipseTestHarnessApplication {
-/**
- * Test names can have two forms:
- * 1) Unqualified test ID -> Run the suite method for that test class
- * 2) Qualified ID + method name -> Run the single test method with the given name.
- */
-protected Object run(String testName) throws Exception {
- if (testName.indexOf('#') == -1) {
- return super.run(testName);
- } else {
- return runSingleTest(testName);
- }
-}
-/**
- * Runs a single test method of the given test class.
- * The test method is supplied after the '#' in the test name.
- */
-protected Object runSingleTest(String testName) throws Exception {
- int hash = testName.indexOf('#');
- String testID = testName.substring(0, hash);
- String testMethod = testName.substring(hash+1);
-
- Object testClass = findTestFor(testID);
- if (testClass == null) {
- return null;
- }
- if (!(testClass instanceof TestCase)) {
- System.out.println("Session tests must conform to the TestCase interface: " + testClass);
- return null;
- }
- TestCase testCase = (TestCase)testClass;
- testCase.setName(testMethod);
- run(testCase);
- return null;
-}
-}
\ No newline at end of file
diff --git a/tests/org.eclipse.core.tests.harness/src/org/eclipse/core/tests/harness/TestProgressMonitor.java b/tests/org.eclipse.core.tests.harness/src/org/eclipse/core/tests/harness/TestProgressMonitor.java
deleted file mode 100644
index cb98068..0000000
--- a/tests/org.eclipse.core.tests.harness/src/org/eclipse/core/tests/harness/TestProgressMonitor.java
+++ /dev/null
@@ -1,49 +0,0 @@
-package org.eclipse.core.tests.harness;
-
-/*
- * (c) Copyright IBM Corp. 2000, 2001.
- * All Rights Reserved.
- */
-
-import org.eclipse.core.runtime.IProgressMonitor;
-
-public abstract class TestProgressMonitor implements IProgressMonitor {
-/**
- * @see IProgressMonitor#beginTask
- */
-public void beginTask(String name, int totalWork) {
-}
-/**
- * @see IProgressMonitor#done
- */
-public void done() {
-}
-public void internalWorked(double work) {
-}
-/**
- * @see IProgressMonitor#isCanceled
- */
-public boolean isCanceled() {
- return false;
-}
-/**
- * @see IProgressMonitor#setCanceled
- */
-public void setCanceled(boolean b) {
-}
-/**
- * @see IProgressMonitor#setTaskName
- */
-public void setTaskName(String name) {
-}
-/**
- * @see IProgressMonitor#subTask
- */
-public void subTask(String name) {
-}
-/**
- * @see IProgressMonitor#worked
- */
-public void worked(int work) {
-}
-}
diff --git a/tests/org.eclipse.core.tests.harness/src/org/eclipse/core/tests/harness/WorkspaceSessionTest.java b/tests/org.eclipse.core.tests.harness/src/org/eclipse/core/tests/harness/WorkspaceSessionTest.java
deleted file mode 100644
index ba68e45..0000000
--- a/tests/org.eclipse.core.tests.harness/src/org/eclipse/core/tests/harness/WorkspaceSessionTest.java
+++ /dev/null
@@ -1,65 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2002 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
- *
- * Contributors:
- * IBM - Initial API and implementation
- ******************************************************************************/
-package org.eclipse.core.tests.harness;
-
-import java.io.*;
-import java.lang.reflect.InvocationTargetException;
-import java.lang.reflect.Method;
-import java.util.ArrayList;
-import java.util.Arrays;
-
-/**
- * Workspace session tests function as follows: Each test class looks like a typical JUnit test,
- * except the platform is shutdown and restarted after each test method. The steps for each
- * test method are:
- * - startup the platform
- * - run setUp
- * - run the test method
- * - run tearDown
- * - shutdown the platform
- *
- * Tests are run according to the natural order of their method names. This is the
- * partial ordering defined by the String.compareTo() operation. Each test method
- * must begin with the prefix "test", and have no parameters (thus overloading is
- * not supported).
- *
- * After all test methods in the class have been run, the platform location is deleted.
- * This way, each test class plays like a series of related operations on the same
- * workspace, with each operation running in a separate platform instance.
- *
- * The class SessionTestLauncher acts as a harness for running the tests. Each string
- * passed to the main method of SessionTestLauncher represents a separate fully-qualified
- * session test class name. There must be a corresponding test ID in some XML file that exactly
- * matches the fully qualified class name.
- */
-public class WorkspaceSessionTest extends EclipseWorkspaceTest {
- protected String testName;
-
-/**
- * Constructor for WorkspaceSessionTest.
- */
-public WorkspaceSessionTest() {
- super();
-}
-
-/**
- * Constructor for WorkspaceSessionTest.
- * @param name
- */
-public WorkspaceSessionTest(String name) {
- super(name);
-}
-
-protected void tearDown() throws Exception {
- // We should not run super.tearDown() on session tests.
- // If needed, we should call it explicitly.
-}
-}
\ No newline at end of file
diff --git a/tests/org.eclipse.core.tests.harness/test.xml b/tests/org.eclipse.core.tests.harness/test.xml
deleted file mode 100644
index ca979f1..0000000
--- a/tests/org.eclipse.core.tests.harness/test.xml
+++ /dev/null
@@ -1,128 +0,0 @@
-<?xml version="1.0"?>
-<project name="Core Resources Automated Tests" default="run" basedir=".">
-
- <!-- The property ${eclipse-home} should be passed into this script -->
- <!-- sets the properties eclipse-home, and library-file -->
- <property name="eclipse-home" value="${basedir}/../../"/>
- <property name="library-file" value="${eclipse-home}/plugins/org.eclipse.test/library.xml"/>
- <property name="location" value="${eclipse-home}/core_sniff_folder"/>
-
- <!-- This target holds all initialization code that needs to be done for -->
- <!-- all tests that are to be run. Initialization for individual tests -->
- <!-- should be done within the body of the suite target. -->
- <target name="init">
- <tstamp/>
- </target>
-
- <!-- This target holds code to cleanup the testing environment after the tests -->
- <!-- have been run. You can use this to delete temporary files that are created. -->
- <target name="cleanup">
- <delete dir="${location}" quiet="true"/>
- </target>
-
- <!-- This target runs the test suite. Any actions that need to happen after all -->
- <!-- the tests have been run should go here. -->
- <target name="run" depends="init,suite,cleanup">
- <ant target="collect" antfile="${library-file}" dir="${eclipse-home}">
- <property name="includes" value="org*.xml"/>
- <property name="output-file" value="org.eclipse.core.tests.xml"/>
- </ant>
- </target>
-
- <target name="ResourcesTests" depends="init,cleanup">
- <ant target="core-test" antfile="${library-file}" dir="${eclipse-home}">
- <property name="data-dir" value="${location}"/>
- <property name="plugin-name" value="org.eclipse.core.tests.resources"/>
- <property name="classname" value="org.eclipse.core.tests.resources.AutomatedTests"/>
- </ant>
- </target>
-
- <target name="PR_1G1N9GZ_SessionTests" depends="init,cleanup">
- <ant target="core-test" antfile="${library-file}" dir="${eclipse-home}">
- <property name="data-dir" value="${location}"/>
- <property name="plugin-name" value="org.eclipse.core.tests.resources"/>
- <property name="classname" value="org.eclipse.core.tests.resources.regression.PR_1G1N9GZ_1Test"/>
- </ant>
- <ant target="core-test" antfile="${library-file}" dir="${eclipse-home}">
- <property name="data-dir" value="${location}"/>
- <property name="plugin-name" value="org.eclipse.core.tests.resources"/>
- <property name="classname" value="org.eclipse.core.tests.resources.regression.PR_1G1N9GZ_2Test"/>
- </ant>
- </target>
-
- <target name="PR_1GALH44_SessionTests" depends="init,cleanup">
- <ant target="core-test" antfile="${library-file}" dir="${eclipse-home}">
- <property name="data-dir" value="${location}"/>
- <property name="plugin-name" value="org.eclipse.core.tests.resources"/>
- <property name="classname" value="org.eclipse.core.tests.resources.regression.PR_1GALH44_1Test"/>
- </ant>
- <ant target="core-test" antfile="${library-file}" dir="${eclipse-home}">
- <property name="data-dir" value="${location}"/>
- <property name="plugin-name" value="org.eclipse.core.tests.resources"/>
- <property name="classname" value="org.eclipse.core.tests.resources.regression.PR_1GALH44_2Test"/>
- </ant>
- <ant target="core-test" antfile="${library-file}" dir="${eclipse-home}">
- <property name="data-dir" value="${location}"/>
- <property name="plugin-name" value="org.eclipse.core.tests.resources"/>
- <property name="classname" value="org.eclipse.core.tests.resources.regression.PR_1GALH44_3Test"/>
- </ant>
- </target>
-
- <target name="Snapshot_SessionTests" depends="init,cleanup">
- <ant target="core-test" antfile="${library-file}" dir="${eclipse-home}">
- <property name="data-dir" value="${location}"/>
- <property name="plugin-name" value="org.eclipse.core.tests.resources"/>
- <property name="classname" value="org.eclipse.core.tests.resources.usecase.Snapshot1Test"/>
- </ant>
- <ant target="core-test" antfile="${library-file}" dir="${eclipse-home}">
- <property name="data-dir" value="${location}"/>
- <property name="plugin-name" value="org.eclipse.core.tests.resources"/>
- <property name="classname" value="org.eclipse.core.tests.resources.usecase.Snapshot2Test"/>
- </ant>
- <ant target="core-test" antfile="${library-file}" dir="${eclipse-home}">
- <property name="data-dir" value="${location}"/>
- <property name="plugin-name" value="org.eclipse.core.tests.resources"/>
- <property name="classname" value="org.eclipse.core.tests.resources.usecase.Snapshot3Test"/>
- </ant>
- <ant target="core-test" antfile="${library-file}" dir="${eclipse-home}">
- <property name="data-dir" value="${location}"/>
- <property name="plugin-name" value="org.eclipse.core.tests.resources"/>
- <property name="classname" value="org.eclipse.core.tests.resources.usecase.Snapshot4Test"/>
- </ant>
- <ant target="core-test" antfile="${library-file}" dir="${eclipse-home}">
- <property name="data-dir" value="${location}"/>
- <property name="plugin-name" value="org.eclipse.core.tests.resources"/>
- <property name="classname" value="org.eclipse.core.tests.resources.usecase.Snapshot5Test"/>
- </ant>
- </target>
-
- <target name="SaveManager_SessionTests" depends="init,cleanup">
- <ant target="core-test" antfile="${library-file}" dir="${eclipse-home}">
- <property name="data-dir" value="${location}"/>
- <property name="plugin-name" value="org.eclipse.core.tests.resources.saveparticipant"/>
- <property name="classname" value="org.eclipse.core.tests.resources.saveparticipant.SaveManager1Test"/>
- </ant>
- <ant target="core-test" antfile="${library-file}" dir="${eclipse-home}">
- <property name="data-dir" value="${location}"/>
- <property name="plugin-name" value="org.eclipse.core.tests.resources.saveparticipant"/>
- <property name="classname" value="org.eclipse.core.tests.resources.saveparticipant.SaveManager2Test"/>
- </ant>
- <ant target="core-test" antfile="${library-file}" dir="${eclipse-home}">
- <property name="data-dir" value="${location}"/>
- <property name="plugin-name" value="org.eclipse.core.tests.resources.saveparticipant"/>
- <property name="classname" value="org.eclipse.core.tests.resources.saveparticipant.SaveManager3Test"/>
- </ant>
- </target>
-
- <target name="RuntimeTests" depends="init,cleanup">
- <ant target="core-test" antfile="${library-file}" dir="${eclipse-home}">
- <property name="data-dir" value="${location}"/>
- <property name="plugin-name" value="org.eclipse.core.tests.runtime"/>
- <property name="classname" value="org.eclipse.core.tests.runtime.AutomatedTests"/>
- </ant>
- </target>
-
- <!-- This target defines the tests that need to be run. -->
- <target name="suite" depends="ResourcesTests,RuntimeTests"/>
- <!--target name="suite" depends="ResourcesTests,RuntimeTests,PR_1G1N9GZ_SessionTests,PR_1GALH44_SessionTests,Snapshot_SessionTests,SaveManager_SessionTests"/-->
- </project>
\ No newline at end of file
diff --git a/tests/org.eclipse.core.tests.runtime/src/org/eclipse/core/tests/internal/runtime/LogSerializationTest.java b/tests/org.eclipse.core.tests.runtime/src/org/eclipse/core/tests/internal/runtime/LogSerializationTest.java
index efbe052..7afa2aa 100644
--- a/tests/org.eclipse.core.tests.runtime/src/org/eclipse/core/tests/internal/runtime/LogSerializationTest.java
+++ b/tests/org.eclipse.core.tests.runtime/src/org/eclipse/core/tests/internal/runtime/LogSerializationTest.java
@@ -11,14 +11,10 @@
package org.eclipse.core.tests.internal.runtime;
import java.io.*;
-
import junit.framework.Test;
import junit.framework.TestSuite;
-import org.eclipse.core.internal.boot.DelegatingURLClassLoader;
-import org.eclipse.core.internal.boot.PlatformClassLoader;
import org.eclipse.core.internal.runtime.PlatformLogReader;
import org.eclipse.core.internal.runtime.PlatformLogWriter;
-import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.core.runtime.*;
import org.eclipse.core.tests.runtime.RuntimeTest;
@@ -34,6 +30,9 @@
}
public static Test suite() {
return new TestSuite(LogSerializationTest.class);
+// TestSuite suite = new TestSuite();
+// suite.addTest(new LogSerializationTest("testDeepMultiStatus"));
+// return suite;
}
protected void assertEquals(String msg, IStatus[] expected, IStatus[] actual) {
if (expected == null) {
@@ -66,10 +65,8 @@
assertNull(msg + " expected " + expected + " but got null", expected);
return;
}
- assertEquals(msg + " stack trace",
- encodeStackTrace(expected),
- encodeStackTrace(actual));
- assertEquals(msg + " message", expected.getMessage(), actual.getMessage());
+ assertEquals(msg + " stack trace", encodeStackTrace(expected),encodeStackTrace(actual));
+ assertEquals(msg + " message", expected.getMessage(), actual.getMessage());
}
protected String encodeStackTrace(Throwable t) {
StringWriter sWriter = new StringWriter();
@@ -125,22 +122,16 @@
}
protected void setUp() throws Exception {
super.setUp();
- //XXX spoof up the classloader so we can load XML classes. See bug 5801
- DelegatingURLClassLoader xmlClassLoader = (DelegatingURLClassLoader)Platform.getPluginRegistry().getPluginDescriptor("org.apache.xerces").getPluginClassLoader();
- PlatformClassLoader.getDefault().setImports(new DelegatingURLClassLoader[] { xmlClassLoader });
-
//setup the log file
if (logFile == null) {
File parent = Platform.getLocation().toFile();
String logName = Long.toString(System.currentTimeMillis()) + ".log";
logFile = new File(parent, logName);
}
-
}
protected void tearDown() throws Exception {
super.tearDown();
logFile.delete();
- PlatformClassLoader.getDefault().setImports(null);
}
public void testDeepMultiStatus() {
MultiStatus multi = new MultiStatus("id", 1, getInterestingMultiStatuses(), "ok", null);
@@ -184,6 +175,8 @@
writeLog(new IStatus[] {status});
}
protected void writeLog(IStatus[] statuses) {
+ if (logFile.exists())
+ logFile.delete();
PlatformLogWriter writer = new PlatformLogWriter(logFile);
for (int i = 0; i < statuses.length; i++) {
writer.logging(statuses[i], "org.eclipse.core.tests.runtime");