Package juzu.io

Examples of juzu.io.Stream


      if (result instanceof Response.Content) {
        Response.Status status = (Response.Status)result;
        final Streamable wrapped = status.streamable();
        Streamable wrapper = new Streamable() {
          public void send(final Stream stream) throws IllegalStateException {
            Stream our = new Stream() {
              boolean done = false;
              public void provide(Chunk chunk) {
                if (chunk instanceof Chunk.Data && !done) {
                  done = true;
                  stream.provide(new Chunk.Property<String>("juzu.ajax", PropertyType.ASSET));
View Full Code Here


    if (status == STATUS_BUFFERING) {
      sendHeaders();
    }
    if (status != STATUS_CLOSED) {
      status = STATUS_CLOSED;
      Stream dataStream = getDataStream(false);
      if (dataStream != null) {
        dataStream.close(errorHandler);
      }
      endAsync();
    }
  }
View Full Code Here

          //
          status = FAILED;
          stream.setStatusCode(500);
          page.clear();
          page.sendHeader(stream);
          Response.error(e).asStatus(true).streamable().send(new Stream() {
            public void provide(Chunk chunk) {
              stream.provide(chunk);
            }
            public void close(Thread.UncaughtExceptionHandler errorHandler) {
              // Do nothing
View Full Code Here

      //
      final AssetService assetPlugin = (AssetService)bridge.getApplication().getPlugin("asset");

      //
      Stream stream = new Stream() {

        /** . */
        private Charset charset = Tools.ISO_8859_1;

        /** . */
 
View Full Code Here

  }

  public void send(final Stream stream) throws IllegalStateException {
    sendHeader(stream);
    Stream wrapper = new Stream() {
      public void provide(Chunk chunk) {
        stream.provide(chunk);
      }
      public void close(Thread.UncaughtExceptionHandler errorHandler) {
        try {
View Full Code Here

  }

  public void setResponse(Response response) throws IllegalArgumentException, IOException {
    if (response instanceof Response.Status) {
      Response.Status body = (Response.Status)response;
      body.streamable().send(new Stream() {
        BinaryStream dataStream = null;
        public void provide(Chunk chunk) {
          if (chunk instanceof Chunk.Property) {
            Chunk.Property property = (Chunk.Property)chunk;
            if (property.type == PropertyType.ENCODING) {
View Full Code Here

  @Path("index.gtmpl")
  Template index;

  @View
  public Response.Content index() {
    Stream printer = OutputStream.create(Tools.UTF_8, new Appendable() {
      public Appendable append(CharSequence csq) throws IOException {
        throw new IOException();
      }

      public Appendable append(CharSequence csq, int start, int end) throws IOException {
        throw new IOException();
      }

      public Appendable append(char c) throws IOException {
        throw new IOException();
      }
    });
    index.renderTo(printer);
    final LinkedList<Throwable> errors = new LinkedList<Throwable>();
    printer.close(new Thread.UncaughtExceptionHandler() {
      public void uncaughtException(Thread t, Throwable e) {
        errors.add(e);
      }
    });
    String ret;
View Full Code Here

  @Override
  protected void doRender(TemplateRenderContext renderContext) throws TemplateExecutionException, IOException {
    StringWriter buffer = new StringWriter();
    mustache.execute(buffer, new Object[]{new ContextMap(renderContext)});
    Stream stream = renderContext.getPrinter();
    stream.provide(Chunk.create(buffer.getBuffer()));
  }
View Full Code Here

TOP

Related Classes of juzu.io.Stream

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.