Beispiel #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("");
   }
 }
Beispiel #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();
      }
    }
  }
Beispiel #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");
   }
 }
Beispiel #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();
    }
  }
Beispiel #5
0
Datei: A.java Projekt: benjp/juzu
 @View
 public Response.Render index() {
   return Response.ok("pass");
 }
Beispiel #6
0
Datei: A.java Projekt: haint/juzu
 @View
 @Route(value = "/{foo}", priority = -1)
 public Response.Content foo2(String foo) {
   return Response.ok("foo2");
 }
Beispiel #7
0
Datei: A.java Projekt: haint/juzu
 @View
 @Route("/{foo}")
 public Response.Content foo1(String foo) {
   return Response.ok("foo1");
 }
Beispiel #8
0
Datei: A.java Projekt: benjp/juzu
 @View
 public Response.Content<?> index() throws IOException {
   return Response.ok(service != null ? "pass" : "");
 }