launcher/api/src/main/java/org/apidesign/bck2brwsr/launcher/InvocationContext.java
changeset 1860 4ce38f21f4cd
parent 1787 ea12a3bb4b33
child 1908 4f4554f69892
     1.1 --- a/launcher/api/src/main/java/org/apidesign/bck2brwsr/launcher/InvocationContext.java	Tue Feb 24 11:12:53 2015 +0100
     1.2 +++ b/launcher/api/src/main/java/org/apidesign/bck2brwsr/launcher/InvocationContext.java	Tue Jan 26 04:36:23 2016 +0100
     1.3 @@ -19,7 +19,6 @@
     1.4  
     1.5  import java.io.IOException;
     1.6  import java.io.InputStream;
     1.7 -import java.net.URI;
     1.8  import java.util.ArrayList;
     1.9  import java.util.List;
    1.10  import java.util.concurrent.CountDownLatch;
    1.11 @@ -38,6 +37,7 @@
    1.12      private Throwable exception;
    1.13      String html;
    1.14      final List<Resource> resources = new ArrayList<>();
    1.15 +    private int time;
    1.16  
    1.17      InvocationContext(Launcher launcher, Class<?> clazz, String methodName) {
    1.18          this.launcher = launcher;
    1.19 @@ -65,11 +65,27 @@
    1.20      
    1.21      /** Invokes the associated method. 
    1.22       * @return the textual result of the invocation
    1.23 +     * @throws java.io.IOException if execution fails
    1.24       */
    1.25      public String invoke() throws IOException {
    1.26          launcher.runMethod(this);
    1.27          return toString();
    1.28      }
    1.29 +
    1.30 +    /** Invokes the associated method.
    1.31 +     * @param time one element array to store the length of the invocation
    1.32 +     *    - can be <code>null</code>
    1.33 +     * @return the textual result of the invocation
    1.34 +     * @throws java.io.IOException if execution fails
    1.35 +     * @since 0.20
    1.36 +     */
    1.37 +    public String invoke(int[] time) throws IOException {
    1.38 +        launcher.runMethod(this);
    1.39 +        if (time != null) {
    1.40 +            time[0] = this.time;
    1.41 +        }
    1.42 +        return toString();
    1.43 +    }
    1.44      
    1.45      /** Obtains textual result of the invocation.
    1.46       * @return text representing the exception or result value
    1.47 @@ -90,7 +106,8 @@
    1.48          wait.await(timeOut, TimeUnit.MILLISECONDS);
    1.49      }
    1.50      
    1.51 -    void result(String r, Throwable e) {
    1.52 +    void result(String r, int time, Throwable e) {
    1.53 +        this.time = time;
    1.54          this.result = r;
    1.55          this.exception = e;
    1.56          wait.countDown();