Package org.deftserver.example

Source Code of org.deftserver.example.AsynchronousHttpClientExample

package org.deftserver.example;

import static java.lang.System.out;

import org.deftserver.io.IOLoop;
import org.deftserver.web.AsyncResult;
import org.deftserver.web.http.client.AsynchronousHttpClient;
import org.deftserver.web.http.client.HttpResponse;

public class AsynchronousHttpClientExample {

  public static void main(String[] args) {
    AsynchronousHttpClient client = new AsynchronousHttpClient();
    client.fetch("http://tt.se/start/", new ResultCallback());
    IOLoop.INSTANCE.start();
  }
 
  private static class ResultCallback implements AsyncResult<HttpResponse> {

    @Override public void onFailure(Throwable caught) { out.println("exception caught: " + caught); }

    @Override public void onSuccess(HttpResponse response) { out.println("http resonse:\n" + response); }
   
  }

}
TOP

Related Classes of org.deftserver.example.AsynchronousHttpClientExample

TOP
Copyright © 2018 www.massapi.com. 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.