示例#1
0
文件: A.java 项目: nscavell/juzu
 @View
 public Response.Content index() throws IOException {
   if (bean != null) {
     serial = bean.getSerial();
     return Response.ok(A_.doneURL().toString());
   } else {
     return Response.ok("");
   }
 }
示例#2
0
文件: Bridge.java 项目: bdaw/juzu
  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();
      }
    }
  }
示例#3
0
文件: A.java 项目: nscavell/juzu
 @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");
   }
 }
示例#4
0
文件: Bridge.java 项目: bdaw/juzu
  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();
    }
  }
示例#5
0
文件: A.java 项目: benjp/juzu
 @View
 public Response.Render index() {
   return Response.ok("pass");
 }
示例#6
0
文件: A.java 项目: haint/juzu
 @View
 @Route(value = "/{foo}", priority = -1)
 public Response.Content foo2(String foo) {
   return Response.ok("foo2");
 }
示例#7
0
文件: A.java 项目: haint/juzu
 @View
 @Route("/{foo}")
 public Response.Content foo1(String foo) {
   return Response.ok("foo1");
 }
示例#8
0
文件: A.java 项目: benjp/juzu
 @View
 public Response.Content<?> index() throws IOException {
   return Response.ok(service != null ? "pass" : "");
 }