org.springbyexample.httpclient
Class HttpClientTemplate

java.lang.Object
  extended by org.springbyexample.httpclient.AbstractHttpClientTemplate<RequestEntity>
      extended by org.springbyexample.httpclient.HttpClientTemplate
All Implemented Interfaces:
DisposableBean, InitializingBean

@Component
public class HttpClientTemplate
extends AbstractHttpClientTemplate<RequestEntity>

Template for easier use of HttpClient.

Author:
David Winterfeldt

Field Summary
 
Fields inherited from class org.springbyexample.httpclient.AbstractHttpClientTemplate
authenticationPreemptive, client, connectionManager, defaultUri, lCredentials
 
Constructor Summary
HttpClientTemplate()
          Constructor.
HttpClientTemplate(String defaultUri)
          Constructor.
HttpClientTemplate(String defaultUri, boolean init)
          Constructor.
 
Method Summary
 void executePostMethod(byte[] input)
          Execute post method.
 void executePostMethod(byte[] input, ResponseCallback<?> callback)
          Execute post method.
 void executePostMethod(InputStream input)
          Execute post method.
 void executePostMethod(InputStream input, ResponseCallback<?> callback)
          Execute post method.
 void executePostMethod(String input)
          Execute post method.
 void executePostMethod(String uri, RequestEntity requestPayload, Map<String,String> hParams, ResponseCallback<?> callback)
          Execute post method.
 void executePostMethod(String input, ResponseCallback<?> callback)
          Execute post method.
protected  void processHttpMethod(HttpMethod httpMethod, ResponseCallback<?> callback)
          Processes HttpMethod by executing the method, validating the response, and calling the callback.
 
Methods inherited from class org.springbyexample.httpclient.AbstractHttpClientTemplate
afterPropertiesSet, destroy, executeGetMethod, executeGetMethod, executeGetMethod, executeGetMethod, executeGetMethod, executeGetMethod, executePostMethod, executePostMethod, executePostMethod, executePostMethod, executePostMethod, getClient, getConnectionManager, getCredentials, getDefaultUri, isAuthenticationPreemptive, processHttpMethodParams, setAuthenticationPreemptive, setClient, setConnectionManager, setCredentials, setDefaultUri, validateResponse
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

HttpClientTemplate

public HttpClientTemplate()
Constructor.


HttpClientTemplate

public HttpClientTemplate(String defaultUri)
Constructor.

Parameters:
defaultUri - Default uri.

HttpClientTemplate

public HttpClientTemplate(String defaultUri,
                          boolean init)
Constructor.

Parameters:
defaultUri - Default uri.
init - Whether or not to initialize the bean.
Method Detail

executePostMethod

public void executePostMethod(byte[] input)
Execute post method.

Parameters:
input - Byte array RequestEntity to post for the request's data.

executePostMethod

public void executePostMethod(byte[] input,
                              ResponseCallback<?> callback)
Execute post method.

Parameters:
input - Byte array RequestEntity to post for the request's data.
callback - Callback with HTTP method's response.

executePostMethod

public void executePostMethod(String input)
Execute post method.

Parameters:
input - String to post for the request's data.

executePostMethod

public void executePostMethod(String input,
                              ResponseCallback<?> callback)
Execute post method.

Parameters:
input - String to post for the request's data.
callback - Callback with HTTP method's response.

executePostMethod

public void executePostMethod(InputStream input)
Execute post method.

Parameters:
input - InputStream to post for the request's data.

executePostMethod

public void executePostMethod(InputStream input,
                              ResponseCallback<?> callback)
Execute post method.

Parameters:
input - InputStream to post for the request's data.
callback - Callback with HTTP method's response.

executePostMethod

public void executePostMethod(String uri,
                              RequestEntity requestPayload,
                              Map<String,String> hParams,
                              ResponseCallback<?> callback)
Execute post method.

Specified by:
executePostMethod in class AbstractHttpClientTemplate<RequestEntity>
Parameters:
uri - URI to use when processing this HTTP request instead of using the default URI.
requestPayload - RequestEntity data to post.
hParams - Parameters for the HTTP post.
callback - Callback with HTTP method's response.

processHttpMethod

protected void processHttpMethod(HttpMethod httpMethod,
                                 ResponseCallback<?> callback)
Processes HttpMethod by executing the method, validating the response, and calling the callback.

Specified by:
processHttpMethod in class AbstractHttpClientTemplate<RequestEntity>
Parameters:
httpMethod - HttpMethod to process.
callback - Callback with HTTP method's response.


Copyright © 2008-2009 Spring by Example. All Rights Reserved.