rt/launcher/src/main/java/org/apidesign/bck2brwsr/launcher/Launcher.java
branchelements
changeset 1072 3800d11c0bdb
parent 913 146ae7b52b64
parent 1071 2894b9a9dbfc
child 1073 9321b4016d5c
     1.1 --- a/rt/launcher/src/main/java/org/apidesign/bck2brwsr/launcher/Launcher.java	Tue Apr 02 15:40:51 2013 +0200
     1.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.3 @@ -1,116 +0,0 @@
     1.4 -/**
     1.5 - * Back 2 Browser Bytecode Translator
     1.6 - * Copyright (C) 2012 Jaroslav Tulach <jaroslav.tulach@apidesign.org>
     1.7 - *
     1.8 - * This program is free software: you can redistribute it and/or modify
     1.9 - * it under the terms of the GNU General Public License as published by
    1.10 - * the Free Software Foundation, version 2 of the License.
    1.11 - *
    1.12 - * This program is distributed in the hope that it will be useful,
    1.13 - * but WITHOUT ANY WARRANTY; without even the implied warranty of
    1.14 - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    1.15 - * GNU General Public License for more details.
    1.16 - *
    1.17 - * You should have received a copy of the GNU General Public License
    1.18 - * along with this program. Look for COPYING file in the top folder.
    1.19 - * If not, see http://opensource.org/licenses/GPL-2.0.
    1.20 - */
    1.21 -package org.apidesign.bck2brwsr.launcher;
    1.22 -
    1.23 -import java.io.Closeable;
    1.24 -import java.io.File;
    1.25 -import java.io.IOException;
    1.26 -import org.apidesign.vm4brwsr.Bck2Brwsr;
    1.27 -
    1.28 -/** An abstraction for executing tests in a Bck2Brwsr virtual machine.
    1.29 - * Either in {@linkm Launcher#createJavaScript JavaScript engine}, 
    1.30 - * or in {@linkm Launcher#createBrowser external browser}.
    1.31 - * <p>
    1.32 - * There also are methods to {@link #showDir(java.io.File, java.lang.String) display pages} 
    1.33 - * in an external browser served by internal HTTP server.
    1.34 - *
    1.35 - * @author Jaroslav Tulach <jtulach@netbeans.org>
    1.36 - */
    1.37 -public abstract class Launcher {
    1.38 -
    1.39 -    Launcher() {
    1.40 -    }
    1.41 -
    1.42 -    /** Initializes the launcher. This may mean starting a web browser or
    1.43 -     * initializing execution engine.
    1.44 -     * @throws IOException if something goes wrong
    1.45 -     */
    1.46 -    public abstract void initialize() throws IOException;
    1.47 -    
    1.48 -    /** Shuts down the launcher.
    1.49 -     * @throws IOException if something goes wrong
    1.50 -     */
    1.51 -    public abstract void shutdown() throws IOException;
    1.52 -    
    1.53 -    
    1.54 -    /** Builds an invocation context. The context can later be customized
    1.55 -     * and {@link InvocationContext#invoke() invoked}.
    1.56 -     * 
    1.57 -     * @param clazz the class to execute method from
    1.58 -     * @param method the method to execute
    1.59 -     * @return the context pointing to the selected method
    1.60 -     */
    1.61 -    public InvocationContext createInvocation(Class<?> clazz, String method) {
    1.62 -        return new InvocationContext(this, clazz, method);
    1.63 -    }
    1.64 -    
    1.65 -
    1.66 -    /** Creates launcher that uses internal JavaScript engine (Rhino).
    1.67 -     * @return the launcher
    1.68 -     */
    1.69 -    public static Launcher createJavaScript() {
    1.70 -        final JSLauncher l = new JSLauncher();
    1.71 -        l.addClassLoader(Bck2Brwsr.class.getClassLoader());
    1.72 -        return l;
    1.73 -    }
    1.74 -    
    1.75 -    /** Creates launcher that is using external browser.
    1.76 -     * 
    1.77 -     * @param cmd <code>null</code> to use <code>java.awt.Desktop</code> to show the launcher
    1.78 -     *    or a string to execute in an external process (with a parameter to the URL)
    1.79 -     * @return launcher executing in external browser.
    1.80 -     */
    1.81 -    public static Launcher createBrowser(String cmd) {
    1.82 -        final Bck2BrwsrLauncher l = new Bck2BrwsrLauncher(cmd);
    1.83 -        l.addClassLoader(Bck2Brwsr.class.getClassLoader());
    1.84 -        l.setTimeout(180000);
    1.85 -        return l;
    1.86 -    }
    1.87 -    
    1.88 -    /** Starts an HTTP server which provides access to classes and resources
    1.89 -     * available in the <code>classes</code> URL and shows a start page
    1.90 -     * available as {@link ClassLoader#getResource(java.lang.String)} from the
    1.91 -     * provide classloader. Opens a browser with URL showing the start page.
    1.92 -     * 
    1.93 -     * @param classes classloader offering access to classes and resources
    1.94 -     * @param startpage page to show in the browser
    1.95 -     * @return interface that allows one to stop the server
    1.96 -     * @throws IOException if something goes wrong
    1.97 -     */
    1.98 -    public static Closeable showURL(ClassLoader classes, String startpage) throws IOException {
    1.99 -        Bck2BrwsrLauncher l = new Bck2BrwsrLauncher(null);
   1.100 -        l.addClassLoader(classes);
   1.101 -        l.showURL(startpage);
   1.102 -        return l;
   1.103 -    }
   1.104 -    /** Starts an HTTP server which provides access to certain directory.
   1.105 -     * The <code>startpage</code> should be relative location inside the root 
   1.106 -     * directory. Opens a browser with URL showing the start page.
   1.107 -     * 
   1.108 -     * @param directory the root directory on disk
   1.109 -     * @param startpage relative path from the root to the page
   1.110 -     * @exception IOException if something goes wrong.
   1.111 -     */
   1.112 -    public static Closeable showDir(File directory, String startpage) throws IOException {
   1.113 -        Bck2BrwsrLauncher l = new Bck2BrwsrLauncher(null);
   1.114 -        l.showDirectory(directory, startpage);
   1.115 -        return l;
   1.116 -    }
   1.117 -
   1.118 -    abstract InvocationContext runMethod(InvocationContext c) throws IOException; 
   1.119 -}