launcher/src/main/java/org/apidesign/bck2brwsr/launcher/Bck2BrwsrLauncher.java
branchemul
changeset 692 d088fc482c65
parent 626 f08eb4df84c1
child 709 722c51330e75
     1.1 --- a/launcher/src/main/java/org/apidesign/bck2brwsr/launcher/Bck2BrwsrLauncher.java	Thu Jan 31 19:21:37 2013 +0100
     1.2 +++ b/launcher/src/main/java/org/apidesign/bck2brwsr/launcher/Bck2BrwsrLauncher.java	Wed Feb 06 18:24:53 2013 +0100
     1.3 @@ -39,6 +39,7 @@
     1.4  import java.util.concurrent.TimeUnit;
     1.5  import java.util.logging.Level;
     1.6  import java.util.logging.Logger;
     1.7 +import org.apidesign.bck2brwsr.launcher.InvocationContext.Resource;
     1.8  import org.apidesign.vm4brwsr.Bck2Brwsr;
     1.9  import org.glassfish.grizzly.PortRange;
    1.10  import org.glassfish.grizzly.http.server.HttpHandler;
    1.11 @@ -152,11 +153,13 @@
    1.12          class DynamicResourceHandler extends HttpHandler {
    1.13              private final InvocationContext ic;
    1.14              public DynamicResourceHandler(InvocationContext ic) {
    1.15 -                if (ic == null || ic.httpPath == null) {
    1.16 +                if (ic == null || ic.resources.isEmpty()) {
    1.17                      throw new NullPointerException();
    1.18                  }
    1.19                  this.ic = ic;
    1.20 -                conf.addHttpHandler(this, ic.httpPath);
    1.21 +                for (Resource r : ic.resources) {
    1.22 +                    conf.addHttpHandler(this, r.httpPath);
    1.23 +                }
    1.24              }
    1.25  
    1.26              public void close() {
    1.27 @@ -165,10 +168,12 @@
    1.28              
    1.29              @Override
    1.30              public void service(Request request, Response response) throws Exception {
    1.31 -                if (ic.httpPath.equals(request.getRequestURI())) {
    1.32 -                    LOG.log(Level.INFO, "Serving HttpResource for {0}", request.getRequestURI());
    1.33 -                    response.setContentType(ic.httpType);
    1.34 -                    copyStream(ic.httpContent, response.getOutputStream(), null);
    1.35 +                for (Resource r : ic.resources) {
    1.36 +                    if (r.httpPath.equals(request.getRequestURI())) {
    1.37 +                        LOG.log(Level.INFO, "Serving HttpResource for {0}", request.getRequestURI());
    1.38 +                        response.setContentType(r.httpType);
    1.39 +                        copyStream(r.httpContent, response.getOutputStream(), null);
    1.40 +                    }
    1.41                  }
    1.42              }
    1.43          }
    1.44 @@ -206,7 +211,7 @@
    1.45                      return;
    1.46                  }
    1.47                  
    1.48 -                if (mi.httpPath != null) {
    1.49 +                if (!mi.resources.isEmpty()) {
    1.50                      prev = new DynamicResourceHandler(mi);
    1.51                  }
    1.52