handle version numbers in dirs/add resource url
diff --git a/bundles/org.eclipse.core.runtime/src/org/eclipse/core/internal/plugins/PluginClassLoader.java b/bundles/org.eclipse.core.runtime/src/org/eclipse/core/internal/plugins/PluginClassLoader.java
index 581526c..ac309fb 100644
--- a/bundles/org.eclipse.core.runtime/src/org/eclipse/core/internal/plugins/PluginClassLoader.java
+++ b/bundles/org.eclipse.core.runtime/src/org/eclipse/core/internal/plugins/PluginClassLoader.java
@@ -26,11 +26,11 @@
 	private PluginDescriptor descriptor;

 	private boolean pluginActivationInProgress = false;

 	private boolean loadInProgress = false;

-public PluginClassLoader(URL[] codePath, URLContentFilter[] codeFilters, URL[] resourcePath, URLContentFilter[] resourceFilters, PlatformClassLoader parent, PluginDescriptor descriptor) {

-	// create a class loader with the given classpath and filters.  Also, set the parent

-	// to be the parent of the platform class loader.  This allows us to decouple standard

+public PluginClassLoader(URL[] codePath, URLContentFilter[] codeFilters, URL[] resourcePath, URLContentFilter[] resourceFilters, ClassLoader parent, PluginDescriptor descriptor) {

+	// create a class loader with the given classpath and filters.  Also, the parent

+	// should be the parent of the platform class loader.  This allows us to decouple standard

 	// parent loading from platform loading.

-	super(codePath, codeFilters, resourcePath, resourceFilters, parent.getParent());

+	super(codePath, codeFilters, resourcePath, resourceFilters, parent);

 	this.descriptor = descriptor;

 	base = descriptor.getInstallURL();

 	debugConstruction(); // must have initialized loader

diff --git a/bundles/org.eclipse.core.runtime/src/org/eclipse/core/internal/plugins/PluginDescriptor.java b/bundles/org.eclipse.core.runtime/src/org/eclipse/core/internal/plugins/PluginDescriptor.java
index 28a2a68..e256eef 100644
--- a/bundles/org.eclipse.core.runtime/src/org/eclipse/core/internal/plugins/PluginDescriptor.java
+++ b/bundles/org.eclipse.core.runtime/src/org/eclipse/core/internal/plugins/PluginDescriptor.java
@@ -261,7 +261,9 @@
 	URLContentFilter[] codeFilters = (URLContentFilter[]) path[1];

 	URL[] resourcePath = (URL[]) path[2];

 	URLContentFilter[] resourceFilters = (URLContentFilter[]) path[3];

-	loader = new PluginClassLoader(codePath, codeFilters, resourcePath, resourceFilters, PlatformClassLoader.getDefault(), this);

+	// Create the classloader.  The parent should be the parent of the platform class loader.  

+	// This allows us to decouple standard parent loading from platform loading.

+	loader = new PluginClassLoader(codePath, codeFilters, resourcePath, resourceFilters, PlatformClassLoader.getDefault().getParent(), this);

 	loader.initializeImportedLoaders();

 	// Note: need to be able to give out a loader reference before

 	// its prereqs are initialized. Otherwise loops in prereq

diff --git a/bundles/org.eclipse.core.runtime/src/org/eclipse/core/internal/runtime/InternalPlatform.java b/bundles/org.eclipse.core.runtime/src/org/eclipse/core/internal/runtime/InternalPlatform.java
index 0acb6ee..6ad2e10 100644
--- a/bundles/org.eclipse.core.runtime/src/org/eclipse/core/internal/runtime/InternalPlatform.java
+++ b/bundles/org.eclipse.core.runtime/src/org/eclipse/core/internal/runtime/InternalPlatform.java
@@ -43,6 +43,7 @@
 

 	// default plugin data

 	private static final String PI_XML = "org.apache.xerces";

+	private static final String PLUGINSDIR = "plugins/";

 	private static final String XML_VERSION = "1.2.1";

 	private static final String XML_JAR = "xerces.jar";

 	private static final String XML_LOCATION = "plugins/" + PI_XML + "/";

@@ -139,6 +140,30 @@
 private static void assertInitialized() {

 	Assert.isTrue(initialized, Policy.bind("appNotInit", new String[] {}));

 }

+private static String findPlugin(LaunchInfo.VersionedIdentifier[] list, String name, String version) {

+	LaunchInfo.VersionedIdentifier result = null;

+	for (int i = 0; i < list.length; i++) {

+		if (list[i].getIdentifier().equals(name)) {

+			if (version != null)

+				// we are looking for a particular version, compare.  If the current element 

+				// has no version, save it for later in case we don't fine what we are looking for.

+				if (list[i].getVersion().equals(version))

+					return list[i].toString();

+				else

+					if (result == null && list[i].getVersion().length() == 0)

+						result = list[i];

+			else 

+				// remember the element with the latest version number.

+				if (result == null)

+					result = list[i];

+				else 

+					if (result.getVersion().compareTo(list[i].getVersion()) == -1)

+						result = list[i];

+		}

+	}

+	return result == null ? null : result.toString();

+}

+

 /**

  * Creates and remembers a spoofed up class loader which loads the

  * classes from a predefined XML plugin.

@@ -151,11 +176,20 @@
 	descriptor.setEnabled(true);

 	descriptor.setId(PI_XML);

 	descriptor.setVersion(XML_VERSION);

+

 	try {

-		descriptor.setLocation(new URL(BootLoader.getInstallURL(), XML_LOCATION).toExternalForm());

+		LaunchInfo launch = LaunchInfo.getCurrent();

+		String plugin = findPlugin(launch.getPlugins(), PI_XML, XML_VERSION);

+		URL url = null;

+		if (plugin == null)

+			url = new URL(BootLoader.getInstallURL(), XML_LOCATION);

+		else

+			url = new URL(BootLoader.getInstallURL(), PLUGINSDIR + plugin + "/");

+		descriptor.setLocation(url.toExternalForm());

 	} catch (MalformedURLException e) {

 		// ISSUE: What to do when this fails.  It's pretty serious

 	}

+

 	LibraryModel lib = factory.createLibrary();

 	lib.setName(XML_JAR);

 	lib.setExports(new String[] { "*" });

diff --git a/bundles/org.eclipse.core.runtime/src/org/eclipse/core/internal/runtime/PlatformURLPluginHandlerFactory.java b/bundles/org.eclipse.core.runtime/src/org/eclipse/core/internal/runtime/PlatformURLPluginHandlerFactory.java
index bf823ac..119d216 100644
--- a/bundles/org.eclipse.core.runtime/src/org/eclipse/core/internal/runtime/PlatformURLPluginHandlerFactory.java
+++ b/bundles/org.eclipse.core.runtime/src/org/eclipse/core/internal/runtime/PlatformURLPluginHandlerFactory.java
@@ -46,5 +46,6 @@
 	// initialize plugin and fragment connection support

 	PlatformURLPluginConnection.startup();

 	PlatformURLFragmentConnection.startup();

+	PlatformURLResourceConnection.startup(Platform.getLocation());

 }

 }

diff --git a/bundles/org.eclipse.core.runtime/src/org/eclipse/core/internal/runtime/PlatformURLResourceConnection.java b/bundles/org.eclipse.core.runtime/src/org/eclipse/core/internal/runtime/PlatformURLResourceConnection.java
new file mode 100644
index 0000000..575bb8b
--- /dev/null
+++ b/bundles/org.eclipse.core.runtime/src/org/eclipse/core/internal/runtime/PlatformURLResourceConnection.java
@@ -0,0 +1,60 @@
+package org.eclipse.core.internal.runtime;

+

+/*

+ * Licensed Materials - Property of IBM,

+ * WebSphere Studio Workbench

+ * (c) Copyright IBM Corp 2000

+ */

+

+/**

+ * Platform URL support

+ * platform:/resource/<path>/<resource>  maps to resource in current workspace

+ */

+

+import java.net.*;

+import java.io.*;

+import java.util.*;

+import org.eclipse.core.internal.boot.PlatformURLConnection;

+import org.eclipse.core.internal.boot.PlatformURLHandler;

+import org.eclipse.core.runtime.Platform;

+import org.eclipse.core.runtime.IPath;

+

+public class PlatformURLResourceConnection extends PlatformURLConnection {

+

+	// resource/ protocol

+	public static final String RESOURCE = "resource";

+	public static final String RESOURCE_URL_STRING = PlatformURLHandler.PROTOCOL + PlatformURLHandler.PROTOCOL_SEPARATOR + "/" + RESOURCE + "/";

+	private static URL rootURL;

+

+public PlatformURLResourceConnection(URL url) {

+	super(url);

+}

+protected boolean allowCaching() {

+	return false; // don't cache, workspace is local

+}

+protected URL resolve() throws IOException {

+	String spec = url.getFile().trim();

+	if (spec.startsWith("/"))

+		spec = spec.substring(1);

+	if (!spec.startsWith(RESOURCE + "/")) 

+		throw new IOException("Unsupported protocol variation " + url.toString());

+	return spec.length() == RESOURCE.length() + 1 ? rootURL : new URL(rootURL, spec.substring(RESOURCE.length() + 1));

+}

+

+/**

+ * This method is called during resource plugin startup() initialization.

+ * @param url URL to the root of the current workspace.

+ */

+public static void startup(IPath root) {

+	// register connection type for platform:/resource/ handling

+	if (rootURL != null) 

+		return;

+	try {

+		rootURL = new URL("file:" + root.toString());

+	} catch (MalformedURLException e) {

+		// should never happen but if it does, the resource URL cannot be supported.

+		return;

+	}

+	PlatformURLHandler.register(RESOURCE, PlatformURLResourceConnection.class);

+}

+}
\ No newline at end of file