# HG changeset patch # User Jaroslav Tulach # Date 1399290545 -7200 # Node ID 45c50b9c7dc4e1097efa4735611bb626d058d46a # Parent 9afa6856382c54d33665a5693987c27c05be0d6b When querying manifests, return them as array of bytes diff -r 9afa6856382c -r 45c50b9c7dc4 launcher/fx/src/main/java/org/apidesign/bck2brwsr/launcher/BaseHTTPLauncher.java --- a/launcher/fx/src/main/java/org/apidesign/bck2brwsr/launcher/BaseHTTPLauncher.java Mon May 05 12:58:10 2014 +0200 +++ b/launcher/fx/src/main/java/org/apidesign/bck2brwsr/launcher/BaseHTTPLauncher.java Mon May 05 13:49:05 2014 +0200 @@ -35,6 +35,7 @@ import java.util.ArrayList; import java.util.Arrays; import java.util.Enumeration; +import java.util.HashSet; import java.util.LinkedHashSet; import java.util.List; import java.util.Set; @@ -579,8 +580,12 @@ } final class Res { - String compileJar(JarFile jar) throws IOException { - return BaseHTTPLauncher.this.compileJar(jar); + private final Set ignore = new HashSet(); + + String compileJar(JarFile jar, URL jarURL) throws IOException { + String ret = BaseHTTPLauncher.this.compileJar(jar); + ignore.add(jarURL); + return ret; } String compileFromClassPath(URL f) throws IOException { return BaseHTTPLauncher.this.compileFromClassPath(f, this); @@ -618,6 +623,12 @@ // module is not compiled with target 1.6, currently continue; } + if (now.getProtocol().equals("jar")) { + JarURLConnection juc = (JarURLConnection) now.openConnection(); + if (ignore.contains(juc.getJarFileURL())) { + continue; + } + } if (--skip < 0) { return now; } @@ -730,11 +741,11 @@ String skip = request.getParameter("skip"); int skipCnt = skip == null ? 0 : Integer.parseInt(skip); URL url = loader.get(res, skipCnt); - try { + if (url != null && !res.equals("META-INF/MANIFEST.MF")) try { response.setCharacterEncoding("UTF-8"); if (url.getProtocol().equals("jar")) { JarURLConnection juc = (JarURLConnection) url.openConnection(); - String s = loader.compileJar(juc.getJarFile()); + String s = loader.compileJar(juc.getJarFile(), juc.getJarFileURL()); if (s != null) { Writer w = response.getWriter(); w.append(s); @@ -753,18 +764,13 @@ } } catch (IOException ex) { LOG.log(Level.SEVERE, "Cannot handle " + res, ex); - throw ex; } - Exception ex = new Exception("Won't server bytes of " + url); - /* - try (InputStream is = url.openStream()) { -======= InputStream is = null; try { - String skip = request.getParameter("skip"); - int skipCnt = skip == null ? 0 : Integer.parseInt(skip); - is = loader.get(res, skipCnt); ->>>>>>> other + if (url == null) { + throw new IOException("Resource not found"); + } + is = url.openStream(); response.setContentType("text/javascript"); Writer w = response.getWriter(); w.append("(["); @@ -785,16 +791,15 @@ w.append(Integer.toString(b)); } w.append("\n])"); - } catch (IOException ex) - */ { + } catch (IOException ex) { response.setStatus(HttpStatus.NOT_FOUND_404); response.setError(); response.setDetailMessage(ex.getMessage()); - } /*finally { + } finally { if (is != null) { is.close(); } - }*/ + } } } diff -r 9afa6856382c -r 45c50b9c7dc4 launcher/http/src/main/java/org/apidesign/bck2brwsr/launcher/Bck2BrwsrLauncher.java --- a/launcher/http/src/main/java/org/apidesign/bck2brwsr/launcher/Bck2BrwsrLauncher.java Mon May 05 12:58:10 2014 +0200 +++ b/launcher/http/src/main/java/org/apidesign/bck2brwsr/launcher/Bck2BrwsrLauncher.java Mon May 05 13:49:05 2014 +0200 @@ -95,11 +95,12 @@ sb.append( "(function WrapperVM(global) {\n" + " var cache = {};\n" + + " var empty = {};\n" + " function ldCls(res, skip) {\n" + " var c = cache[res];\n" + " if (c) {\n" + + " if (c[skip] === empty) return null;\n" + " if (c[skip]) return c[skip];\n" - + " if (c[skip] === null) return null;\n" + " } else {\n" + " cache[res] = c = new Array();\n" + " }\n" @@ -111,6 +112,7 @@ + " return null;\n" + " }\n" + " var arr = eval(request.responseText);\n" + + " if (arr === null) arr = empty;\n" + " c[skip] = arr;\n" + " return arr;\n" + " }\n"