launcher/src/main/java/org/apidesign/bck2brwsr/launcher/Bck2BrwsrLauncher.java
branchlauncher
changeset 349 3fe5a86bd123
parent 348 4e9d576780ca
child 356 e078953818d2
     1.1 --- a/launcher/src/main/java/org/apidesign/bck2brwsr/launcher/Bck2BrwsrLauncher.java	Tue Dec 18 12:43:18 2012 +0100
     1.2 +++ b/launcher/src/main/java/org/apidesign/bck2brwsr/launcher/Bck2BrwsrLauncher.java	Tue Dec 18 13:10:56 2012 +0100
     1.3 @@ -31,6 +31,7 @@
     1.4  import java.util.List;
     1.5  import java.util.Set;
     1.6  import java.util.concurrent.CountDownLatch;
     1.7 +import java.util.concurrent.TimeUnit;
     1.8  import static org.apidesign.bck2brwsr.launcher.Bck2BrwsrLauncher.copyStream;
     1.9  import org.apidesign.vm4brwsr.Bck2Brwsr;
    1.10  import org.glassfish.grizzly.PortRange;
    1.11 @@ -47,6 +48,7 @@
    1.12  public class Bck2BrwsrLauncher {
    1.13      private Set<ClassLoader> loaders = new LinkedHashSet<>();
    1.14      private List<MethodInvocation> methods = new ArrayList<>();
    1.15 +    private long timeOut;
    1.16      
    1.17      
    1.18      public MethodInvocation addMethod(Class<?> clazz, String method) {
    1.19 @@ -56,7 +58,9 @@
    1.20          return c;
    1.21      }
    1.22      
    1.23 -    
    1.24 +    public void setTimeout(long ms) {
    1.25 +        timeOut = ms;
    1.26 +    }
    1.27      
    1.28      public static void main( String[] args ) throws Exception {
    1.29          Bck2BrwsrLauncher l = new Bck2BrwsrLauncher();
    1.30 @@ -131,7 +135,8 @@
    1.31              Runtime.getRuntime().exec(cmd).waitFor();
    1.32          }
    1.33          
    1.34 -        wait.await();
    1.35 +        wait.await(timeOut, TimeUnit.MILLISECONDS);
    1.36 +        server.stop();
    1.37      }
    1.38      
    1.39      static void copyStream(InputStream is, OutputStream os, String baseURL, String... params) throws IOException {