Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'org.eclipse.help.appserver')
-rw-r--r--org.eclipse.help.appserver/src/org/eclipse/help/internal/appserver/DevClassPathHelper.java96
-rw-r--r--org.eclipse.help.appserver/src/org/eclipse/help/internal/appserver/PluginClassLoaderWrapper.java22
2 files changed, 106 insertions, 12 deletions
diff --git a/org.eclipse.help.appserver/src/org/eclipse/help/internal/appserver/DevClassPathHelper.java b/org.eclipse.help.appserver/src/org/eclipse/help/internal/appserver/DevClassPathHelper.java
new file mode 100644
index 000000000..be61d99a7
--- /dev/null
+++ b/org.eclipse.help.appserver/src/org/eclipse/help/internal/appserver/DevClassPathHelper.java
@@ -0,0 +1,96 @@
+/*******************************************************************************
+ * Copyright (c) 2004 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Common Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/cpl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.help.internal.appserver;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.net.MalformedURLException;
+import java.net.URL;
+import java.util.*;
+
+/**
+ * Class copied from org.eclipse.osgi.framework.internal.defaultadaptor
+ */
+public class DevClassPathHelper {
+ static protected boolean inDevelopmentMode = false;
+ static protected String[] devDefaultClasspath;
+ static protected Properties devProperties = null;
+
+ static {
+ // Check the osgi.dev property to see if dev classpath entries have been defined.
+ String osgiDev = System.getProperty("osgi.dev");
+ if (osgiDev != null) {
+ try {
+ inDevelopmentMode = true;
+ URL location = new URL(osgiDev);
+ devProperties = load(location);
+ if (devProperties != null)
+ devDefaultClasspath = getArrayFromList(devProperties.getProperty("*"));
+ } catch (MalformedURLException e) {
+ devDefaultClasspath = getArrayFromList(osgiDev);
+ }
+ }
+ }
+
+ public static String[] getDevClassPath(String id) {
+ String[] result = null;
+ if (id != null && devProperties != null) {
+ String entry = devProperties.getProperty(id);
+ if (entry != null)
+ result = getArrayFromList(entry);
+ }
+ if (result == null)
+ result = devDefaultClasspath;
+ return result;
+ }
+
+ /**
+ * Returns the result of converting a list of comma-separated tokens into an array
+ *
+ * @return the array of string tokens
+ * @param prop the initial comma-separated string
+ */
+ public static String[] getArrayFromList(String prop) {
+ if (prop == null || prop.trim().equals("")) //$NON-NLS-1$
+ return new String[0];
+ Vector list = new Vector();
+ StringTokenizer tokens = new StringTokenizer(prop, ","); //$NON-NLS-1$
+ while (tokens.hasMoreTokens()) {
+ String token = tokens.nextToken().trim();
+ if (!token.equals("")) //$NON-NLS-1$
+ list.addElement(token);
+ }
+ return list.isEmpty() ? new String[0] : (String[]) list.toArray(new String[list.size()]);
+ }
+
+ public static boolean inDevelopmentMode() {
+ return inDevelopmentMode;
+ }
+
+ /*
+ * Load the given properties file
+ */
+ private static Properties load(URL url) {
+ Properties props = new Properties();
+ try {
+ InputStream is = null;
+ try {
+ is = url.openStream();
+ props.load(is);
+ } finally {
+ is.close();
+ }
+ } catch (IOException e) {
+ // TODO consider logging here
+ }
+ return props;
+ }
+} \ No newline at end of file
diff --git a/org.eclipse.help.appserver/src/org/eclipse/help/internal/appserver/PluginClassLoaderWrapper.java b/org.eclipse.help.appserver/src/org/eclipse/help/internal/appserver/PluginClassLoaderWrapper.java
index 542dfea13..1f64260d2 100644
--- a/org.eclipse.help.appserver/src/org/eclipse/help/internal/appserver/PluginClassLoaderWrapper.java
+++ b/org.eclipse.help.appserver/src/org/eclipse/help/internal/appserver/PluginClassLoaderWrapper.java
@@ -61,7 +61,7 @@ public class PluginClassLoaderWrapper extends URLClassLoader {
if (paths != null) {
for (int i = 0; i < paths.length; i++) {
String path = paths[i].getValue();
- URL url = Platform.find(b, new Path(path));
+ URL url = b.getEntry(path);
if (url != null)
try {
urls.add(Platform.asLocalURL(url));
@@ -70,17 +70,15 @@ public class PluginClassLoaderWrapper extends URLClassLoader {
}
}
// dev classpath
- String prop = System.getProperty("osgi.dev");
- if (prop != null) {
- String[] devpaths = prop.split(",");
- for (int i = 0; i < devpaths.length; i++) {
- URL url = Platform.find(b, new Path(devpaths[i]));
- if (url != null)
- try {
- urls.add(Platform.asLocalURL(url));
- } catch (IOException ioe) {
- }
- }
+ String[] devpaths = DevClassPathHelper
+ .getDevClassPath(pluginId);
+ for (int i = 0; i < devpaths.length; i++) {
+ URL url = b.getEntry("/");
+ if (url != null)
+ try {
+ urls.add(Platform.asLocalURL(url));
+ } catch (IOException ioe) {
+ }
}
} catch (BundleException e) {
}

Back to the top