Exemple #1
0
 @View
 public Response.Content index() throws IOException {
   if (bean != null) {
     serial = bean.getSerial();
     return Response.ok(A_.doneURL().toString());
   } else {
     return Response.ok("");
   }
 }
Exemple #2
0
  public void render(final RenderBridge requestBridge) throws Throwable {

    //
    Collection<CompilationError> errors = null;
    try {
      boot();
    } catch (CompilationException e) {
      errors = e.getErrors();
    }

    //
    if (errors == null || errors.isEmpty()) {

      //
      if (errors != null) {
        requestBridge.purgeSession();
      }

      //
      try {
        TrimmingException.invoke(
            new TrimmingException.Callback() {
              public void call() throws Throwable {
                try {
                  runtime.getContext().invoke(requestBridge);
                } catch (ApplicationException e) {
                  throw e.getCause();
                }
              }
            });
      } catch (TrimmingException e) {
        if (config.isProd()) {
          throw e.getSource();
        } else {
          StringWriter writer = new StringWriter();
          PrintWriter printer = new PrintWriter(writer);
          renderThrowable(printer, e);
          requestBridge.setResponse(Response.ok(writer.getBuffer()));
        }
      } finally {
        requestBridge.close();
      }
    } else {
      try {
        StringWriter writer = new StringWriter();
        PrintWriter printer = new PrintWriter(writer);
        renderErrors(printer, errors);
        requestBridge.setResponse(Response.ok(writer.getBuffer()));
      } finally {
        requestBridge.close();
      }
    }
  }
Exemple #3
0
 @View
 public Response.Content done() throws IOException {
   if (bean != null) {
     if (serial + 1 == bean.getSerial()) {
       return Response.ok("pass");
     } else {
       return Response.ok(
           "failure: was expecting to have" + serial + " + 1 == " + bean.getSerial());
     }
   } else {
     return Response.ok("failure");
   }
 }
Exemple #4
0
  public void serveResource(final ResourceBridge requestBridge) throws Throwable {
    try {
      TrimmingException.invoke(
          new TrimmingException.Callback() {
            public void call() throws Throwable {
              try {
                runtime.getContext().invoke(requestBridge);
              } catch (ApplicationException e) {
                throw e.getCause();
              }
            }
          });
    } catch (TrimmingException e) {

      //
      logThrowable(e);

      // Internal server error
      Response response;
      if (!config.isProd()) {
        StringWriter writer = new StringWriter();
        PrintWriter printer = new PrintWriter(writer);
        printer.print("<html>\n");
        printer.print("<head>\n");
        printer.print("</head>\n");
        printer.print("<body>\n");
        renderThrowable(printer, e);
        printer.print("</body>\n");
        response = Response.content(500, writer.getBuffer());
      } else {
        response = Response.content(500, "todo");
      }

      // Set response
      requestBridge.setResponse(response);
    } finally {
      requestBridge.close();
    }
  }
Exemple #5
0
 @View
 public Response.Render index() {
   return Response.ok("pass");
 }
Exemple #6
0
 @View
 @Route(value = "/{foo}", priority = -1)
 public Response.Content foo2(String foo) {
   return Response.ok("foo2");
 }
Exemple #7
0
 @View
 @Route("/{foo}")
 public Response.Content foo1(String foo) {
   return Response.ok("foo1");
 }
Exemple #8
0
 @View
 public Response.Content<?> index() throws IOException {
   return Response.ok(service != null ? "pass" : "");
 }