diff options
5 files changed, 54 insertions, 1 deletions
diff --git a/bundles/org.eclipse.osgi/defaultAdaptor/src/org/eclipse/osgi/framework/internal/defaultadaptor/BundleEntry.java b/bundles/org.eclipse.osgi/defaultAdaptor/src/org/eclipse/osgi/framework/internal/defaultadaptor/BundleEntry.java index 74121aa8c..8a7099127 100644 --- a/bundles/org.eclipse.osgi/defaultAdaptor/src/org/eclipse/osgi/framework/internal/defaultadaptor/BundleEntry.java +++ b/bundles/org.eclipse.osgi/defaultAdaptor/src/org/eclipse/osgi/framework/internal/defaultadaptor/BundleEntry.java @@ -50,6 +50,8 @@ public abstract class BundleEntry { public abstract URL getLocalURL(); + public abstract URL getFileURL(); + /** * Return the name of this BundleEntry by calling getName(). * @@ -124,9 +126,17 @@ public abstract class BundleEntry { public URL getLocalURL() { try { + return new URL("jar:file:" + bundleFile.bundlefile.getAbsolutePath() + "!/" + zipEntry.getName()); + } catch (MalformedURLException e) { + //This can not happen. + return null; + } + } + + public URL getFileURL() { + try { File file = bundleFile.getFile(zipEntry.getName()); return file.toURL(); - //return new URL("jar:file:" + bundleFile.getAbsolutePath() + "!/" + zipEntry.getName()); } catch (MalformedURLException e) { //This can not happen. return null; @@ -190,6 +200,10 @@ public abstract class BundleEntry { } public URL getLocalURL() { + return getFileURL(); + } + + public URL getFileURL() { try { return file.toURL(); } catch (MalformedURLException e) { @@ -227,6 +241,10 @@ public abstract class BundleEntry { } public URL getLocalURL() { + return getFileURL(); + } + + public URL getFileURL() { try { return new URL("jar:file:" + file.getAbsolutePath() + "!/" + name); } catch (MalformedURLException e) { diff --git a/bundles/org.eclipse.osgi/defaultAdaptor/src/org/eclipse/osgi/framework/internal/defaultadaptor/BundleURLConnection.java b/bundles/org.eclipse.osgi/defaultAdaptor/src/org/eclipse/osgi/framework/internal/defaultadaptor/BundleURLConnection.java index 6b114f351..5f9fd50de 100644 --- a/bundles/org.eclipse.osgi/defaultAdaptor/src/org/eclipse/osgi/framework/internal/defaultadaptor/BundleURLConnection.java +++ b/bundles/org.eclipse.osgi/defaultAdaptor/src/org/eclipse/osgi/framework/internal/defaultadaptor/BundleURLConnection.java @@ -201,4 +201,8 @@ public class BundleURLConnection extends URLConnection { public URL getLocalURL() { return bundleEntry.getLocalURL(); } + + public URL getFileURL() { + return bundleEntry.getFileURL(); + } } diff --git a/bundles/org.eclipse.osgi/eclipseAdaptor/src/org/eclipse/core/runtime/adaptor/URLConverterImpl.java b/bundles/org.eclipse.osgi/eclipseAdaptor/src/org/eclipse/core/runtime/adaptor/URLConverterImpl.java index f89b5b999..47971905b 100644 --- a/bundles/org.eclipse.osgi/eclipseAdaptor/src/org/eclipse/core/runtime/adaptor/URLConverterImpl.java +++ b/bundles/org.eclipse.osgi/eclipseAdaptor/src/org/eclipse/core/runtime/adaptor/URLConverterImpl.java @@ -22,9 +22,20 @@ import org.eclipse.osgi.service.urlconversion.URLConverter; * URLs to be converted to native file URLs on the local file system. */ public class URLConverterImpl implements URLConverter{ + public URL convertToFileURL(URL url) throws IOException{ URLConnection connection = url.openConnection(); if (connection instanceof BundleURLConnection) { + return ((BundleURLConnection)connection).getFileURL(); + } + else { + return url; + } + } + + public URL convertToLocalURL(URL url) throws IOException { + URLConnection connection = url.openConnection(); + if (connection instanceof BundleURLConnection) { return ((BundleURLConnection)connection).getLocalURL(); } else { diff --git a/bundles/org.eclipse.osgi/eclipseAdaptor/src/org/eclipse/osgi/service/urlconversion/URLConverter.java b/bundles/org.eclipse.osgi/eclipseAdaptor/src/org/eclipse/osgi/service/urlconversion/URLConverter.java index 6ed0db8e8..510d777c3 100644 --- a/bundles/org.eclipse.osgi/eclipseAdaptor/src/org/eclipse/osgi/service/urlconversion/URLConverter.java +++ b/bundles/org.eclipse.osgi/eclipseAdaptor/src/org/eclipse/osgi/service/urlconversion/URLConverter.java @@ -28,4 +28,14 @@ public interface URLConverter { * @throws IOException if an error occurs during the conversion. */ public URL convertToFileURL(URL url) throws IOException; + + /** + * Converts a URL that uses a protocol of bundleentry or bundleresource into + * a URL that uses a local java protocol (file, jar etc). + * @param url The bundleentry or bundleresource URL to convert into a local URL. + * @return The converted file URL or the original URL passed in if it is not + * a bundleentry or bundleresource URL. + * @throws IOException if an error occurs during the conversion. + */ + public URL convertToLocalURL(URL url) throws IOException; } diff --git a/bundles/org.eclipse.osgi/supplement/src/org/eclipse/osgi/service/urlconversion/URLConverter.java b/bundles/org.eclipse.osgi/supplement/src/org/eclipse/osgi/service/urlconversion/URLConverter.java index 6ed0db8e8..510d777c3 100644 --- a/bundles/org.eclipse.osgi/supplement/src/org/eclipse/osgi/service/urlconversion/URLConverter.java +++ b/bundles/org.eclipse.osgi/supplement/src/org/eclipse/osgi/service/urlconversion/URLConverter.java @@ -28,4 +28,14 @@ public interface URLConverter { * @throws IOException if an error occurs during the conversion. */ public URL convertToFileURL(URL url) throws IOException; + + /** + * Converts a URL that uses a protocol of bundleentry or bundleresource into + * a URL that uses a local java protocol (file, jar etc). + * @param url The bundleentry or bundleresource URL to convert into a local URL. + * @return The converted file URL or the original URL passed in if it is not + * a bundleentry or bundleresource URL. + * @throws IOException if an error occurs during the conversion. + */ + public URL convertToLocalURL(URL url) throws IOException; } |