launcher/src/main/java/org/apidesign/bck2brwsr/launcher/Bck2BrwsrLauncher.java
branchlauncher
changeset 370 ed48023d1d85
parent 369 723d854272ae
child 371 bafc670aa10d
     1.1 --- a/launcher/src/main/java/org/apidesign/bck2brwsr/launcher/Bck2BrwsrLauncher.java	Sun Dec 23 09:17:26 2012 +0100
     1.2 +++ b/launcher/src/main/java/org/apidesign/bck2brwsr/launcher/Bck2BrwsrLauncher.java	Sun Dec 23 17:02:34 2012 +0100
     1.3 @@ -17,7 +17,6 @@
     1.4   */
     1.5  package org.apidesign.bck2brwsr.launcher;
     1.6  
     1.7 -import java.awt.Desktop;
     1.8  import java.io.File;
     1.9  import java.io.IOException;
    1.10  import java.io.InputStream;
    1.11 @@ -27,7 +26,6 @@
    1.12  import java.net.URI;
    1.13  import java.net.URISyntaxException;
    1.14  import java.net.URL;
    1.15 -import java.nio.file.Files;
    1.16  import java.util.ArrayList;
    1.17  import java.util.Arrays;
    1.18  import java.util.Enumeration;
    1.19 @@ -38,11 +36,6 @@
    1.20  import java.util.concurrent.TimeUnit;
    1.21  import java.util.logging.Level;
    1.22  import java.util.logging.Logger;
    1.23 -import javax.script.Invocable;
    1.24 -import javax.script.ScriptEngine;
    1.25 -import javax.script.ScriptEngineManager;
    1.26 -import javax.script.ScriptException;
    1.27 -import static org.apidesign.bck2brwsr.launcher.Bck2BrwsrLauncher.copyStream;
    1.28  import org.apidesign.vm4brwsr.Bck2Brwsr;
    1.29  import org.glassfish.grizzly.PortRange;
    1.30  import org.glassfish.grizzly.http.server.HttpHandler;
    1.31 @@ -62,7 +55,6 @@
    1.32      private Set<ClassLoader> loaders = new LinkedHashSet<>();
    1.33      private List<MethodInvocation> methods = new ArrayList<>();
    1.34      private long timeOut;
    1.35 -    private String sen;
    1.36      private String showURL;
    1.37      private final Res resources = new Res();
    1.38      
    1.39 @@ -78,10 +70,6 @@
    1.40          timeOut = ms;
    1.41      }
    1.42      
    1.43 -    public void setScriptEngineName(String sen) {
    1.44 -        this.sen = sen;
    1.45 -    }
    1.46 -
    1.47      public void setStartPage(String startpage) {
    1.48          if (!startpage.startsWith("/")) {
    1.49              startpage = "/" + startpage;
    1.50 @@ -104,9 +92,7 @@
    1.51  
    1.52      public void execute() throws IOException {
    1.53          try {
    1.54 -            if (sen != null) {
    1.55 -                executeRhino();
    1.56 -            } else if (showURL != null) {
    1.57 +            if (showURL != null) {
    1.58                  HttpServer server = initServer();
    1.59                  server.getServerConfiguration().addHttpHandler(new Page(resources, null), "/");
    1.60                  launchServerAndBrwsr(server, showURL);
    1.61 @@ -128,36 +114,6 @@
    1.62          }
    1.63      }
    1.64      
    1.65 -    private void executeRhino() throws IOException, ScriptException, NoSuchMethodException {
    1.66 -        StringBuilder sb = new StringBuilder();
    1.67 -        Bck2Brwsr.generate(sb, new Res());
    1.68 -
    1.69 -        ScriptEngineManager sem = new ScriptEngineManager();
    1.70 -        ScriptEngine mach = sem.getEngineByExtension(sen);
    1.71 -
    1.72 -        sb.append(
    1.73 -              "\nvar vm = new bck2brwsr(org.apidesign.bck2brwsr.launcher.Console.read);"
    1.74 -            + "\nfunction initVM() { return vm; };"
    1.75 -            + "\n");
    1.76 -
    1.77 -        Object res = mach.eval(sb.toString());
    1.78 -        if (!(mach instanceof Invocable)) {
    1.79 -            throw new IOException("It is invocable object: " + res);
    1.80 -        }
    1.81 -        Invocable code = (Invocable) mach;
    1.82 -        
    1.83 -        Object vm = code.invokeFunction("initVM");
    1.84 -        Object console = code.invokeMethod(vm, "loadClass", Console.class.getName());
    1.85 -
    1.86 -        final MethodInvocation[] cases = this.methods.toArray(new MethodInvocation[0]);
    1.87 -        for (MethodInvocation mi : cases) {
    1.88 -            mi.result = code.invokeMethod(console, 
    1.89 -                "invoke__Ljava_lang_String_2Ljava_lang_String_2Ljava_lang_String_2", 
    1.90 -                mi.className, mi.methodName
    1.91 -            ).toString();
    1.92 -        }
    1.93 -    }
    1.94 -    
    1.95      private HttpServer initServer() {
    1.96          HttpServer server = HttpServer.createSimpleServer(".", new PortRange(8080, 65535));
    1.97  
    1.98 @@ -456,20 +412,4 @@
    1.99              }
   1.100          }
   1.101      }
   1.102 -    
   1.103 -    public static final class MethodInvocation {
   1.104 -        final String className;
   1.105 -        final String methodName;
   1.106 -        String result;
   1.107 -
   1.108 -        MethodInvocation(String className, String methodName) {
   1.109 -            this.className = className;
   1.110 -            this.methodName = methodName;
   1.111 -        }
   1.112 -
   1.113 -        @Override
   1.114 -        public String toString() {
   1.115 -            return result;
   1.116 -        }
   1.117 -    }
   1.118  }