launcher/src/main/java/org/apidesign/bck2brwsr/launcher/InvocationContext.java
branchmodel
changeset 877 3392f250c784
parent 626 f08eb4df84c1
     1.1 --- a/launcher/src/main/java/org/apidesign/bck2brwsr/launcher/InvocationContext.java	Thu Jan 31 19:21:37 2013 +0100
     1.2 +++ b/launcher/src/main/java/org/apidesign/bck2brwsr/launcher/InvocationContext.java	Fri Mar 22 16:59:47 2013 +0100
     1.3 @@ -19,6 +19,8 @@
     1.4  
     1.5  import java.io.IOException;
     1.6  import java.io.InputStream;
     1.7 +import java.util.ArrayList;
     1.8 +import java.util.List;
     1.9  import java.util.concurrent.CountDownLatch;
    1.10  import java.util.concurrent.TimeUnit;
    1.11  
    1.12 @@ -34,9 +36,7 @@
    1.13      private String result;
    1.14      private Throwable exception;
    1.15      String html;
    1.16 -    InputStream httpContent;
    1.17 -    String httpType;
    1.18 -    String httpPath;
    1.19 +    final List<Resource> resources = new ArrayList<>();
    1.20  
    1.21      InvocationContext(Launcher launcher, Class<?> clazz, String methodName) {
    1.22          this.launcher = launcher;
    1.23 @@ -55,13 +55,11 @@
    1.24      /** HTTP resource to be available during execution. An invocation may
    1.25       * perform an HTTP query and obtain a resource relative to the page.
    1.26       */
    1.27 -    public void setHttpResource(String relativePath, String mimeType, InputStream content) {
    1.28 +    public void addHttpResource(String relativePath, String mimeType, InputStream content) {
    1.29          if (relativePath == null || mimeType == null || content == null) {
    1.30              throw new NullPointerException();
    1.31          }
    1.32 -        this.httpPath = relativePath;
    1.33 -        this.httpType = mimeType;
    1.34 -        this.httpContent = content;
    1.35 +        resources.add(new Resource(content, mimeType, relativePath));
    1.36      }
    1.37      
    1.38      /** Invokes the associated method. 
    1.39 @@ -97,5 +95,16 @@
    1.40          wait.countDown();
    1.41      }
    1.42  
    1.43 -    
    1.44 +
    1.45 +    static final class Resource {
    1.46 +        final InputStream httpContent;
    1.47 +        final String httpType;
    1.48 +        final String httpPath;
    1.49 +
    1.50 +        Resource(InputStream httpContent, String httpType, String httpPath) {
    1.51 +            this.httpContent = httpContent;
    1.52 +            this.httpType = httpType;
    1.53 +            this.httpPath = httpPath;
    1.54 +        }
    1.55 +    }
    1.56  }