1.1 --- a/launcher/fx/src/main/java/org/apidesign/bck2brwsr/launcher/BaseHTTPLauncher.java Mon Oct 07 14:59:21 2013 +0200
1.2 +++ b/launcher/fx/src/main/java/org/apidesign/bck2brwsr/launcher/BaseHTTPLauncher.java Sun Oct 20 20:36:03 2013 +0200
1.3 @@ -572,7 +572,10 @@
1.4 }
1.5
1.6 class Res {
1.7 - public InputStream get(String resource) throws IOException {
1.8 + public InputStream get(String resource, int skip) throws IOException {
1.9 + if (!resource.endsWith(".class")) {
1.10 + return getResource(resource, skip);
1.11 + }
1.12 URL u = null;
1.13 for (ClassLoader l : loaders) {
1.14 Enumeration<URL> en = l.getResources(resource);
1.15 @@ -592,6 +595,23 @@
1.16 }
1.17 throw new IOException("Can't find " + resource);
1.18 }
1.19 + private InputStream getResource(String resource, int skip) throws IOException {
1.20 + URL u = null;
1.21 + for (ClassLoader l : loaders) {
1.22 + Enumeration<URL> en = l.getResources(resource);
1.23 + while (en.hasMoreElements()) {
1.24 + final URL now = en.nextElement();
1.25 + if (--skip < 0) {
1.26 + u = now;
1.27 + break;
1.28 + }
1.29 + }
1.30 + }
1.31 + if (u != null) {
1.32 + return u.openStream();
1.33 + }
1.34 + return null;
1.35 + }
1.36 }
1.37
1.38 private static class Page extends HttpHandler {
1.39 @@ -624,7 +644,7 @@
1.40 }
1.41 OutputStream os = response.getOutputStream();
1.42 try {
1.43 - InputStream is = res.get(r);
1.44 + InputStream is = res.get(r, 0);
1.45 copyStream(is, os, request.getRequestURL().toString(), replace);
1.46 } catch (IOException ex) {
1.47 response.setDetailMessage(ex.getLocalizedMessage());
1.48 @@ -696,7 +716,9 @@
1.49 }
1.50 InputStream is = null;
1.51 try {
1.52 - is = loader.get(res);
1.53 + String skip = request.getParameter("skip");
1.54 + int skipCnt = skip == null ? 0 : Integer.parseInt(skip);
1.55 + is = loader.get(res, skipCnt);
1.56 response.setContentType("text/javascript");
1.57 Writer w = response.getWriter();
1.58 w.append("[");