org.apache.deft.example.client
Class AsynchronousHttpClientPostExample
java.lang.Object
org.apache.deft.example.client.AsynchronousHttpClientPostExample
public class AsynchronousHttpClientPostExample
- extends Object
Example class to demonstrate usage of AsynchronousHttpClient.
|
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 |
AsynchronousHttpClientPostExample
public AsynchronousHttpClientPostExample()
main
public 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.
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.
- Create a
Request, providing target URL and HTTP method
as well as body and content type information.
- Create an instance of
AsynchronousHttpClient and pass
this Request with our previously defined callback.
- 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.
- Start the instance.
- Parameters:
args - the arguments to pass; unused.
Copyright © 2010-2011. All Rights Reserved.