org.apache.deft.example.client
Class AsynchronousHttpClientPostExample

java.lang.Object
  extended by org.apache.deft.example.client.AsynchronousHttpClientPostExample

public class AsynchronousHttpClientPostExample
extends Object

Example class to demonstrate usage of AsynchronousHttpClient.


Constructor Summary
AsynchronousHttpClientPostExample()
           
 
Method Summary
static void main(String[] args)
          A simple example of how to use the AsynchronousHttpClient, taking the following steps: Create an instance of AsyncResult<Response> and define the methods onSuccess and onFailure.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AsynchronousHttpClientPostExample

public AsynchronousHttpClientPostExample()
Method Detail

main

public static void main(String[] args)
A simple example of how to use the AsynchronousHttpClient, taking the following steps:
  1. Create an instance of AsyncResult<Response> and define the methods onSuccess and onFailure. This type will become the callback for our operation, and the actions defined in the method will be executed when that operation succeeds or fails respectively. In this case, we will detail the exception on failure and show the response body on success.
  2. Create a Request, providing target URL and HTTP method as well as body and content type information.
  3. Create an instance of AsynchronousHttpClient and pass this Request with our previously defined callback.
  4. Add time-out value to the current IOLoop of one second, and in the definition of the onCallback method tell the instance to stop listening when this time limit has been reached.
  5. Start the instance.

Parameters:
args - the arguments to pass; unused.


Copyright © 2010-2011. All Rights Reserved.