launcher/src/main/java/org/apidesign/bck2brwsr/launcher/Bck2BrwsrLauncher.java
branchemul
changeset 622 a07253cf2ca4
parent 613 a4a06840209a
child 623 4af0d3dedb9d
     1.1 --- a/launcher/src/main/java/org/apidesign/bck2brwsr/launcher/Bck2BrwsrLauncher.java	Wed Jan 30 18:27:57 2013 +0100
     1.2 +++ b/launcher/src/main/java/org/apidesign/bck2brwsr/launcher/Bck2BrwsrLauncher.java	Thu Jan 31 16:58:27 2013 +0100
     1.3 @@ -55,9 +55,9 @@
     1.4   */
     1.5  final class Bck2BrwsrLauncher extends Launcher implements Closeable {
     1.6      private static final Logger LOG = Logger.getLogger(Bck2BrwsrLauncher.class.getName());
     1.7 -    private static final MethodInvocation END = new MethodInvocation(null, null, null);
     1.8 -    private Set<ClassLoader> loaders = new LinkedHashSet<>();
     1.9 -    private BlockingQueue<MethodInvocation> methods = new LinkedBlockingQueue<>();
    1.10 +    private static final InvocationContext END = new InvocationContext(null, null, null);
    1.11 +    private final Set<ClassLoader> loaders = new LinkedHashSet<>();
    1.12 +    private final BlockingQueue<InvocationContext> methods = new LinkedBlockingQueue<>();
    1.13      private long timeOut;
    1.14      private final Res resources = new Res();
    1.15      private final String cmd;
    1.16 @@ -70,9 +70,8 @@
    1.17      }
    1.18      
    1.19      @Override
    1.20 -     MethodInvocation addMethod(Class<?> clazz, String method, String html) throws IOException {
    1.21 -        loaders.add(clazz.getClassLoader());
    1.22 -        MethodInvocation c = new MethodInvocation(clazz.getName(), method, html);
    1.23 +    InvocationContext runMethod(InvocationContext c) throws IOException {
    1.24 +        loaders.add(c.clazz.getClassLoader());
    1.25          methods.add(c);
    1.26          try {
    1.27              c.await(timeOut);
    1.28 @@ -154,7 +153,7 @@
    1.29          ), "/execute");
    1.30          conf.addHttpHandler(new HttpHandler() {
    1.31              int cnt;
    1.32 -            List<MethodInvocation> cases = new ArrayList<>();
    1.33 +            List<InvocationContext> cases = new ArrayList<>();
    1.34              @Override
    1.35              public void service(Request request, Response response) throws Exception {
    1.36                  String id = request.getParameter("request");
    1.37 @@ -166,7 +165,7 @@
    1.38                      cases.get(Integer.parseInt(id)).result(value, null);
    1.39                  }
    1.40                  
    1.41 -                MethodInvocation mi = methods.take();
    1.42 +                InvocationContext mi = methods.take();
    1.43                  if (mi == END) {
    1.44                      response.getWriter().write("");
    1.45                      wait.countDown();
    1.46 @@ -176,7 +175,7 @@
    1.47                  }
    1.48                  
    1.49                  cases.add(mi);
    1.50 -                final String cn = mi.className;
    1.51 +                final String cn = mi.clazz.getName();
    1.52                  final String mn = mi.methodName;
    1.53                  LOG.log(Level.INFO, "Request for {0} case. Sending {1}.{2}", new Object[]{cnt, cn, mn});
    1.54                  response.getWriter().write("{"