launcher/fx/src/main/java/org/apidesign/bck2brwsr/launcher/BaseHTTPLauncher.java
changeset 1619 a7bf87c2c1d9
parent 1574 d51a5533a2e7
parent 1615 80e39583b35d
child 1733 955520296b08
     1.1 --- a/launcher/fx/src/main/java/org/apidesign/bck2brwsr/launcher/BaseHTTPLauncher.java	Thu May 15 11:38:27 2014 +0200
     1.2 +++ b/launcher/fx/src/main/java/org/apidesign/bck2brwsr/launcher/BaseHTTPLauncher.java	Mon Jun 09 15:57:14 2014 +0200
     1.3 @@ -131,10 +131,12 @@
     1.4          if (!startpage.startsWith("/")) {
     1.5              startpage = "/" + startpage;
     1.6          }
     1.7 -        String prefix = "";
     1.8 -        int last = startpage.lastIndexOf('/');
     1.9 -        if (last >= 0) {
    1.10 -            prefix = startpage.substring(0, last);
    1.11 +        String prefix = null;
    1.12 +        if (!new File(dir, "bck2brwsr.js").exists()) {
    1.13 +            int last = startpage.lastIndexOf('/');
    1.14 +            if (last >= 0) {
    1.15 +                prefix = startpage.substring(0, last);
    1.16 +            }
    1.17          }
    1.18          HttpServer s = initServer(dir.getPath(), addClasses, prefix);
    1.19          try {
    1.20 @@ -565,7 +567,7 @@
    1.21  
    1.22      abstract void generateBck2BrwsrJS(StringBuilder sb, Res loader) throws IOException;
    1.23      abstract String harnessResource();
    1.24 -    String compileJar(JarFile jar) throws IOException {
    1.25 +    String compileJar(URL jar) throws IOException {
    1.26          return null;
    1.27      }
    1.28      String compileFromClassPath(URL f, Res loader) throws IOException {
    1.29 @@ -585,8 +587,8 @@
    1.30      final class Res {
    1.31          private final Set<URL> ignore = new HashSet<URL>();
    1.32          
    1.33 -        String compileJar(JarFile jar, URL jarURL) throws IOException {
    1.34 -            String ret = BaseHTTPLauncher.this.compileJar(jar);
    1.35 +        String compileJar(URL jarURL) throws IOException {
    1.36 +            String ret = BaseHTTPLauncher.this.compileJar(jarURL);
    1.37              ignore.add(jarURL);
    1.38              return ret;
    1.39          }
    1.40 @@ -748,7 +750,7 @@
    1.41                  response.setCharacterEncoding("UTF-8");
    1.42                  if (url.getProtocol().equals("jar")) {
    1.43                      JarURLConnection juc = (JarURLConnection) url.openConnection();
    1.44 -                    String s = loader.compileJar(juc.getJarFile(), juc.getJarFileURL());
    1.45 +                    String s = loader.compileJar(juc.getJarFileURL());
    1.46                      if (s != null) {
    1.47                          Writer w = response.getWriter();
    1.48                          w.append(s);
    1.49 @@ -757,6 +759,15 @@
    1.50                      }
    1.51                  }
    1.52                  if (url.getProtocol().equals("file")) {
    1.53 +                    final String filePart = url.getFile();
    1.54 +                    if (filePart.endsWith(res)) {
    1.55 +                        url = new URL(
    1.56 +                            url.getProtocol(), 
    1.57 +                            url.getHost(), 
    1.58 +                            url.getPort(), 
    1.59 +                            filePart.substring(0, filePart.length() - res.length())
    1.60 +                        );
    1.61 +                    }
    1.62                      String s = loader.compileFromClassPath(url);
    1.63                      if (s != null) {
    1.64                          Writer w = response.getWriter();