diff options
Diffstat (limited to 'src/org')
4 files changed, 224 insertions, 0 deletions
diff --git a/src/org/eclipse/jdt/internal/jarinjarloader/JarRsrcLoader.java b/src/org/eclipse/jdt/internal/jarinjarloader/JarRsrcLoader.java new file mode 100644 index 0000000..9cddcf9 --- /dev/null +++ b/src/org/eclipse/jdt/internal/jarinjarloader/JarRsrcLoader.java @@ -0,0 +1,104 @@ +/* */ package org.eclipse.jdt.internal.jarinjarloader; +/* */ +/* */ import java.io.IOException; +/* */ import java.io.InputStream; +/* */ import java.io.PrintStream; +/* */ import java.lang.reflect.InvocationTargetException; +/* */ import java.lang.reflect.Method; +/* */ import java.net.URL; +/* */ import java.net.URLClassLoader; +/* */ import java.util.ArrayList; +/* */ import java.util.Enumeration; +/* */ import java.util.List; +/* */ import java.util.jar.Attributes; +/* */ import java.util.jar.Manifest; +/* */ +/* */ public class JarRsrcLoader +/* */ { +/* */ public static void main(String[] args) +/* */ throws ClassNotFoundException, IllegalArgumentException, IllegalAccessException, InvocationTargetException, SecurityException, NoSuchMethodException, IOException +/* */ { +/* 41 */ ManifestInfo mi = getManifestInfo(); +/* 42 */ ClassLoader cl = Thread.currentThread().getContextClassLoader(); +/* 43 */ URL.setURLStreamHandlerFactory(new RsrcURLStreamHandlerFactory(cl)); +/* 44 */ URL[] rsrcUrls = new URL[mi.rsrcClassPath.length]; +/* 45 */ for (int i = 0; i < mi.rsrcClassPath.length; i++) { +/* 46 */ String rsrcPath = mi.rsrcClassPath[i]; +/* 47 */ if (rsrcPath.endsWith("/")) +/* 48 */ rsrcUrls[i] = new URL("rsrc:" + rsrcPath); +/* */ else +/* 50 */ rsrcUrls[i] = new URL("jar:rsrc:" + rsrcPath + "!/"); +/* */ } +/* 52 */ ClassLoader jceClassLoader = new URLClassLoader(rsrcUrls, null); +/* 53 */ Thread.currentThread().setContextClassLoader(jceClassLoader); +/* 54 */ Class c = Class.forName(mi.rsrcMainClass, true, jceClassLoader); +/* 55 */ Method main = c.getMethod("main", new Class[] { args.getClass() }); +/* 56 */ main.invoke(null, new Object[] { args }); +/* */ } +/* */ +/* */ private static ManifestInfo getManifestInfo() throws IOException +/* */ { +/* 61 */ Enumeration resEnum = Thread.currentThread().getContextClassLoader().getResources("META-INF/MANIFEST.MF"); +/* 62 */ while (resEnum.hasMoreElements()) { +/* */ try { +/* 64 */ URL url = (URL)resEnum.nextElement(); +/* 65 */ InputStream is = url.openStream(); +/* 66 */ if (is != null) { +/* 67 */ ManifestInfo result = new ManifestInfo(null); +/* 68 */ Manifest manifest = new Manifest(is); +/* 69 */ Attributes mainAttribs = manifest.getMainAttributes(); +/* 70 */ result.rsrcMainClass = mainAttribs.getValue("Rsrc-Main-Class"); +/* 71 */ String rsrcCP = mainAttribs.getValue("Rsrc-Class-Path"); +/* 72 */ if (rsrcCP == null) +/* 73 */ rsrcCP = ""; +/* 74 */ result.rsrcClassPath = splitSpaces(rsrcCP); +/* 75 */ if ((result.rsrcMainClass != null) && (!result.rsrcMainClass.trim().equals(""))) +/* 76 */ return result; +/* */ } +/* */ } +/* */ catch (Exception localException) +/* */ { +/* */ } +/* */ } +/* 83 */ System.err.println("Missing attributes for RsrcLoader in Manifest (Rsrc-Main-Class, Rsrc-Class-Path)"); +/* 84 */ return null; +/* */ } +/* */ +/* */ private static String[] splitSpaces(String line) +/* */ { +/* 95 */ if (line == null) +/* 96 */ return null; +/* 97 */ List result = new ArrayList(); +/* 98 */ int firstPos = 0; +/* 99 */ while (firstPos < line.length()) { +/* 100 */ int lastPos = line.indexOf(' ', firstPos); +/* 101 */ if (lastPos == -1) +/* 102 */ lastPos = line.length(); +/* 103 */ if (lastPos > firstPos) { +/* 104 */ result.add(line.substring(firstPos, lastPos)); +/* */ } +/* 106 */ firstPos = lastPos + 1; +/* */ } +/* 108 */ return (String[])result.toArray(new String[result.size()]); +/* */ } +/* */ +/* */ private static class ManifestInfo +/* */ { +/* */ String rsrcMainClass; +/* */ String[] rsrcClassPath; +/* */ +/* */ private ManifestInfo() +/* */ { +/* */ } +/* */ +/* */ ManifestInfo(ManifestInfo paramManifestInfo) +/* */ { +/* 35 */ this(); +/* */ } +/* */ } +/* */ } + +/* Location: Modulus.jar + * Qualified Name: org.eclipse.jdt.internal.jarinjarloader.JarRsrcLoader + * JD-Core Version: 0.6.2 + */
\ No newline at end of file diff --git a/src/org/eclipse/jdt/internal/jarinjarloader/RsrcURLConnection.java b/src/org/eclipse/jdt/internal/jarinjarloader/RsrcURLConnection.java new file mode 100644 index 0000000..9cc10e7 --- /dev/null +++ b/src/org/eclipse/jdt/internal/jarinjarloader/RsrcURLConnection.java @@ -0,0 +1,36 @@ +/* */ package org.eclipse.jdt.internal.jarinjarloader; +/* */ +/* */ import java.io.IOException; +/* */ import java.io.InputStream; +/* */ import java.net.MalformedURLException; +/* */ import java.net.URL; +/* */ import java.net.URLConnection; +/* */ import java.net.URLDecoder; +/* */ +/* */ public class RsrcURLConnection extends URLConnection +/* */ { +/* */ private ClassLoader classLoader; +/* */ +/* */ public RsrcURLConnection(URL url, ClassLoader classLoader) +/* */ { +/* 34 */ super(url); +/* 35 */ this.classLoader = classLoader; +/* */ } +/* */ +/* */ public void connect() throws IOException { +/* */ } +/* */ +/* */ public InputStream getInputStream() throws IOException { +/* 42 */ String file = URLDecoder.decode(this.url.getFile(), "UTF-8"); +/* 43 */ InputStream result = this.classLoader.getResourceAsStream(file); +/* 44 */ if (result == null) { +/* 45 */ throw new MalformedURLException("Could not open InputStream for URL '" + this.url + "'"); +/* */ } +/* 47 */ return result; +/* */ } +/* */ } + +/* Location: Modulus.jar + * Qualified Name: org.eclipse.jdt.internal.jarinjarloader.RsrcURLConnection + * JD-Core Version: 0.6.2 + */
\ No newline at end of file diff --git a/src/org/eclipse/jdt/internal/jarinjarloader/RsrcURLStreamHandler.java b/src/org/eclipse/jdt/internal/jarinjarloader/RsrcURLStreamHandler.java new file mode 100644 index 0000000..0744c28 --- /dev/null +++ b/src/org/eclipse/jdt/internal/jarinjarloader/RsrcURLStreamHandler.java @@ -0,0 +1,50 @@ +/* */ package org.eclipse.jdt.internal.jarinjarloader; +/* */ +/* */ import java.io.IOException; +/* */ import java.net.URL; +/* */ import java.net.URLConnection; +/* */ import java.net.URLStreamHandler; +/* */ +/* */ public class RsrcURLStreamHandler extends URLStreamHandler +/* */ { +/* */ private ClassLoader classLoader; +/* */ +/* */ public RsrcURLStreamHandler(ClassLoader classLoader) +/* */ { +/* 33 */ this.classLoader = classLoader; +/* */ } +/* */ +/* */ protected URLConnection openConnection(URL u) throws IOException { +/* 37 */ return new RsrcURLConnection(u, this.classLoader); +/* */ } +/* */ +/* */ protected void parseURL(URL url, String spec, int start, int limit) +/* */ { +/* */ String file; +/* */ String file; +/* 42 */ if (spec.startsWith("rsrc:")) { +/* 43 */ file = spec.substring(5); +/* */ } +/* */ else +/* */ { +/* */ String file; +/* 44 */ if (url.getFile().equals("./")) { +/* 45 */ file = spec; +/* */ } +/* */ else +/* */ { +/* */ String file; +/* 46 */ if (url.getFile().endsWith("/")) +/* 47 */ file = url.getFile() + spec; +/* */ else +/* 49 */ file = spec; +/* */ } +/* */ } +/* 50 */ setURL(url, "rsrc", "", -1, null, null, file, null, null); +/* */ } +/* */ } + +/* Location: Modulus.jar + * Qualified Name: org.eclipse.jdt.internal.jarinjarloader.RsrcURLStreamHandler + * JD-Core Version: 0.6.2 + */
\ No newline at end of file diff --git a/src/org/eclipse/jdt/internal/jarinjarloader/RsrcURLStreamHandlerFactory.java b/src/org/eclipse/jdt/internal/jarinjarloader/RsrcURLStreamHandlerFactory.java new file mode 100644 index 0000000..8d0adce --- /dev/null +++ b/src/org/eclipse/jdt/internal/jarinjarloader/RsrcURLStreamHandlerFactory.java @@ -0,0 +1,34 @@ +/* */ package org.eclipse.jdt.internal.jarinjarloader; +/* */ +/* */ import java.net.URLStreamHandler; +/* */ import java.net.URLStreamHandlerFactory; +/* */ +/* */ public class RsrcURLStreamHandlerFactory +/* */ implements URLStreamHandlerFactory +/* */ { +/* */ private ClassLoader classLoader; +/* */ private URLStreamHandlerFactory chainFac; +/* */ +/* */ public RsrcURLStreamHandlerFactory(ClassLoader cl) +/* */ { +/* 30 */ this.classLoader = cl; +/* */ } +/* */ +/* */ public URLStreamHandler createURLStreamHandler(String protocol) { +/* 34 */ if ("rsrc".equals(protocol)) +/* 35 */ return new RsrcURLStreamHandler(this.classLoader); +/* 36 */ if (this.chainFac != null) +/* 37 */ return this.chainFac.createURLStreamHandler(protocol); +/* 38 */ return null; +/* */ } +/* */ +/* */ public void setURLStreamHandlerFactory(URLStreamHandlerFactory fac) +/* */ { +/* 50 */ this.chainFac = fac; +/* */ } +/* */ } + +/* Location: Modulus.jar + * Qualified Name: org.eclipse.jdt.internal.jarinjarloader.RsrcURLStreamHandlerFactory + * JD-Core Version: 0.6.2 + */
\ No newline at end of file |